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):
|
if (args.communityId == self.sectionId):
|
||||||
self.delegate.onCommunityCategoryCreated(args.category, args.chats)
|
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):
|
self.events.on(SIGNAL_COMMUNITY_CHANNEL_REORDERED) do(e:Args):
|
||||||
let args = CommunityChatOrderArgs(e)
|
let args = CommunityChatOrderArgs(e)
|
||||||
if (args.communityId == self.sectionId):
|
if (args.communityId == self.sectionId):
|
||||||
|
@ -306,6 +311,9 @@ method editCommunityChannel*(
|
||||||
method createCommunityCategory*(self: Controller, name: string, channels: seq[string]) =
|
method createCommunityCategory*(self: Controller, name: string, channels: seq[string]) =
|
||||||
self.communityService.createCommunityCategory(self.sectionId, name, channels)
|
self.communityService.createCommunityCategory(self.sectionId, name, channels)
|
||||||
|
|
||||||
|
method deleteCommunityCategory*(self: Controller, categoryId: string) =
|
||||||
|
self.communityService.deleteCommunityCategory(self.sectionId, categoryId)
|
||||||
|
|
||||||
method leaveCommunity*(self: Controller) =
|
method leaveCommunity*(self: Controller) =
|
||||||
self.communityService.leaveCommunity(self.sectionId)
|
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.} =
|
method joinGroupChatFromInvitation*(self: AccessInterface, groupName: string, chatId: string, adminPK: string) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
|
||||||
method acceptRequestToJoinCommunity*(self: AccessInterface, requestId: string) {.base.} =
|
method acceptRequestToJoinCommunity*(self: AccessInterface, requestId: string) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
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.} =
|
method createCommunityCategory*(self: AccessInterface, name: string, channels: seq[string]) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method deleteCommunityCategory*(self: AccessInterface, categoryId: string) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method leaveCommunity*(self: AccessInterface) {.base.} =
|
method leaveCommunity*(self: AccessInterface) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
|
|
@ -441,6 +441,20 @@ method onCommunityCategoryCreated*(self: Module, cat: Category, chats: seq[ChatD
|
||||||
categoryItem.prependSubItems(categoryChannels)
|
categoryItem.prependSubItems(categoryChannels)
|
||||||
self.view.chatsModel().appendItem(categoryItem)
|
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) =
|
method onCommunityChannelDeletedOrChatLeft*(self: Module, chatId: string) =
|
||||||
if(not self.chatContentModules.contains(chatId)):
|
if(not self.chatContentModules.contains(chatId)):
|
||||||
return
|
return
|
||||||
|
@ -599,6 +613,9 @@ method editCommunityChannel*(self: Module, channelId, name, description, categor
|
||||||
method createCommunityCategory*(self: Module, name: string, channels: seq[string]) =
|
method createCommunityCategory*(self: Module, name: string, channels: seq[string]) =
|
||||||
self.controller.createCommunityCategory(name, channels)
|
self.controller.createCommunityCategory(name, channels)
|
||||||
|
|
||||||
|
method deleteCommunityCategory*(self: Module, categoryId: string) =
|
||||||
|
self.controller.deleteCommunityCategory(categoryId)
|
||||||
|
|
||||||
method leaveCommunity*(self: Module) =
|
method leaveCommunity*(self: Module) =
|
||||||
self.controller.leaveCommunity()
|
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.} =
|
method onCommunityCategoryCreated*(self: AccessInterface, category: Category, chats: seq[ChatDto]) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
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.} =
|
method createCommunityCategory*(self: AccessInterface, name: string, channels: seq[string]) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method deleteCommunityCategory*(self: AccessInterface, categoryId: string) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
|
@ -224,3 +224,6 @@ QtObject:
|
||||||
proc createCommunityCategory*(self: View, name: string, channels: string) {.slot.} =
|
proc createCommunityCategory*(self: View, name: string, channels: string) {.slot.} =
|
||||||
let channelsSeq = map(parseJson(channels).getElems(), proc(x:JsonNode):string = x.getStr())
|
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(){
|
onConfirmButtonClicked: function(){
|
||||||
const error = root.store.deleteCommunityCategory(root.categoryId);
|
const error = root.store.deleteCommunityCategory(root.categoryId);
|
||||||
if (error) {
|
if (error) {
|
||||||
creatingError.text = error
|
categoryError.text = error
|
||||||
return creatingError.open()
|
return categoryError.open()
|
||||||
}
|
}
|
||||||
close();
|
close();
|
||||||
root.close()
|
root.close()
|
||||||
|
|
|
@ -159,8 +159,7 @@ QtObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteCommunityCategory(categoryId) {
|
function deleteCommunityCategory(categoryId) {
|
||||||
// Not Refactored Yet
|
chatCommunitySectionModule.deleteCommunityCategory(categoryId);
|
||||||
// chatsModelInst.communities.deleteCommunityCategory(chatsModelInst.communities.activeCommunity.id, categoryId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function leaveCommunity() {
|
function leaveCommunity() {
|
||||||
|
|
|
@ -209,24 +209,27 @@ Item {
|
||||||
property var categoryItem
|
property var categoryItem
|
||||||
|
|
||||||
openHandler: function (id) {
|
openHandler: function (id) {
|
||||||
// Not Refactored Yet
|
let jsonObj = root.communitySectionModule.getItemAsJson(id)
|
||||||
// categoryItem = root.store.chatsModelInst.communities.activeCommunity.getCommunityCategoryItemById(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 {
|
StatusMenuItem {
|
||||||
// Not Refactored Yet
|
|
||||||
enabled: communityData.amISectionAdmin
|
enabled: communityData.amISectionAdmin
|
||||||
//% "Edit Category"
|
//% "Edit Category"
|
||||||
text: qsTrId("edit-category")
|
text: qsTrId("edit-category")
|
||||||
icon.name: "edit"
|
icon.name: "edit"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
// Not Refactored Yet
|
Global.openPopup(createCategoryPopup, {
|
||||||
// Global.openPopup(createCategoryPopup, {
|
isEdit: true,
|
||||||
// communityId: root.store.chatsModelInst.communities.activeCommunity.id,
|
categoryId: categoryItem.categoryId,
|
||||||
// isEdit: true,
|
categoryName: categoryItem.name
|
||||||
// categoryId: categoryItem.id,
|
})
|
||||||
// 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."
|
//% "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-")
|
confirmationText: qsTrId("are-you-sure-you-want-to-delete--1-category--channels-inside-the-category-won-t-be-deleted-")
|
||||||
.arg(categoryItem.name),
|
.arg(categoryItem.name),
|
||||||
categoryId: categoryItem.id
|
categoryId: categoryItem.categoryId
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -431,13 +434,12 @@ Item {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
onConfirmButtonClicked: function(){
|
onConfirmButtonClicked: function(){
|
||||||
// Not Refactored Yet
|
const error = root.store.deleteCommunityCategory(categoryId);
|
||||||
// const error = root.store.chatsModelInst.communities.deleteCommunityCategory(root.store.chatsModelInst.communities.activeCommunity.id, categoryId)
|
if (error) {
|
||||||
// if (error) {
|
deleteError.text = error
|
||||||
// creatingError.text = error
|
return deleteError.open()
|
||||||
// return creatingError.open()
|
}
|
||||||
// }
|
close();
|
||||||
// close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue