refactor(community): hook invite user and fix community context menu
This commit is contained in:
parent
11fbab0c65
commit
9fc9f698d9
|
@ -124,7 +124,7 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
|
|||
result.networkService = network_service.newService()
|
||||
result.contactsService = contacts_service.newService(statusFoundation.status.events, statusFoundation.threadpool)
|
||||
result.chatService = chat_service.newService(statusFoundation.status.events, result.contactsService)
|
||||
result.communityService = community_service.newService(statusFoundation.status.events)
|
||||
result.communityService = community_service.newService(statusFoundation.status.events, result.chatService)
|
||||
result.messageService = message_service.newService(statusFoundation.status.events, statusFoundation.threadpool)
|
||||
result.activityCenterService = activity_center_service.newService(statusFoundation.status.events,
|
||||
statusFoundation.threadpool, result.chatService)
|
||||
|
|
|
@ -31,6 +31,10 @@ method init*(self: Controller) =
|
|||
let communities = self.communityService.getAllCommunities()
|
||||
self.delegate.setAllCommunities(communities)
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITY_CREATED) do(e:Args):
|
||||
let args = CommunityArgs(e)
|
||||
self.delegate.addCommunity(args.community)
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITY_MY_REQUEST_ADDED) do(e:Args):
|
||||
let args = CommunityRequestArgs(e)
|
||||
# self.delegate.requestAdded()
|
||||
|
@ -183,8 +187,8 @@ method acceptRequestToJoinCommunity*(self: Controller, communityId: string, requ
|
|||
method declineRequestToJoinCommunity*(self: Controller, communityId: string, requestId: string) =
|
||||
self.communityService.declineRequestToJoinCommunity(requestId)
|
||||
|
||||
# method inviteUsersToCommunityById*(self: Controller, communityId: string, pubKeys: string) =
|
||||
# self.communityService.inviteUsersToCommunityById(communityId, pubKeys)
|
||||
method inviteUsersToCommunityById*(self: Controller, communityId: string, pubKeys: string): string =
|
||||
result = self.communityService.inviteUsersToCommunityById(communityId, pubKeys)
|
||||
|
||||
method removeUserFromCommunity*(self: Controller, communityId: string, pubKeys: string) =
|
||||
self.communityService.removeUserFromCommunity(communityId, pubKeys)
|
||||
|
|
|
@ -61,7 +61,7 @@ method acceptRequestToJoinCommunity*(self: AccessInterface, communityId: string,
|
|||
method declineRequestToJoinCommunity*(self: AccessInterface, communityId: string, requestId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method inviteUsersToCommunityById*(self: AccessInterface, communityId: string, pubKeys: string) {.base.} =
|
||||
method inviteUsersToCommunityById*(self: AccessInterface, communityId: string, pubKeys: string): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method removeUserFromCommunity*(self: AccessInterface, communityId: string, pubKeys: string) {.base.} =
|
||||
|
|
|
@ -50,12 +50,10 @@ method isLoaded*(self: Module): bool =
|
|||
|
||||
method viewDidLoad*(self: Module) =
|
||||
self.moduleLoaded = true
|
||||
# FIXME this works one time, then restarting the app doesn<t work
|
||||
# self.delegate.communitiesModuleDidLoad()
|
||||
self.delegate.communitiesModuleDidLoad()
|
||||
|
||||
method setAllCommunities*(self: Module, communities: seq[CommunityDto]) =
|
||||
for c in communities:
|
||||
let communityItem = initItem(
|
||||
method getCommunityItem(self: Module, c: CommunityDto): SectionItem =
|
||||
return initItem(
|
||||
c.id,
|
||||
SectionType.Community,
|
||||
c.name,
|
||||
|
@ -76,7 +74,13 @@ method setAllCommunities*(self: Module, communities: seq[CommunityDto]) =
|
|||
c.permissions.access,
|
||||
c.permissions.ensOnly,
|
||||
c.members.map(x => member_item.initItem(x.id, x.roles)))
|
||||
self.view.addItem(communityItem)
|
||||
|
||||
method setAllCommunities*(self: Module, communities: seq[CommunityDto]) =
|
||||
for community in communities:
|
||||
self.view.addItem(self.getCommunityItem(community))
|
||||
|
||||
method addCommunity*(self: Module, community: CommunityDto) =
|
||||
self.view.addItem(self.getCommunityItem(community))
|
||||
|
||||
method joinCommunity*(self: Module, communityId: string): string =
|
||||
self.controller.joinCommunity(communityId)
|
||||
|
@ -154,8 +158,8 @@ method removeUserFromCommunity*(self: Module, communityId: string, categoryId: s
|
|||
method leaveCommunity*(self: Module, communityId: string) =
|
||||
self.controller.leaveCommunity(communityId)
|
||||
|
||||
method inviteUsersToCommunityById*(self: Module, communityId: string, pubKeysJSON: string) =
|
||||
self.controller.inviteUsersToCommunityById(communityId, pubKeysJSON)
|
||||
method inviteUsersToCommunityById*(self: Module, communityId: string, pubKeysJSON: string): string =
|
||||
result = self.controller.inviteUsersToCommunityById(communityId, pubKeysJSON)
|
||||
|
||||
method removeUserFromCommunity*(self: Module, communityId: string, pubKey: string) =
|
||||
self.controller.removeUserFromCommunity(communityId, pubKey)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import ../../../../../app_service/service/community/service as community_service
|
||||
import ../../../shared_models/section_item
|
||||
|
||||
method delete*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
@ -12,6 +13,12 @@ method isLoaded*(self: AccessInterface): bool {.base.} =
|
|||
method setAllCommunities*(self: AccessInterface, communities: seq[CommunityDto]) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getCommunityItem*(self: AccessInterface, community: CommunityDto): SectionItem {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method addCommunity*(self: AccessInterface, community: CommunityDto) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method joinCommunity*(self: AccessInterface, communityId: string): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
@ -42,7 +49,7 @@ method reorderCommunityChannel*(self: AccessInterface, communityId: string, cate
|
|||
method leaveCommunity*(self: AccessInterface, communityId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method inviteUsersToCommunityById*(self: AccessInterface, communityId: string, pubKeysJSON: string) {.base.} =
|
||||
method inviteUsersToCommunityById*(self: AccessInterface, communityId: string, pubKeysJSON: string): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method removeUserFromCommunity*(self: AccessInterface, communityId: string, pubKey: string) {.base.} =
|
||||
|
|
|
@ -12,13 +12,11 @@ QtObject:
|
|||
model: SectionModel
|
||||
modelVariant: QVariant
|
||||
observedItem: ActiveSection
|
||||
observedItemVariant: QVariant
|
||||
|
||||
proc delete*(self: View) =
|
||||
self.model.delete
|
||||
self.modelVariant.delete
|
||||
self.observedItem.delete
|
||||
self.observedItemVariant.delete
|
||||
self.QObject.delete
|
||||
|
||||
proc newView*(delegate: io_interface.AccessInterface): View =
|
||||
|
@ -28,7 +26,6 @@ QtObject:
|
|||
result.model = newModel()
|
||||
result.modelVariant = newQVariant(result.model)
|
||||
result.observedItem = newActiveSection()
|
||||
result.observedItemVariant = newQVariant(result.observedItem)
|
||||
|
||||
proc load*(self: View) =
|
||||
self.delegate.viewDidLoad()
|
||||
|
@ -45,7 +42,7 @@ QtObject:
|
|||
proc observedItemChanged*(self:View) {.signal.}
|
||||
|
||||
proc getObservedItem(self: View): QVariant {.slot.} =
|
||||
return self.observedItemVariant
|
||||
return newQVariant(self.observedItem)
|
||||
|
||||
QtProperty[QVariant] observedCommunity:
|
||||
read = getObservedItem
|
||||
|
@ -56,6 +53,7 @@ QtObject:
|
|||
if (item.id == ""):
|
||||
return
|
||||
self.observedItem.setActiveSectionData(item)
|
||||
self.observedItemChanged()
|
||||
|
||||
proc joinCommunity*(self: View, communityId: string): string {.slot.} =
|
||||
result = self.delegate.joinCommunity(communityId)
|
||||
|
@ -93,11 +91,8 @@ QtObject:
|
|||
proc leaveCommunity*(self: View, communityId: string) {.slot.} =
|
||||
self.delegate.leaveCommunity(communityId)
|
||||
|
||||
proc inviteUsersToCommunityById*(self: View, communityId: string, pubKeysJSON: string) {.slot.} =
|
||||
self.delegate.inviteUsersToCommunityById(communityId, pubKeysJSON)
|
||||
|
||||
proc inviteUsersToCommunity*(self: View, communityId: string, pubKeysJSON: string) {.slot.} =
|
||||
self.inviteUsersToCommunityById(communityId, pubKeysJSON)
|
||||
proc inviteUsersToCommunityById*(self: View, communityId: string, pubKeysJSON: string): string {.slot.} =
|
||||
result = self.delegate.inviteUsersToCommunityById(communityId, pubKeysJSON)
|
||||
|
||||
proc removeUserFromCommunity*(self: View, communityId: string, pubKey: string) {.slot.} =
|
||||
self.delegate.removeUserFromCommunity(communityId, pubKey)
|
||||
|
|
|
@ -126,4 +126,5 @@ QtObject:
|
|||
QtProperty[int] nbMembers:
|
||||
read = nbMembers
|
||||
|
||||
|
||||
proc hasMember(self: ActiveSection, pubkey: string): bool {.slot.} =
|
||||
return self.item.hasMember(pubkey)
|
|
@ -175,3 +175,9 @@ proc ensOnly*(self: SectionItem): bool {.inline.} =
|
|||
|
||||
proc members*(self: SectionItem): seq[MemberItem] {.inline.} =
|
||||
self.members
|
||||
|
||||
proc hasMember*(self: SectionItem, pubkey: string): bool =
|
||||
for member in self.members:
|
||||
if (member.id == pubkey):
|
||||
return true
|
||||
return false
|
||||
|
|
|
@ -141,7 +141,7 @@ proc toCommunityDto*(jsonObj: JsonNode): CommunityDto =
|
|||
result.permissions = toPermission(permissionObj)
|
||||
|
||||
var membersObj: JsonNode
|
||||
if(jsonObj.getProp("members", membersObj)):
|
||||
if(jsonObj.getProp("members", membersObj) and membersObj.kind == JArray):
|
||||
for memberId, memberObj in membersObj:
|
||||
result.members.add(toMember(memberObj, memberId))
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import eventemitter
|
|||
import ./dto/community as community_dto
|
||||
export community_dto
|
||||
import ../../../app/global/global_singleton
|
||||
import ../chat/service as chat_service
|
||||
|
||||
import status/statusgo_backend_new/communities as status_go
|
||||
|
||||
|
@ -57,6 +58,7 @@ QtObject:
|
|||
type
|
||||
Service* = ref object of QObject
|
||||
events: EventEmitter
|
||||
chatService: chat_service.Service
|
||||
joinedCommunities: Table[string, CommunityDto] # [community_id, CommunityDto]
|
||||
allCommunities: Table[string, CommunityDto] # [community_id, CommunityDto]
|
||||
myCommunityRequests*: seq[CommunityMembershipRequestDto]
|
||||
|
@ -69,9 +71,10 @@ QtObject:
|
|||
proc delete*(self: Service) =
|
||||
discard
|
||||
|
||||
proc newService*(events: EventEmitter): Service =
|
||||
proc newService*(events: EventEmitter, chatService: chat_service.Service): Service =
|
||||
result = Service()
|
||||
result.events = events
|
||||
result.chatService = chatService
|
||||
result.joinedCommunities = initTable[string, CommunityDto]()
|
||||
result.allCommunities = initTable[string, CommunityDto]()
|
||||
result.myCommunityRequests = @[]
|
||||
|
@ -486,11 +489,17 @@ QtObject:
|
|||
except Exception as e:
|
||||
error "Error exporting community", msg = e.msg
|
||||
|
||||
# proc inviteUsersToCommunityById*(self: Service, communityId: string, pubKeys: string) =
|
||||
# try:
|
||||
# discard status_go.inviteUsersToCommunityById(communityId, pubKeys)
|
||||
# except Exception as e:
|
||||
# error "Error exporting community", msg = e.msg
|
||||
proc inviteUsersToCommunityById*(self: Service, communityId: string, pubKeysJson: string): string =
|
||||
try:
|
||||
let pubKeysParsed = pubKeysJson.parseJson
|
||||
var pubKeys: seq[string] = @[]
|
||||
for pubKey in pubKeysParsed:
|
||||
pubKeys.add(pubKey.getStr)
|
||||
let response = status_go.inviteUsersToCommunity(communityId, pubKeys)
|
||||
discard self.chatService.processMessageUpdateAfterSend(response)
|
||||
except Exception as e:
|
||||
error "Error exporting community", msg = e.msg
|
||||
result = "Error exporting community: " & e.msg
|
||||
|
||||
proc removeUserFromCommunity*(self: Service, communityId: string, pubKeys: string) =
|
||||
try:
|
||||
|
|
|
@ -26,6 +26,7 @@ StatusAppThreePanelLayout {
|
|||
handle: SplitViewHandle { implicitWidth: 5 }
|
||||
|
||||
property var contactsStore
|
||||
property bool hasAddedContacts: root.contactsStore.myContactsModel.count > 0
|
||||
|
||||
// Not Refactored
|
||||
property var messageStore
|
||||
|
@ -128,6 +129,7 @@ StatusAppThreePanelLayout {
|
|||
CommunityColumnView {
|
||||
communitySectionModule: root.rootStore.chatCommunitySectionModule
|
||||
store: root.rootStore
|
||||
hasAddedContacts: root.hasAddedContacts
|
||||
pinnedMessagesPopupComponent: root.pinnedMessagesListPopupComponent
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,19 +17,20 @@ Column {
|
|||
|
||||
property string headerTitle: ""
|
||||
|
||||
property var rootStore
|
||||
property var contactsStore
|
||||
property var community
|
||||
property alias contactListSearch: contactFieldAndList
|
||||
|
||||
function sendInvites(pubKeys) {
|
||||
// Not Refactored Yet
|
||||
// const error = chatsModel.communities.inviteUsersToCommunityById(root.community.id, JSON.stringify(pubKeys))
|
||||
// if (error) {
|
||||
// console.error('Error inviting', error)
|
||||
// contactFieldAndList.validationError = error
|
||||
// return
|
||||
// }
|
||||
// //% "Invite successfully sent"
|
||||
// contactFieldAndList.successMessage = qsTrId("invite-successfully-sent")
|
||||
const error = root.rootStore.inviteUsersToCommunityById(root.community.id, JSON.stringify(pubKeys))
|
||||
if (error) {
|
||||
console.error('Error inviting', error)
|
||||
contactFieldAndList.validationError = error
|
||||
return
|
||||
}
|
||||
//% "Invite successfully sent"
|
||||
contactFieldAndList.successMessage = qsTrId("invite-successfully-sent")
|
||||
}
|
||||
|
||||
StatusDescriptionListItem {
|
||||
|
@ -40,10 +41,9 @@ Column {
|
|||
tooltip.text: qsTrId("copy-to-clipboard")
|
||||
icon.name: "copy"
|
||||
iconButton.onClicked: {
|
||||
// Not Refactored Yet
|
||||
// let link = `${Constants.communityLinkPrefix}${root.community.id}`
|
||||
// chatsModel.copyToClipboard(link)
|
||||
// tooltip.visible = !tooltip.visible
|
||||
let link = `${Constants.communityLinkPrefix}${root.community.id}`
|
||||
root.rootStore.copyToClipboard(link)
|
||||
tooltip.visible = !tooltip.visible
|
||||
}
|
||||
width: parent.width
|
||||
}
|
||||
|
@ -65,6 +65,8 @@ Column {
|
|||
id: contactFieldAndList
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: parent.width - 32
|
||||
contactsStore: root.contactsStore
|
||||
community: root.community
|
||||
showCheckbox: true
|
||||
hideCommunityMembers: true
|
||||
showSearch: false
|
||||
|
|
|
@ -114,7 +114,7 @@ Column {
|
|||
|
||||
StatusListItem {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
visible: root.community.isAdmin || root.community.admin
|
||||
visible: root.community.amISectionAdmin
|
||||
//% "Edit community"
|
||||
title: qsTrId("edit-community")
|
||||
icon.name: "edit"
|
||||
|
@ -124,7 +124,7 @@ Column {
|
|||
|
||||
StatusListItem {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
visible: root.community.isAdmin || root.community.admin
|
||||
visible: root.community.amISectionAdmin
|
||||
//% "Transfer ownership"
|
||||
title: qsTrId("transfer-ownership")
|
||||
icon.name: "exchange"
|
||||
|
|
|
@ -23,6 +23,7 @@ Rectangle {
|
|||
color: Style.current.transparent
|
||||
property var activeCommunity
|
||||
property var store
|
||||
property bool hasAddedContacts
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
|
@ -89,7 +90,8 @@ Rectangle {
|
|||
anchors.bottom: manageBtn.top
|
||||
anchors.bottomMargin: Style.current.halfPadding
|
||||
onClicked: Global.openPopup(inviteFriendsToCommunityPopup, {
|
||||
community: root.activeCommunity
|
||||
community: root.activeCommunity,
|
||||
hasAddedContacts: root.hasAddedContacts
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@ import "../../panels/communities"
|
|||
StatusModal {
|
||||
id: popup
|
||||
|
||||
property var rootStore
|
||||
property var contactsStore
|
||||
property var community
|
||||
property bool hasAddedContacts
|
||||
|
||||
|
@ -35,9 +37,12 @@ StatusModal {
|
|||
|
||||
contentItem: CommunityProfilePopupInviteFriendsPanel {
|
||||
id: contactFieldAndList
|
||||
rootStore: popup.rootStore
|
||||
contactsStore: popup.contactsStore
|
||||
community: popup.community
|
||||
contactListSearch.onUserClicked: {
|
||||
if (isContact) {
|
||||
// those are just added to the list to by added by the bunch
|
||||
if (isAddedContact) {
|
||||
// those are just added to the list to be added by the bunch
|
||||
return
|
||||
}
|
||||
contactFieldAndList.sendInvites([pubKey])
|
||||
|
|
|
@ -26,6 +26,7 @@ Item {
|
|||
property var communitySectionModule
|
||||
|
||||
property var store
|
||||
property bool hasAddedContacts: false
|
||||
property var communityData: store.mainModuleInst ? store.mainModuleInst.activeSection || {} : {}
|
||||
// TODO unhardcode
|
||||
// Not Refactored Yet
|
||||
|
@ -48,10 +49,10 @@ Item {
|
|||
chatInfoButton.icon.color: communityData.color
|
||||
menuButton.visible: communityData.amISectionAdmin && communityData.canManageUsers
|
||||
// TODO remove dynamic scoping of popup component
|
||||
chatInfoButton.onClicked: Global.openPopup(communityProfilePopup, {
|
||||
store: root.store,
|
||||
community: communityData
|
||||
})
|
||||
chatInfoButton.onClicked: Global.openPopup(communityProfilePopup, {
|
||||
store: root.store,
|
||||
community: communityData
|
||||
})
|
||||
|
||||
popupMenu: StatusPopupMenu {
|
||||
StatusMenuItem {
|
||||
|
@ -78,10 +79,10 @@ Item {
|
|||
text: qsTrId("invite-people")
|
||||
icon.name: "share-ios"
|
||||
enabled: communityData.canManageUsers
|
||||
// Not Refactored Yet
|
||||
// onTriggered: Global.openPopup(inviteFriendsToCommunityPopup, {
|
||||
// community: root.store.chatsModelInst.communities.activeCommunity
|
||||
// })
|
||||
onTriggered: Global.openPopup(inviteFriendsToCommunityPopup, {
|
||||
community: communityData,
|
||||
hasAddedContacts: root.hasAddedContacts
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -198,11 +199,11 @@ Item {
|
|||
//% "Invite people"
|
||||
text: qsTrId("invite-people")
|
||||
icon.name: "share-ios"
|
||||
// Not Refactored Yet
|
||||
enabled: communityData.amISectionAdmin
|
||||
// onTriggered: Global.openPopup(inviteFriendsToCommunityPopup, {
|
||||
// community: root.store.chatsModelInst.communities.activeCommunity
|
||||
// })
|
||||
enabled: communityData.canManageUsers
|
||||
onTriggered: Global.openPopup(inviteFriendsToCommunityPopup, {
|
||||
community: communityData,
|
||||
hasAddedContacts: root.hasAddedContacts
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -350,6 +351,7 @@ Item {
|
|||
CommunityWelcomeBannerPanel {
|
||||
activeCommunity: communityData
|
||||
store: root.store
|
||||
hasAddedContacts: root.hasAddedContacts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ QtObject {
|
|||
property var mainModuleInst: mainModule
|
||||
property var aboutModuleInst: aboutModule
|
||||
property var communitiesModuleInst: communitiesModule
|
||||
property var observedCommunity: communitiesModuleInst.observedCommunity
|
||||
|
||||
property ProfileSectionStore profileSectionStore: ProfileSectionStore {
|
||||
}
|
||||
|
@ -25,12 +26,19 @@ QtObject {
|
|||
// Not Refactored Yet
|
||||
// property var profileModelInst: profileModel
|
||||
|
||||
property var contactStore: profileSectionStore.contactsStore
|
||||
property bool hasAddedContacts: contactStore.myContactsModel.count > 0
|
||||
|
||||
property var assets: walletSectionAccountTokens.model
|
||||
// property MessageStore messageStore: MessageStore { }
|
||||
|
||||
property real volume: !!localAccountSensitiveSettings ? localAccountSensitiveSettings.volume : 0.0
|
||||
property bool notificationSoundsEnabled: !!localAccountSensitiveSettings ? localAccountSensitiveSettings.notificationSoundsEnabled : false
|
||||
|
||||
function setObservedCommunity(communityId) {
|
||||
communitiesModuleInst.setObservedCommunity(communityId);
|
||||
}
|
||||
|
||||
function setCommunityMuted(communityId, checked) {
|
||||
// Not Refactored Yet
|
||||
// chatsModelInst.communities.setCommunityMuted(communityId, checked);
|
||||
|
@ -53,8 +61,11 @@ QtObject {
|
|||
communitiesModuleInst.editCommunity(communityId, communityName, communityDescription, checkedMembership, ensOnlySwitchChecked, communityColor, communityImage, imageCropperModalaX, imageCropperModalaY, imageCropperModalbX, imageCropperModalbY);
|
||||
}
|
||||
|
||||
function inviteUsersToCommunityById(communityId, pubkeysJson) {
|
||||
communitiesModuleInst.inviteUsersToCommunityById(communityId, pubkeysJson);
|
||||
}
|
||||
|
||||
function copyToClipboard(text) {
|
||||
// Not Refactored Yet
|
||||
// chatsModelInst.copyToClipboard(text);
|
||||
globalUtils.copyToClipboard(text)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -241,40 +241,39 @@ Item {
|
|||
id: communityContextMenu
|
||||
|
||||
openHandler: function () {
|
||||
// Not Refactored Yet
|
||||
// chatsModel.communities.setObservedCommunity(model.id)
|
||||
appMain.rootStore.setObservedCommunity(model.id)
|
||||
}
|
||||
|
||||
StatusMenuItem {
|
||||
//% "Invite People"
|
||||
text: qsTrId("invite-people")
|
||||
icon.name: "share-ios"
|
||||
// Not Refactored Yet
|
||||
// enabled: chatsModel.communities.observedCommunity.canManageUsers
|
||||
// onTriggered: Global.openPopup(inviteFriendsToCommunityPopup, {
|
||||
// community: chatsModel.communities.observedCommunity
|
||||
// })
|
||||
enabled: appMain.rootStore.observedCommunity.canManageUsers
|
||||
onTriggered: Global.openPopup(inviteFriendsToCommunityPopup, {
|
||||
community: appMain.rootStore.observedCommunity,
|
||||
hasAddedContacts: appMain.rootStore.hasAddedContacts
|
||||
})
|
||||
}
|
||||
|
||||
StatusMenuItem {
|
||||
//% "View Community"
|
||||
text: qsTrId("view-community")
|
||||
icon.name: "group-chat"
|
||||
// Not Refactored Yet
|
||||
// onTriggered: Global.openPopup(communityProfilePopup, {
|
||||
// store: appMain.rootStore,
|
||||
// community: chatsModel.communities.observedCommunity
|
||||
// })
|
||||
onTriggered: Global.openPopup(communityProfilePopup, {
|
||||
store: appMain.rootStore,
|
||||
community: appMain.rootStore.observedCommunity
|
||||
})
|
||||
}
|
||||
|
||||
StatusMenuItem {
|
||||
// Not Refactored Yet
|
||||
// enabled: chatsModel.communities.observedCommunity.admin
|
||||
enabled: appMain.rootStore.observedCommunity.amISectionAdmin
|
||||
//% "Edit Community"
|
||||
text: qsTrId("edit-community")
|
||||
icon.name: "edit"
|
||||
// Not Refactored Yet
|
||||
// onTriggered: Global.openPopup(editCommunityPopup, {store: appMain.rootStore, community: chatsModel.communities.observedCommunity})
|
||||
onTriggered: Global.openPopup(editCommunityPopup, {
|
||||
store: appMain.rootStore,
|
||||
community: appMain.rootStore.observedCommunity
|
||||
})
|
||||
}
|
||||
|
||||
StatusMenuSeparator {}
|
||||
|
@ -425,7 +424,7 @@ Item {
|
|||
|
||||
pinnedMessagesListPopupComponent: pinnedMessagesPopupComponent
|
||||
|
||||
contactsStore: appMain.rootStore.profileSectionStore.contactsStore
|
||||
contactsStore: appMain.rootStore.contactStore
|
||||
rootStore.emojiReactionsModel: appMain.rootStore.emojiReactionsModel
|
||||
|
||||
onProfileButtonClicked: {
|
||||
|
@ -515,7 +514,7 @@ Item {
|
|||
|
||||
pinnedMessagesListPopupComponent: pinnedMessagesPopupComponent
|
||||
|
||||
contactsStore: appMain.rootStore.profileSectionStore.contactsStore
|
||||
contactsStore: appMain.rootStore.contactStore
|
||||
rootStore.emojiReactionsModel: appMain.rootStore.emojiReactionsModel
|
||||
|
||||
onProfileButtonClicked: {
|
||||
|
@ -617,8 +616,8 @@ Item {
|
|||
id: inviteFriendsToCommunityPopup
|
||||
InviteFriendsToCommunityPopup {
|
||||
anchors.centerIn: parent
|
||||
// Not Refactored Yet
|
||||
// hasAddedContacts: appMain.rootStore.allContacts.hasAddedContacts()
|
||||
rootStore: appMain.rootStore
|
||||
contactsStore: appMain.rootStore.contactStore
|
||||
onClosed: {
|
||||
destroy()
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ Item {
|
|||
height: childrenRect.height + 24
|
||||
|
||||
property var contactsStore
|
||||
property var community
|
||||
|
||||
property string validationError: ""
|
||||
property string successMessage: ""
|
||||
|
@ -31,7 +32,7 @@ Item {
|
|||
property bool showCheckbox: false
|
||||
property bool showContactList: true
|
||||
property bool showSearch: true
|
||||
signal userClicked(string pubKey)
|
||||
signal userClicked(string pubKey, bool isAddedContact)
|
||||
property var pubKeys: ([])
|
||||
property bool hideCommunityMembers: false
|
||||
property bool addContactEnabled: true
|
||||
|
@ -167,6 +168,7 @@ Item {
|
|||
id: existingContacts
|
||||
|
||||
contactsStore: root.contactsStore
|
||||
community: root.community
|
||||
|
||||
visible: showContactList
|
||||
hideCommunityMembers: root.hideCommunityMembers
|
||||
|
@ -195,7 +197,7 @@ Item {
|
|||
}
|
||||
root.pubKeys = pubKeysCopy
|
||||
|
||||
userClicked(contact.pubKey)
|
||||
userClicked(contact.pubKey, contact.isContact)
|
||||
}
|
||||
expanded: !searchResults.loading && pubKey === "" && !searchResults.showProfileNotFoundMessage
|
||||
}
|
||||
|
@ -213,7 +215,7 @@ Item {
|
|||
if (!validate()) {
|
||||
return
|
||||
}
|
||||
userClicked(pubKey)
|
||||
userClicked(pubKey, isAddedContact)
|
||||
}
|
||||
onAddToContactsButtonClicked: {
|
||||
root.contactsStore.addContact(pubKey)
|
||||
|
|
|
@ -14,6 +14,7 @@ Item {
|
|||
anchors.right: parent.right
|
||||
|
||||
property var contactsStore
|
||||
property var community
|
||||
|
||||
property string filterText: ""
|
||||
property bool expanded: true
|
||||
|
@ -50,11 +51,14 @@ Item {
|
|||
name: model.name
|
||||
identicon: model.icon
|
||||
isIdenticon: model.isIdenticon
|
||||
visible: model.isContact && !model.isBlocked && (root.filterText === "" ||
|
||||
isVisible: {
|
||||
return model.isContact && !model.isBlocked && (root.filterText === "" ||
|
||||
root.matchesAlias(model.name.toLowerCase(), root.filterText.toLowerCase()) ||
|
||||
model.name.toLowerCase().includes(root.filterText.toLowerCase()) ||
|
||||
model.pubKey.toLowerCase().includes(root.filterText.toLowerCase())) &&
|
||||
!root.hideCommunityMembers
|
||||
(!root.hideCommunityMembers ||
|
||||
!root.community.hasMember(model.pubKey))
|
||||
}
|
||||
onContactClicked: function () {
|
||||
root.contactClicked(model)
|
||||
}
|
||||
|
|
|
@ -29,9 +29,13 @@ Item {
|
|||
property bool resultClickable: true
|
||||
property bool addContactEnabled: true
|
||||
|
||||
property bool isAddedContact: root.pubKey != "" ? Utils.getContactDetailsAsJson(root.pubKey).isContact : false
|
||||
property bool isAddedContact: root.isContactAdded()
|
||||
|
||||
signal resultClicked(string pubKey)
|
||||
function isContactAdded() {
|
||||
return root.pubKey != "" ? Utils.getContactDetailsAsJson(root.pubKey).isContact : false
|
||||
}
|
||||
|
||||
signal resultClicked(string pubKey, bool isAddedContact)
|
||||
signal addToContactsButtonClicked(string pubKey)
|
||||
|
||||
function reset() {
|
||||
|
@ -113,7 +117,7 @@ Item {
|
|||
onExited: foundContact.hovered = false
|
||||
onClicked: {
|
||||
if (root.resultClickable) {
|
||||
root.resultClicked(root.pubKey)
|
||||
root.resultClicked(root.pubKey, root.isAddedContact)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue