refactor(community): hook leave community
This commit is contained in:
parent
96e50a97ac
commit
b7459b331b
|
@ -35,10 +35,6 @@ method init*(self: Controller) =
|
|||
let args = CommunityRequestArgs(e)
|
||||
# self.delegate.requestAdded()
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITY_LEFT) do(e:Args):
|
||||
let args = CommunityIdArgs(e)
|
||||
# self.delegate.communityLeft(args.communityId)
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITY_CHANNEL_EDITED) do(e:Args):
|
||||
let args = CommunityChatArgs(e)
|
||||
# self.delegate.communityChannelEdited()
|
||||
|
|
|
@ -103,6 +103,10 @@ method init*(self: Controller) =
|
|||
self.messageService
|
||||
)
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITY_LEFT) do(e:Args):
|
||||
let args = CommunityIdArgs(e)
|
||||
self.delegate.communityLeft(args.communityId)
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITY_EDITED) do(e:Args):
|
||||
let args = CommunityArgs(e)
|
||||
self.delegate.communityEdited(args.community)
|
||||
|
@ -139,6 +143,9 @@ method storePassword*(self: Controller, password: string) =
|
|||
|
||||
self.keychainService.storePassword(account.name, password)
|
||||
|
||||
method getActiveSectionId*(self: Controller): string =
|
||||
result = self.activeSectionId
|
||||
|
||||
method setActiveSection*(self: Controller, sectionId: string, sectionType: SectionType) =
|
||||
self.activeSectionId = sectionId
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@ method storePassword*(self: AccessInterface, password: string) {.base.} =
|
|||
method setActiveSection*(self: AccessInterface, sectionId: string, sectionType: SectionType) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getActiveSectionId*(self: AccessInterface): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getNumOfNotificaitonsForChat*(self: AccessInterface): tuple[unviewed:int, mentions:int] {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import NimQml, Tables, json, sugar, sequtils
|
||||
import NimQml, tables, json, sugar, sequtils
|
||||
|
||||
import io_interface, view, controller, ../shared_models/section_item, ../shared_models/section_model
|
||||
import ../shared_models/member_item
|
||||
|
@ -494,9 +494,22 @@ method communityJoined*[T](
|
|||
self.communitySectionsModule[community.id].load(events, settingsService, contactsService, chatService, communityService, messageService)
|
||||
|
||||
let communitySectionItem = self.createCommunityItem(community)
|
||||
self.view.addItem(self.createCommunityItem(community))
|
||||
self.view.addItem(communitySectionItem)
|
||||
self.setActiveSection(communitySectionItem)
|
||||
|
||||
method communityLeft*[T](self: Module[T], communityId: string) =
|
||||
if(not self.communitySectionsModule.contains(communityId)):
|
||||
echo "main-module, unexisting community key to leave: ", communityId
|
||||
return
|
||||
|
||||
self.communitySectionsModule.del(communityId)
|
||||
|
||||
self.view.model().removeItem(communityId)
|
||||
|
||||
if (self.controller.getActiveSectionId() == communityId):
|
||||
let item = self.view.model().getItemById(conf.CHAT_SECTION_ID)
|
||||
self.setActiveSection(item)
|
||||
|
||||
method communityEdited*[T](
|
||||
self: Module[T],
|
||||
community: CommunityDto) =
|
||||
|
|
|
@ -26,5 +26,8 @@ method communityJoined*(self: AccessInterface, community: CommunityDto, events:
|
|||
method communityEdited*(self: AccessInterface, community: CommunityDto) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method communityLeft*(self: AccessInterface, communityId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method resolvedENS*(self: AccessInterface, publicKey: string, address: string, uuid: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
|
@ -129,6 +129,20 @@ QtObject:
|
|||
i.inc()
|
||||
return -1
|
||||
|
||||
proc removeItem*(self: SectionModel, itemId: string) =
|
||||
let index = self.getItemIndex(itemId)
|
||||
if (index == -1):
|
||||
return
|
||||
|
||||
let parentModelIndex = newQModelIndex()
|
||||
defer: parentModelIndex.delete
|
||||
|
||||
self.beginRemoveRows(parentModelIndex, index, index)
|
||||
self.items.delete(index)
|
||||
self.endRemoveRows()
|
||||
|
||||
self.countChanged()
|
||||
|
||||
proc editItem*(self: SectionModel, item: SectionItem) =
|
||||
let index = self.getItemIndex(item.id)
|
||||
if (index == -1):
|
||||
|
|
|
@ -63,7 +63,7 @@ StatusModal {
|
|||
onNotificationsButtonClicked: {
|
||||
root.store.setCommunityMuted(root.community.id, checked);
|
||||
}
|
||||
onEditButtonClicked: Global.openPopup(editCommunityPopup, {
|
||||
onEditButtonClicked: Global.openPopup(editCommunityroot, {
|
||||
store: root.store,
|
||||
community: root.community,
|
||||
onSave: root.close
|
||||
|
|
|
@ -157,8 +157,7 @@ QtObject {
|
|||
}
|
||||
|
||||
function leaveCommunity(communityId) {
|
||||
// Not Refactored Yet
|
||||
// chatsModelInst.communities.leaveCommunity(communityId);
|
||||
communitiesModuleInst.leaveCommunity(communityId);
|
||||
}
|
||||
|
||||
function setCommunityMuted(communityId, checked) {
|
||||
|
|
|
@ -42,8 +42,7 @@ QtObject {
|
|||
}
|
||||
|
||||
function leaveCommunity(communityId) {
|
||||
// Not Refactored Yet
|
||||
// chatsModelInst.communities.leaveCommunity(communityId);
|
||||
communitiesModuleInst.leaveCommunity(communityId);
|
||||
}
|
||||
|
||||
function createCommunity(communityName, communityDescription, checkedMembership, ensOnlySwitchChecked, communityColor, communityImage, imageCropperModalaX, imageCropperModalaY, imageCropperModalbX, imageCropperModalbY) {
|
||||
|
@ -51,8 +50,7 @@ QtObject {
|
|||
}
|
||||
|
||||
function editCommunity(communityId, communityName, communityDescription, checkedMembership, ensOnlySwitchChecked, communityColor, communityImage, imageCropperModalaX, imageCropperModalaY, imageCropperModalbX, imageCropperModalbY) {
|
||||
// Not Refactored Yet
|
||||
// chatsModelInst.communities.editCommunity(communityId, communityName, communityDescription, checkedMembership, ensOnlySwitchChecked, communityColor, communityImage, imageCropperModalaX, imageCropperModalaY, imageCropperModalbX, imageCropperModalbY);
|
||||
communitiesModuleInst.editCommunity(communityId, communityName, communityDescription, checkedMembership, ensOnlySwitchChecked, communityColor, communityImage, imageCropperModalaX, imageCropperModalaY, imageCropperModalbX, imageCropperModalbY);
|
||||
}
|
||||
|
||||
function copyToClipboard(text) {
|
||||
|
|
|
@ -286,8 +286,7 @@ Item {
|
|||
icon.width: 14
|
||||
iconRotation: 180
|
||||
type: StatusMenuItem.Type.Danger
|
||||
// Not Refactored Yet
|
||||
// onTriggered: chatsModel.communities.leaveCommunity(model.id)
|
||||
onTriggered: appMain.rootStore.leaveCommunity(model.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue