feat(@community): Add tags to communities

Close #5680
This commit is contained in:
MishkaRogachev 2022-06-09 17:59:54 +03:00 committed by Mikhail Rogachev
parent 1cda32470b
commit e30ba7e760
21 changed files with 338 additions and 17 deletions

View File

@ -385,6 +385,7 @@ proc editCommunity*(
outroMessage: string, outroMessage: string,
access: int, access: int,
color: string, color: string,
tags: string,
logoJsonStr: string, logoJsonStr: string,
bannerJsonStr: string, bannerJsonStr: string,
historyArchiveSupportEnabled: bool, historyArchiveSupportEnabled: bool,
@ -397,6 +398,7 @@ proc editCommunity*(
outroMessage, outroMessage,
access, access,
color, color,
tags,
logoJsonStr, logoJsonStr,
bannerJsonStr, bannerJsonStr,
historyArchiveSupportEnabled, historyArchiveSupportEnabled,

View File

@ -252,7 +252,9 @@ method removeUserFromCommunity*(self: AccessInterface, pubKey: string) {.base.}
method banUserFromCommunity*(self: AccessInterface, pubKey: string) {.base.} = method banUserFromCommunity*(self: AccessInterface, pubKey: string) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method editCommunity*(self: AccessInterface, name: string, description, introMessage, outroMessage: string, access: int, color: string, logoJsonData: string, bannerJsonData: string, historyArchiveSupportEnabled: bool, pinMessageAllMembersEnabled: bool) {.base.} = method editCommunity*(self: AccessInterface, name: string, description, introMessage, outroMessage: string,
access: int, color: string, tags: string, logoJsonData: string, bannerJsonData: string,
historyArchiveSupportEnabled: bool, pinMessageAllMembersEnabled: bool) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method exportCommunity*(self: AccessInterface): string {.base.} = method exportCommunity*(self: AccessInterface): string {.base.} =

View File

@ -741,12 +741,13 @@ method banUserFromCommunity*(self: Module, pubKey: string) =
method editCommunity*(self: Module, name: string, method editCommunity*(self: Module, name: string,
description, introMessage, outroMessage: string, description, introMessage, outroMessage: string,
access: int, color: string, access: int, color: string, tags: string,
logoJsonStr: string, logoJsonStr: string,
bannerJsonStr: string, bannerJsonStr: string,
historyArchiveSupportEnabled: bool, historyArchiveSupportEnabled: bool,
pinMessageAllMembersEnabled: bool) = pinMessageAllMembersEnabled: bool) =
self.controller.editCommunity(name, description, introMessage, outroMessage, access, color, logoJsonStr, bannerJsonStr, historyArchiveSupportEnabled, pinMessageAllMembersEnabled) self.controller.editCommunity(name, description, introMessage, outroMessage, access, color, tags, logoJsonStr,
bannerJsonStr, historyArchiveSupportEnabled, pinMessageAllMembersEnabled)
method exportCommunity*(self: Module): string = method exportCommunity*(self: Module): string =
self.controller.exportCommunity() self.controller.exportCommunity()

View File

@ -247,8 +247,11 @@ QtObject:
proc banUserFromCommunity*(self: View, pubKey: string) {.slot.} = proc banUserFromCommunity*(self: View, pubKey: string) {.slot.} =
self.delegate.banUserFromCommunity(pubKey) self.delegate.banUserFromCommunity(pubKey)
proc editCommunity*(self: View, name: string, description: string, introMessage: string, outroMessage: string, access: int, color: string, logoJsonData: string, bannerJsonData: string, historyArchiveSupportEnabled: bool, pinMessageAllMembersEnabled: bool) {.slot.} = proc editCommunity*(self: View, name: string, description: string, introMessage: string, outroMessage: string, access: int,
self.delegate.editCommunity(name, description, introMessage, outroMessage, access, color, logoJsonData, bannerJsonData, historyArchiveSupportEnabled, pinMessageAllMembersEnabled) color: string, tags: string, logoJsonData: string, bannerJsonData: string, historyArchiveSupportEnabled: bool,
pinMessageAllMembersEnabled: bool) {.slot.} =
self.delegate.editCommunity(name, description, introMessage, outroMessage, access, color, tags,
logoJsonData, bannerJsonData, historyArchiveSupportEnabled, pinMessageAllMembersEnabled)
proc exportCommunity*(self: View): string {.slot.} = proc exportCommunity*(self: View): string {.slot.} =
self.delegate.exportCommunity() self.delegate.exportCommunity()

View File

@ -62,6 +62,9 @@ proc init*(self: Controller) =
let args = CommunityMutedArgs(e) let args = CommunityMutedArgs(e)
self.delegate.communityMuted(args.communityId, args.muted) self.delegate.communityMuted(args.communityId, args.muted)
proc getCommunityTags*(self: Controller): string =
result = self.communityService.getCommunityTags()
proc getAllCommunities*(self: Controller): seq[CommunityDto] = proc getAllCommunities*(self: Controller): seq[CommunityDto] =
result = self.communityService.getAllCommunities() result = self.communityService.getAllCommunities()
@ -82,6 +85,7 @@ proc createCommunity*(
outroMessage: string, outroMessage: string,
access: int, access: int,
color: string, color: string,
tags: string,
imageUrl: string, imageUrl: string,
aX: int, aY: int, bX: int, bY: int, aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool, historyArchiveSupportEnabled: bool,
@ -93,6 +97,7 @@ proc createCommunity*(
outroMessage, outroMessage,
access, access,
color, color,
tags,
imageUrl, imageUrl,
aX, aY, bX, bY, aX, aY, bX, bY,
historyArchiveSupportEnabled, historyArchiveSupportEnabled,

View File

@ -13,6 +13,9 @@ method load*(self: AccessInterface) {.base.} =
method isLoaded*(self: AccessInterface): bool {.base.} = method isLoaded*(self: AccessInterface): bool {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method setCommunityTags*(self: AccessInterface, communityTags: string) {.base.} =
raise newException(ValueError, "No implementation available")
method setAllCommunities*(self: AccessInterface, communities: seq[CommunityDto]) {.base.} = method setAllCommunities*(self: AccessInterface, communities: seq[CommunityDto]) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
@ -25,7 +28,9 @@ method getCommunityItem*(self: AccessInterface, community: CommunityDto): Sectio
method joinCommunity*(self: AccessInterface, communityId: string): string {.base.} = method joinCommunity*(self: AccessInterface, communityId: string): string {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method createCommunity*(self: AccessInterface, name: string, description, introMessage, outroMessage: string, access: int, color: string, imagePath: string, aX: int, aY: int, bX: int, bY: int, historyArchiveSupportEnabled: bool, pinMessageAllMembersEnabled: bool) {.base.} = method createCommunity*(self: AccessInterface, name: string, description, introMessage, outroMessage: string, access: int,
color: string, tags: string, imagePath: string, aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool, pinMessageAllMembersEnabled: bool) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method deleteCommunityCategory*(self: AccessInterface, communityId: string, categoryId: string) {.base.} = method deleteCommunityCategory*(self: AccessInterface, communityId: string, categoryId: string) {.base.} =

View File

@ -30,6 +30,7 @@ type
moduleLoaded: bool moduleLoaded: bool
# Forward declaration # Forward declaration
method setCommunityTags*(self: Module, communityTags: string)
method setAllCommunities*(self: Module, communities: seq[CommunityDto]) method setAllCommunities*(self: Module, communities: seq[CommunityDto])
method setCuratedCommunities*(self: Module, curatedCommunities: seq[CuratedCommunity]) method setCuratedCommunities*(self: Module, curatedCommunities: seq[CuratedCommunity])
@ -66,6 +67,7 @@ method isLoaded*(self: Module): bool =
method viewDidLoad*(self: Module) = method viewDidLoad*(self: Module) =
self.moduleLoaded = true self.moduleLoaded = true
self.setCommunityTags(self.controller.getCommunityTags())
self.setAllCommunities(self.controller.getAllCommunities()) self.setAllCommunities(self.controller.getAllCommunities())
self.setCuratedCommunities(self.controller.getCuratedCommunities()) self.setCuratedCommunities(self.controller.getCuratedCommunities())
@ -121,6 +123,9 @@ method getCuratedCommunityItem(self: Module, c: CuratedCommunity): CuratedCommun
c.community.color, c.community.color,
len(c.community.members)) len(c.community.members))
method setCommunityTags*(self: Module, communityTags: string) =
self.view.setCommunityTags(communityTags)
method setAllCommunities*(self: Module, communities: seq[CommunityDto]) = method setAllCommunities*(self: Module, communities: seq[CommunityDto]) =
for community in communities: for community in communities:
self.view.addItem(self.getCommunityItem(community)) self.view.addItem(self.getCommunityItem(community))
@ -175,12 +180,13 @@ method communityCategoryDeleted*(self: Module) =
method createCommunity*(self: Module, name: string, method createCommunity*(self: Module, name: string,
description, introMessage: string, outroMessage: string, description, introMessage: string, outroMessage: string,
access: int, color: string, access: int, color: string, tags: string,
imagePath: string, imagePath: string,
aX: int, aY: int, bX: int, bY: int, aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool, historyArchiveSupportEnabled: bool,
pinMessageAllMembersEnabled: bool) = pinMessageAllMembersEnabled: bool) =
self.controller.createCommunity(name, description, introMessage, outroMessage, access, color, imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled, pinMessageAllMembersEnabled) self.controller.createCommunity(name, description, introMessage, outroMessage, access, color, tags,
imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled, pinMessageAllMembersEnabled)
method deleteCommunityCategory*(self: Module, communityId: string, categoryId: string) = method deleteCommunityCategory*(self: Module, communityId: string, categoryId: string) =
self.controller.deleteCommunityCategory(communityId, categoryId) self.controller.deleteCommunityCategory(communityId, categoryId)

View File

@ -10,6 +10,7 @@ import ./models/curated_community_model
QtObject: QtObject:
type type
View* = ref object of QObject View* = ref object of QObject
communityTags: QVariant
delegate: io_interface.AccessInterface delegate: io_interface.AccessInterface
model: SectionModel model: SectionModel
modelVariant: QVariant modelVariant: QVariant
@ -28,6 +29,7 @@ QtObject:
proc newView*(delegate: io_interface.AccessInterface): View = proc newView*(delegate: io_interface.AccessInterface): View =
new(result, delete) new(result, delete)
result.QObject.setup result.QObject.setup
result.communityTags = newQVariant("")
result.delegate = delegate result.delegate = delegate
result.model = newModel() result.model = newModel()
result.modelVariant = newQVariant(result.model) result.modelVariant = newQVariant(result.model)
@ -41,6 +43,9 @@ QtObject:
proc communityAdded*(self: View, communityId: string) {.signal.} proc communityAdded*(self: View, communityId: string) {.signal.}
proc communityChanged*(self: View, communityId: string) {.signal.} proc communityChanged*(self: View, communityId: string) {.signal.}
proc setCommunityTags*(self: View, communityTags: string) =
self.communityTags = newQVariant(communityTags)
proc addItem*(self: View, item: SectionItem) = proc addItem*(self: View, item: SectionItem) =
self.model.addItem(item) self.model.addItem(item)
self.communityAdded(item.id) self.communityAdded(item.id)
@ -48,6 +53,12 @@ QtObject:
proc model*(self: View): SectionModel = proc model*(self: View): SectionModel =
result = self.model result = self.model
proc getTags(self: View): QVariant {.slot.} =
return self.communityTags
QtProperty[QVariant] tags:
read = getTags
proc getModel(self: View): QVariant {.slot.} = proc getModel(self: View): QVariant {.slot.} =
return self.modelVariant return self.modelVariant
@ -84,12 +95,13 @@ QtObject:
proc createCommunity*(self: View, name: string, proc createCommunity*(self: View, name: string,
description: string, introMessage: string, outroMessage: string, description: string, introMessage: string, outroMessage: string,
access: int, color: string, access: int, color: string, tags: string,
imagePath: string, imagePath: string,
aX: int, aY: int, bX: int, bY: int, aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool, historyArchiveSupportEnabled: bool,
pinMessageAllMembersEnabled: bool) {.slot.} = pinMessageAllMembersEnabled: bool) {.slot.} =
self.delegate.createCommunity(name, description, introMessage, outroMessage, access, color, imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled, pinMessageAllMembersEnabled) self.delegate.createCommunity(name, description, introMessage, outroMessage, access, color, tags,
imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled, pinMessageAllMembersEnabled)
proc deleteCommunityCategory*(self: View, communityId: string, categoryId: string): string {.slot.} = proc deleteCommunityCategory*(self: View, communityId: string, categoryId: string): string {.slot.} =
self.delegate.deleteCommunityCategory(communityId, categoryId) self.delegate.deleteCommunityCategory(communityId, categoryId)

View File

@ -61,6 +61,7 @@ type CommunityDto* = object
canManageUsers*: bool canManageUsers*: bool
canJoin*: bool canJoin*: bool
color*: string color*: string
tags*: string
requestedToJoinAt*: int64 requestedToJoinAt*: int64
isMember*: bool isMember*: bool
muted*: bool muted*: bool
@ -120,6 +121,7 @@ proc toCommunityDto*(jsonObj: JsonNode): CommunityDto =
discard jsonObj.getProp("canManageUsers", result.canManageUsers) discard jsonObj.getProp("canManageUsers", result.canManageUsers)
discard jsonObj.getProp("canJoin", result.canJoin) discard jsonObj.getProp("canJoin", result.canJoin)
discard jsonObj.getProp("color", result.color) discard jsonObj.getProp("color", result.color)
discard jsonObj.getProp("tags", result.tags)
discard jsonObj.getProp("requestedToJoinAt", result.requestedToJoinAt) discard jsonObj.getProp("requestedToJoinAt", result.requestedToJoinAt)
discard jsonObj.getProp("isMember", result.isMember) discard jsonObj.getProp("isMember", result.isMember)
discard jsonObj.getProp("muted", result.muted) discard jsonObj.getProp("muted", result.muted)
@ -179,6 +181,7 @@ proc toChannelGroupDto*(communityDto: CommunityDto): ChannelGroupDto =
introMessage: communityDto.introMessage, introMessage: communityDto.introMessage,
outroMessage: communityDto.outroMessage, outroMessage: communityDto.outroMessage,
color: communityDto.color, color: communityDto.color,
# tags: communityDto.tags, NOTE: do we need tags here?
permissions: communityDto.permissions, permissions: communityDto.permissions,
members: communityDto.members.map(m => ChatMember( members: communityDto.members.map(m => ChatMember(
id: m.id, id: m.id,

View File

@ -25,7 +25,7 @@ type
community*: CommunityDto community*: CommunityDto
error*: string error*: string
fromUserAction*: bool fromUserAction*: bool
CuratedCommunityArgs* = ref object of Args CuratedCommunityArgs* = ref object of Args
curatedCommunity*: CuratedCommunity curatedCommunity*: CuratedCommunity
@ -100,12 +100,14 @@ QtObject:
threadpool: ThreadPool threadpool: ThreadPool
events: EventEmitter events: EventEmitter
chatService: chat_service.Service chatService: chat_service.Service
communityTags: string # JSON string contraining tags map
joinedCommunities: Table[string, CommunityDto] # [community_id, CommunityDto] joinedCommunities: Table[string, CommunityDto] # [community_id, CommunityDto]
curatedCommunities: Table[string, CuratedCommunity] # [community_id, CuratedCommunity] curatedCommunities: Table[string, CuratedCommunity] # [community_id, CuratedCommunity]
allCommunities: Table[string, CommunityDto] # [community_id, CommunityDto] allCommunities: Table[string, CommunityDto] # [community_id, CommunityDto]
myCommunityRequests*: seq[CommunityMembershipRequestDto] myCommunityRequests*: seq[CommunityMembershipRequestDto]
# Forward declaration # Forward declaration
proc loadCommunityTags(self: Service): string
proc loadAllCommunities(self: Service): seq[CommunityDto] proc loadAllCommunities(self: Service): seq[CommunityDto]
proc loadJoinedComunities(self: Service): seq[CommunityDto] proc loadJoinedComunities(self: Service): seq[CommunityDto]
proc loadCuratedCommunities(self: Service): seq[CuratedCommunity] proc loadCuratedCommunities(self: Service): seq[CuratedCommunity]
@ -127,6 +129,7 @@ QtObject:
result.events = events result.events = events
result.threadpool = threadpool result.threadpool = threadpool
result.chatService = chatService result.chatService = chatService
result.communityTags = newString(0)
result.joinedCommunities = initTable[string, CommunityDto]() result.joinedCommunities = initTable[string, CommunityDto]()
result.curatedCommunities = initTable[string, CuratedCommunity]() result.curatedCommunities = initTable[string, CuratedCommunity]()
result.allCommunities = initTable[string, CommunityDto]() result.allCommunities = initTable[string, CommunityDto]()
@ -327,6 +330,7 @@ QtObject:
proc init*(self: Service) = proc init*(self: Service) =
self.doConnect() self.doConnect()
self.communityTags = self.loadCommunityTags();
let joinedCommunities = self.loadJoinedComunities() let joinedCommunities = self.loadJoinedComunities()
for community in joinedCommunities: for community in joinedCommunities:
self.joinedCommunities[community.id] = community self.joinedCommunities[community.id] = community
@ -350,6 +354,12 @@ QtObject:
self.loadMyPendingRequestsToJoin() self.loadMyPendingRequestsToJoin()
proc loadCommunityTags(self: Service): string =
let response = status_go.getCommunityTags()
var result = newString(0)
toUgly(result, response.result)
return result
proc loadAllCommunities(self: Service): seq[CommunityDto] = proc loadAllCommunities(self: Service): seq[CommunityDto] =
try: try:
let response = status_go.getAllCommunities() let response = status_go.getAllCommunities()
@ -386,6 +396,9 @@ QtObject:
error "error loading communities settings: ", errDesription error "error loading communities settings: ", errDesription
return return
proc getCommunityTags*(self: Service): string =
return self.communityTags
proc getJoinedCommunities*(self: Service): seq[CommunityDto] = proc getJoinedCommunities*(self: Service): seq[CommunityDto] =
return toSeq(self.joinedCommunities.values) return toSeq(self.joinedCommunities.values)
@ -498,7 +511,7 @@ QtObject:
if not response.result.hasKey("communitiesSettings") or response.result["communitiesSettings"].kind != JArray or response.result["communitiesSettings"].len == 0: if not response.result.hasKey("communitiesSettings") or response.result["communitiesSettings"].kind != JArray or response.result["communitiesSettings"].len == 0:
error "error: ", procName="joinCommunity", errDesription = "no 'communitiesSettings' key in response" error "error: ", procName="joinCommunity", errDesription = "no 'communitiesSettings' key in response"
return return
var updatedCommunity = response.result["communities"][0].toCommunityDto() var updatedCommunity = response.result["communities"][0].toCommunityDto()
let communitySettings = response.result["communitiesSettings"][0].toCommunitySettingsDto() let communitySettings = response.result["communitiesSettings"][0].toCommunitySettingsDto()
@ -591,6 +604,7 @@ QtObject:
outroMessage: string, outroMessage: string,
access: int, access: int,
color: string, color: string,
tags: string,
imageUrl: string, imageUrl: string,
aX: int, aY: int, bX: int, bY: int, aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool, historyArchiveSupportEnabled: bool,
@ -604,6 +618,7 @@ QtObject:
outroMessage, outroMessage,
access, access,
color, color,
tags,
image, image,
aX, aY, bX, bY, aX, aY, bX, bY,
historyArchiveSupportEnabled, historyArchiveSupportEnabled,
@ -635,6 +650,7 @@ QtObject:
outroMessage: string, outroMessage: string,
access: int, access: int,
color: string, color: string,
tags: string,
logoJsonStr: string, logoJsonStr: string,
bannerJsonStr: string, bannerJsonStr: string,
historyArchiveSupportEnabled: bool, historyArchiveSupportEnabled: bool,
@ -651,6 +667,7 @@ QtObject:
outroMessage, outroMessage,
access, access,
color, color,
tags,
logoJson["imagePath"].getStr(), logoJson["imagePath"].getStr(),
int(cropRectJson["x"].getFloat()), int(cropRectJson["x"].getFloat()),
int(cropRectJson["y"].getFloat()), int(cropRectJson["y"].getFloat()),

View File

@ -6,6 +6,9 @@ import interpret/cropped_image
export response_type export response_type
proc getCommunityTags*(): RpcResponse[JsonNode] {.raises: [Exception].} =
result = callPrivateRPC("communityTags".prefix)
proc getJoinedComunities*(): RpcResponse[JsonNode] {.raises: [Exception].} = proc getJoinedComunities*(): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [] let payload = %* []
result = callPrivateRPC("joinedCommunities".prefix, payload) result = callPrivateRPC("joinedCommunities".prefix, payload)
@ -42,6 +45,7 @@ proc createCommunity*(
outroMessage: string, outroMessage: string,
access: int, access: int,
color: string, color: string,
tags: string,
imageUrl: string, imageUrl: string,
aX: int, aY: int, bX: int, bY: int, aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool, historyArchiveSupportEnabled: bool,
@ -56,6 +60,7 @@ proc createCommunity*(
"outroMessage": outroMessage, "outroMessage": outroMessage,
"ensOnly": false, # TODO ensOnly is no longer supported. Remove this when we remove it in status-go "ensOnly": false, # TODO ensOnly is no longer supported. Remove this when we remove it in status-go
"color": color, "color": color,
"tags": parseJson(tags),
"image": imageUrl, "image": imageUrl,
"imageAx": aX, "imageAx": aX,
"imageAy": aY, "imageAy": aY,
@ -73,6 +78,7 @@ proc editCommunity*(
outroMessage: string, outroMessage: string,
access: int, access: int,
color: string, color: string,
tags: string,
imageUrl: string, imageUrl: string,
aX: int, aX: int,
aY: int, aY: int,
@ -92,6 +98,7 @@ proc editCommunity*(
"outroMessage": outroMessage, "outroMessage": outroMessage,
"ensOnly": false, # TODO ensOnly is no longer supported. Remove this when we remove it in status-go "ensOnly": false, # TODO ensOnly is no longer supported. Remove this when we remove it in status-go
"color": color, "color": color,
"tags": parseJson(tags),
"image": imageUrl, "image": imageUrl,
"imageAx": aX, "imageAx": aX,
"imageAy": aY, "imageAy": aY,

@ -1 +1 @@
Subproject commit 1730fe756d71b9357dbb82a896116d575f2ff08b Subproject commit 604bb7a74c83f365b1697005045eb7da2ddef3cb

View File

@ -0,0 +1,70 @@
import QtQuick 2.14
import QtQuick.Layouts 1.14
import utils 1.0
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Components 0.1
import StatusQ.Popups 0.1
import StatusQ.Controls 0.1
import "../../popups/community"
ColumnLayout {
id: root
property string tags
property string selectedTags
onSelectedTagsChanged: {
var obj = JSON.parse(tags);
var array = JSON.parse(selectedTags);
d.tagsModel.clear();
for (const key of Object.keys(obj)) {
if (array.indexOf(key) != -1) {
d.tagsModel.append({ name: key, emoji: obj[key], selected: false });
}
}
}
spacing: 8
QtObject {
id: d
property ListModel tagsModel: ListModel {}
}
StatusBaseText {
text: qsTr("Tags")
font.pixelSize: 15
color: Theme.palette.directColor1
}
StatusPickerButton {
bgColor: root.selectedTags == "" ? Theme.palette.baseColor2 : "transparent"
text: root.selectedTags == "" ? "Choose tags describing the community" : ""
Layout.fillWidth: true
StatusCommunityTags {
anchors.centerIn: parent
model: d.tagsModel
active: false
width: parent.width
}
onClicked: {
tagsDialog.tags = root.tags;
tagsDialog.selectedTags = root.selectedTags;
tagsDialog.open();
}
CommunityTagsPopup {
id: tagsDialog
anchors.centerIn: parent
onAccepted: root.selectedTags = selectedTags
}
}
}

View File

@ -26,6 +26,8 @@ Flickable {
property alias introMessage: introMessageTextInput.text property alias introMessage: introMessageTextInput.text
property alias outroMessage: outroMessageTextInput.text property alias outroMessage: outroMessageTextInput.text
property alias color: colorPicker.color property alias color: colorPicker.color
property alias tags: tagsPicker.tags
property alias selectedTags: tagsPicker.selectedTags
property alias options: options property alias options: options
property alias logoImageData: logoPicker.imageData property alias logoImageData: logoPicker.imageData
@ -76,6 +78,11 @@ Flickable {
Layout.fillWidth: true Layout.fillWidth: true
} }
CommunityTagsPicker {
id: tagsPicker
Layout.fillWidth: true
}
StatusModalDivider { StatusModalDivider {
Layout.fillWidth: true Layout.fillWidth: true
Layout.bottomMargin: -layout.spacing Layout.bottomMargin: -layout.spacing

View File

@ -23,6 +23,8 @@ StackLayout {
property string bannerImageData property string bannerImageData
property rect bannerCropRect property rect bannerCropRect
property color color property color color
property string tags
property string selectedTags
property bool archiveSupportEnabled property bool archiveSupportEnabled
property bool requestToJoinEnabled property bool requestToJoinEnabled
property bool pinMessagesEnabled property bool pinMessagesEnabled
@ -170,6 +172,8 @@ StackLayout {
description: root.description description: root.description
introMessage: root.introMessage introMessage: root.introMessage
outroMessage: root.outroMessage outroMessage: root.outroMessage
tags: root.tags
selectedTags: root.selectedTags
color: root.color color: root.color
logoImageData: root.logoImageData logoImageData: root.logoImageData
bannerImageData: root.bannerImageData bannerImageData: root.bannerImageData
@ -191,6 +195,7 @@ StackLayout {
root.requestToJoinEnabled != options.requestToJoinEnabled || root.requestToJoinEnabled != options.requestToJoinEnabled ||
root.pinMessagesEnabled != options.pinMessagesEnabled || root.pinMessagesEnabled != options.pinMessagesEnabled ||
root.color != color || root.color != color ||
root.selectedTags != selectedTags ||
logoImagePath.length > 0 || logoImagePath.length > 0 ||
isValidRect(logoCropRect) || isValidRect(logoCropRect) ||
bannerPath.length > 0 || bannerPath.length > 0 ||

View File

@ -0,0 +1,159 @@
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Components 0.1
import StatusQ.Controls 0.1
import StatusQ.Popups 0.1
import utils 1.0
StatusModal {
id: root
property string tags
property string selectedTags
property int maxSelectedTags: 4
signal accepted(string selectedTags)
function updateSelectedTags() {
var array = selectedTags.length ? JSON.parse(selectedTags) : [];
d.cntSelectedTags = 0;
for (let i = 0; i < d.tagsModel.count; ++i) {
let item = d.tagsModel.get(i);
if (array.indexOf(item.name) != -1) {
item.selected = true;
d.cntSelectedTags++;
} else {
item.selected = false;
}
d.tagsModel.set(i, item);
}
}
onTagsChanged: {
var obj = JSON.parse(tags);
d.cntSelectedTags = 0;
d.tagsModel.clear();
for (const key of Object.keys(obj)) {
d.tagsModel.append({ name: key, emoji: obj[key], selected: false });
}
}
onSelectedTagsChanged: updateSelectedTags()
width: 680
implicitHeight: 820
header.title: qsTr("Community Tags")
QtObject {
id: d
property int cntSelectedTags: 0
property ListModel tagsModel: ListModel {}
}
rightButtons: [
StatusButton {
text: qsTr("Confirm Community Tags")
onClicked: {
var selectedTags = [];
for (let i = 0; i < d.tagsModel.count; ++i) {
let item = d.tagsModel.get(i);
if (item.selected)
selectedTags.push(item.name);
}
root.accepted(selectedTags.length ? JSON.stringify(selectedTags) : "");
root.close();
}
}
]
leftButtons: [
StatusRoundButton {
id: btnBack
icon.name: "arrow-left"
icon.width: 20
icon.height: 16
onClicked: {
root.updateSelectedTags();
root.close();
}
}
]
contentItem: ScrollView {
id: scroll
width: parent.width
topPadding: 30
leftPadding: 20
rightPadding: 20
bottomPadding: 20
contentHeight: column.height
ScrollBar.vertical.policy: ScrollBar.AsNeeded
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
clip: true
ColumnLayout {
id: column
width: scroll.width - scroll.leftPadding - scroll.rightPadding
spacing: 20
StatusInput {
id: tagsFilter
leftPadding: 0
rightPadding: 0
label: qsTr("Select tags that will fit your Community")
input.icon.name: "search"
input.placeholderText: qsTr("Search tags")
Layout.fillWidth: true
}
StatusCommunityTags {
filterString: tagsFilter.text
model: d.tagsModel
enabled: d.cntSelectedTags < maxSelectedTags
onClicked: {
d.cntSelectedTags++;
item.selected = true;
}
Layout.fillWidth: true
}
StatusModalDivider {
Layout.fillWidth: true
}
RowLayout {
StatusBaseText {
text: qsTr("Selected tags")
font.pixelSize: 15
Layout.fillWidth: true
}
StatusBaseText {
text: d.cntSelectedTags + "/" + maxSelectedTags
color: Theme.palette.baseColor1
font.pixelSize: 13
}
}
StatusCommunityTags {
model: d.tagsModel
showOnlySelected: true
onClicked: {
d.cntSelectedTags--;
item.selected = false;
}
Layout.fillWidth: true
}
}
}
}

View File

@ -100,6 +100,12 @@ StatusModal {
Layout.fillWidth: true Layout.fillWidth: true
} }
CommunityTagsPicker {
id: communityTagsPicker
tags: root.store.communityTags
Layout.fillWidth: true
}
StatusModalDivider { StatusModalDivider {
Layout.fillWidth: true Layout.fillWidth: true
} }
@ -149,6 +155,7 @@ StatusModal {
introMessage: Utils.filterXSS(introMessageInput.input.text), introMessage: Utils.filterXSS(introMessageInput.input.text),
outroMessage: Utils.filterXSS(outroMessageInput.input.text), outroMessage: Utils.filterXSS(outroMessageInput.input.text),
color: colorPicker.color.toString().toUpperCase(), color: colorPicker.color.toString().toUpperCase(),
tags: communityTagsPicker.selectedTags,
image: { image: {
src: logoPicker.source, src: logoPicker.source,
AX: logoPicker.cropRect.x, AX: logoPicker.cropRect.x,

View File

@ -138,6 +138,8 @@ QtObject {
property bool isCommunityHistoryArchiveSupportEnabled: advancedModule? advancedModule.isCommunityHistoryArchiveSupportEnabled : false property bool isCommunityHistoryArchiveSupportEnabled: advancedModule? advancedModule.isCommunityHistoryArchiveSupportEnabled : false
property string communityTags: communitiesModule.tags
function reCalculateAddToGroupContacts(channel) { function reCalculateAddToGroupContacts(channel) {
const contacts = getContactListObject() const contacts = getContactListObject()
@ -234,6 +236,7 @@ QtObject {
introMessage: "", introMessage: "",
outroMessage: "", outroMessage: "",
color: "", color: "",
tags: "",
image: { image: {
src: "", src: "",
AX: 0, AX: 0,
@ -248,7 +251,8 @@ QtObject {
} }
}) { }) {
return communitiesModuleInst.createCommunity( return communitiesModuleInst.createCommunity(
args.name, args.description, args.introMessage, args.outroMessage, args.options.checkedMembership, args.color, args.name, args.description, args.introMessage, args.outroMessage,
args.options.checkedMembership, args.color, args.tags,
args.image.src, args.image.AX, args.image.AY, args.image.BX, args.image.BY, args.image.src, args.image.AX, args.image.AY, args.image.BX, args.image.BY,
args.options.historyArchiveSupportEnabled, args.options.pinMessagesAllowedForMembers); args.options.historyArchiveSupportEnabled, args.options.pinMessagesAllowedForMembers);
} }

View File

@ -125,6 +125,8 @@ StatusAppTwoPanelLayout {
logoImageData: root.community.image logoImageData: root.community.image
bannerImageData: root.community.bannerImageData bannerImageData: root.community.bannerImageData
color: root.community.color color: root.community.color
tags: root.rootStore.communityTags
selectedTags: root.community.tags
archiveSupportEnabled: root.community.historyArchiveSupportEnabled archiveSupportEnabled: root.community.historyArchiveSupportEnabled
requestToJoinEnabled: root.community.access === Constants.communityChatOnRequestAccess requestToJoinEnabled: root.community.access === Constants.communityChatOnRequestAccess
pinMessagesEnabled: root.community.pinMessageAllMembersEnabled pinMessagesEnabled: root.community.pinMessageAllMembersEnabled
@ -140,6 +142,7 @@ StatusAppTwoPanelLayout {
Utils.filterXSS(item.outroMessage), Utils.filterXSS(item.outroMessage),
item.options.requestToJoinEnabled ? Constants.communityChatOnRequestAccess : Constants.communityChatPublicAccess, item.options.requestToJoinEnabled ? Constants.communityChatOnRequestAccess : Constants.communityChatPublicAccess,
item.color.toString().toUpperCase(), item.color.toString().toUpperCase(),
item.selectedTags,
JSON.stringify({imagePath: String(item.logoImagePath).replace("file://", ""), cropRect: item.logoCropRect}), JSON.stringify({imagePath: String(item.logoImagePath).replace("file://", ""), cropRect: item.logoCropRect}),
JSON.stringify({imagePath: String(item.bannerPath).replace("file://", ""), cropRect: item.bannerCropRect}), JSON.stringify({imagePath: String(item.bannerPath).replace("file://", ""), cropRect: item.bannerCropRect}),
item.options.archiveSupportEnabled, item.options.archiveSupportEnabled,

View File

@ -62,8 +62,11 @@ QtObject {
return profileSectionModule.ensUsernamesModule.getEtherscanLink() return profileSectionModule.ensUsernamesModule.getEtherscanLink()
} }
function createCommunity(communityName, communityDescription, checkedMembership, communityColor, communityImage, imageCropperModalaX, imageCropperModalaY, imageCropperModalbX, imageCropperModalbY) { function createCommunity(communityName, communityDescription, checkedMembership, communityColor, communityTags,
communitiesModuleInst.createCommunity(communityName, communityDescription, checkedMembership, communityColor, communityImage, imageCropperModalaX, imageCropperModalaY, imageCropperModalbX, imageCropperModalbY); communityImage, imageCropperModalaX, imageCropperModalaY, imageCropperModalbX, imageCropperModalbY) {
communitiesModuleInst.createCommunity(communityName, communityDescription, checkedMembership, communityColor,
communityTags, communityImage, imageCropperModalaX, imageCropperModalaY,
imageCropperModalbX, imageCropperModalbY);
} }
function copyToClipboard(text) { function copyToClipboard(text) {

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 80631526574c1607b98d1330ac659019ebb003c1 Subproject commit 2873e65a611ed00782d3b833f5a6c2340f98939d