mirror of
https://github.com/status-im/status-desktop.git
synced 2025-03-04 00:11:12 +00:00
refactor(communities): delete categories
This commit is contained in:
parent
7ff994a46a
commit
c338bdf6ae
@ -125,6 +125,11 @@ method init*(self: Controller) =
|
||||
if (args.communityId == self.sectionId):
|
||||
self.delegate.onCommunityCategoryCreated(args.category, args.chats)
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITY_CATEGORY_DELETED) do(e:Args):
|
||||
let args = CommunityCategoryArgs(e)
|
||||
if (args.communityId == self.sectionId):
|
||||
self.delegate.onCommunityCategoryDeleted(args.category)
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITY_CHANNEL_REORDERED) do(e:Args):
|
||||
let args = CommunityChatOrderArgs(e)
|
||||
if (args.communityId == self.sectionId):
|
||||
@ -306,6 +311,9 @@ method editCommunityChannel*(
|
||||
method createCommunityCategory*(self: Controller, name: string, channels: seq[string]) =
|
||||
self.communityService.createCommunityCategory(self.sectionId, name, channels)
|
||||
|
||||
method deleteCommunityCategory*(self: Controller, categoryId: string) =
|
||||
self.communityService.deleteCommunityCategory(self.sectionId, categoryId)
|
||||
|
||||
method leaveCommunity*(self: Controller) =
|
||||
self.communityService.leaveCommunity(self.sectionId)
|
||||
|
||||
|
@ -116,7 +116,6 @@ method joinGroup*(self: AccessInterface) {.base.} =
|
||||
method joinGroupChatFromInvitation*(self: AccessInterface, groupName: string, chatId: string, adminPK: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
||||
method acceptRequestToJoinCommunity*(self: AccessInterface, requestId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
@ -132,6 +131,9 @@ method editCommunityChannel*(self: AccessInterface, channelId: string, name: str
|
||||
method createCommunityCategory*(self: AccessInterface, name: string, channels: seq[string]) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method deleteCommunityCategory*(self: AccessInterface, categoryId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method leaveCommunity*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
@ -441,6 +441,20 @@ method onCommunityCategoryCreated*(self: Module, cat: Category, chats: seq[ChatD
|
||||
categoryItem.prependSubItems(categoryChannels)
|
||||
self.view.chatsModel().appendItem(categoryItem)
|
||||
|
||||
method onCommunityCategoryDeleted*(self: Module, cat: Category) =
|
||||
let chats = self.controller.getChats(self.controller.getMySectionId(), cat.id)
|
||||
for c in chats:
|
||||
let chatDto = self.controller.getChatDetails(self.controller.getMySectionId(), c.id)
|
||||
let hasNotification = chatDto.unviewedMessagesCount > 0 or chatDto.unviewedMentionsCount > 0
|
||||
let notificationsCount = chatDto.unviewedMentionsCount
|
||||
let amIChatAdmin = self.controller.getMyCommunity().admin
|
||||
let channelItem = initItem(chatDto.id, chatDto.name, chatDto.identicon, false, chatDto.color,
|
||||
chatDto.description, chatDto.chatType.int, amIChatAdmin, hasNotification, notificationsCount,
|
||||
chatDto.muted, active = false, chatDto.position, "")
|
||||
self.view.chatsModel().appendItem(channelItem)
|
||||
|
||||
self.view.chatsModel().removeItemById(cat.id)
|
||||
|
||||
method onCommunityChannelDeletedOrChatLeft*(self: Module, chatId: string) =
|
||||
if(not self.chatContentModules.contains(chatId)):
|
||||
return
|
||||
@ -599,6 +613,9 @@ method editCommunityChannel*(self: Module, channelId, name, description, categor
|
||||
method createCommunityCategory*(self: Module, name: string, channels: seq[string]) =
|
||||
self.controller.createCommunityCategory(name, channels)
|
||||
|
||||
method deleteCommunityCategory*(self: Module, categoryId: string) =
|
||||
self.controller.deleteCommunityCategory(categoryId)
|
||||
|
||||
method leaveCommunity*(self: Module) =
|
||||
self.controller.leaveCommunity()
|
||||
|
||||
|
@ -53,3 +53,6 @@ method reorderChannels*(self: AccessInterface, chatId, categoryId: string, posit
|
||||
|
||||
method onCommunityCategoryCreated*(self: AccessInterface, category: Category, chats: seq[ChatDto]) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method onCommunityCategoryDeleted*(self: AccessInterface, category: Category) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
@ -114,3 +114,6 @@ method inviteUsersToCommunity*(self: AccessInterface, pubKeysJSON: string): stri
|
||||
|
||||
method createCommunityCategory*(self: AccessInterface, name: string, channels: seq[string]) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method deleteCommunityCategory*(self: AccessInterface, categoryId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
@ -223,4 +223,7 @@ QtObject:
|
||||
|
||||
proc createCommunityCategory*(self: View, name: string, channels: string) {.slot.} =
|
||||
let channelsSeq = map(parseJson(channels).getElems(), proc(x:JsonNode):string = x.getStr())
|
||||
self.delegate.createCommunityCategory(name, channelsSeq)
|
||||
self.delegate.createCommunityCategory(name, channelsSeq)
|
||||
|
||||
proc deleteCommunityCategory*(self: View, categoryId: string) {.slot.} =
|
||||
self.delegate.deleteCommunityCategory(categoryId)
|
||||
|
@ -194,8 +194,8 @@ StatusModal {
|
||||
onConfirmButtonClicked: function(){
|
||||
const error = root.store.deleteCommunityCategory(root.categoryId);
|
||||
if (error) {
|
||||
creatingError.text = error
|
||||
return creatingError.open()
|
||||
categoryError.text = error
|
||||
return categoryError.open()
|
||||
}
|
||||
close();
|
||||
root.close()
|
||||
|
@ -159,8 +159,7 @@ QtObject {
|
||||
}
|
||||
|
||||
function deleteCommunityCategory(categoryId) {
|
||||
// Not Refactored Yet
|
||||
// chatsModelInst.communities.deleteCommunityCategory(chatsModelInst.communities.activeCommunity.id, categoryId);
|
||||
chatCommunitySectionModule.deleteCommunityCategory(categoryId);
|
||||
}
|
||||
|
||||
function leaveCommunity() {
|
||||
|
@ -209,24 +209,27 @@ Item {
|
||||
property var categoryItem
|
||||
|
||||
openHandler: function (id) {
|
||||
// Not Refactored Yet
|
||||
// categoryItem = root.store.chatsModelInst.communities.activeCommunity.getCommunityCategoryItemById(id)
|
||||
let jsonObj = root.communitySectionModule.getItemAsJson(id)
|
||||
let obj = JSON.parse(jsonObj)
|
||||
if (obj.error) {
|
||||
console.error("error parsing chat item json object, id: ", id, " error: ", obj.error)
|
||||
close()
|
||||
return
|
||||
}
|
||||
categoryItem = obj
|
||||
}
|
||||
|
||||
StatusMenuItem {
|
||||
// Not Refactored Yet
|
||||
enabled: communityData.amISectionAdmin
|
||||
//% "Edit Category"
|
||||
text: qsTrId("edit-category")
|
||||
icon.name: "edit"
|
||||
onTriggered: {
|
||||
// Not Refactored Yet
|
||||
// Global.openPopup(createCategoryPopup, {
|
||||
// communityId: root.store.chatsModelInst.communities.activeCommunity.id,
|
||||
// isEdit: true,
|
||||
// categoryId: categoryItem.id,
|
||||
// categoryName: categoryItem.name
|
||||
// })
|
||||
Global.openPopup(createCategoryPopup, {
|
||||
isEdit: true,
|
||||
categoryId: categoryItem.categoryId,
|
||||
categoryName: categoryItem.name
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -247,7 +250,7 @@ Item {
|
||||
//% "Are you sure you want to delete %1 category? Channels inside the category won’t be deleted."
|
||||
confirmationText: qsTrId("are-you-sure-you-want-to-delete--1-category--channels-inside-the-category-won-t-be-deleted-")
|
||||
.arg(categoryItem.name),
|
||||
categoryId: categoryItem.id
|
||||
categoryId: categoryItem.categoryId
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -431,13 +434,12 @@ Item {
|
||||
close();
|
||||
}
|
||||
onConfirmButtonClicked: function(){
|
||||
// Not Refactored Yet
|
||||
// const error = root.store.chatsModelInst.communities.deleteCommunityCategory(root.store.chatsModelInst.communities.activeCommunity.id, categoryId)
|
||||
// if (error) {
|
||||
// creatingError.text = error
|
||||
// return creatingError.open()
|
||||
// }
|
||||
// close();
|
||||
const error = root.store.deleteCommunityCategory(categoryId);
|
||||
if (error) {
|
||||
deleteError.text = error
|
||||
return deleteError.open()
|
||||
}
|
||||
close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user