mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-23 03:58:49 +00:00
fix(@community): List channel/Add channel/Remove channel from category
fixes #5801
This commit is contained in:
parent
8c496e0505
commit
ddb884fc37
@ -213,9 +213,8 @@ proc getCategories*(self: Controller, communityId: string): seq[Category] =
|
|||||||
proc getChats*(self: Controller, communityId: string, categoryId: string): seq[ChatDto] =
|
proc getChats*(self: Controller, communityId: string, categoryId: string): seq[ChatDto] =
|
||||||
return self.communityService.getChats(communityId, categoryId)
|
return self.communityService.getChats(communityId, categoryId)
|
||||||
|
|
||||||
proc getChatDetails*(self: Controller, communityId, chatId: string): ChatDto =
|
proc getChatDetails*(self: Controller, chatId: string): ChatDto =
|
||||||
let fullId = communityId & chatId
|
return self.chatService.getChatById(chatId)
|
||||||
return self.chatService.getChatById(fullId)
|
|
||||||
|
|
||||||
proc getChatDetailsForChatTypes*(self: Controller, types: seq[ChatType]): seq[ChatDto] =
|
proc getChatDetailsForChatTypes*(self: Controller, types: seq[ChatType]): seq[ChatDto] =
|
||||||
return self.chatService.getChatsOfChatTypes(types)
|
return self.chatService.getChatsOfChatTypes(types)
|
||||||
|
@ -477,7 +477,7 @@ method onCommunityCategoryDeleted*(self: Module, cat: Category) =
|
|||||||
for c in chats:
|
for c in chats:
|
||||||
if (c.categoryId != cat.id or self.doesTopLevelChatExist(self.controller.getMySectionId() & c.id)):
|
if (c.categoryId != cat.id or self.doesTopLevelChatExist(self.controller.getMySectionId() & c.id)):
|
||||||
continue
|
continue
|
||||||
let chatDto = self.controller.getChatDetails(self.controller.getMySectionId(), c.id)
|
let chatDto = self.controller.getChatDetails(c.id)
|
||||||
let hasNotification = chatDto.unviewedMessagesCount > 0 or chatDto.unviewedMentionsCount > 0
|
let hasNotification = chatDto.unviewedMessagesCount > 0 or chatDto.unviewedMentionsCount > 0
|
||||||
let notificationsCount = chatDto.unviewedMentionsCount
|
let notificationsCount = chatDto.unviewedMentionsCount
|
||||||
let amIChatAdmin = self.controller.getMyCommunity().admin
|
let amIChatAdmin = self.controller.getMyCommunity().admin
|
||||||
@ -744,15 +744,14 @@ method prepareEditCategoryModel*(self: Module, categoryId: string) =
|
|||||||
let communityId = self.controller.getMySectionId()
|
let communityId = self.controller.getMySectionId()
|
||||||
let chats = self.controller.getChats(communityId, "")
|
let chats = self.controller.getChats(communityId, "")
|
||||||
for chat in chats:
|
for chat in chats:
|
||||||
let c = self.controller.getChatDetails(communityId, chat.id)
|
let c = self.controller.getChatDetails(chat.id)
|
||||||
let item = initItem(c.id, c.name, icon="", c.color, c.emoji, c.description,
|
let item = initItem(c.id, c.name, icon="", c.color, c.emoji, c.description,
|
||||||
c.chatType.int, amIChatAdmin=false, hasUnreadMessages=false, notificationsCount=0, c.muted,
|
c.chatType.int, amIChatAdmin=false, hasUnreadMessages=false, notificationsCount=0, c.muted,
|
||||||
blocked=false, active=false, c.position, categoryId="")
|
blocked=false, active=false, c.position, categoryId="")
|
||||||
|
|
||||||
self.view.editCategoryChannelsModel().appendItem(item)
|
self.view.editCategoryChannelsModel().appendItem(item)
|
||||||
let catChats = self.controller.getChats(communityId, categoryId)
|
let catChats = self.controller.getChats(communityId, categoryId)
|
||||||
for chat in catChats:
|
for chat in catChats:
|
||||||
let c = self.controller.getChatDetails(communityId, chat.id)
|
let c = self.controller.getChatDetails(chat.id)
|
||||||
let item = initItem(c.id, c.name, icon="", c.color, c.emoji, c.description,
|
let item = initItem(c.id, c.name, icon="", c.color, c.emoji, c.description,
|
||||||
c.chatType.int, amIChatAdmin=false, hasUnreadMessages=false, notificationsCount=0, c.muted,
|
c.chatType.int, amIChatAdmin=false, hasUnreadMessages=false, notificationsCount=0, c.muted,
|
||||||
blocked=false, active=false, c.position, categoryId)
|
blocked=false, active=false, c.position, categoryId)
|
||||||
|
@ -236,7 +236,7 @@ QtObject:
|
|||||||
if (showWarning):
|
if (showWarning):
|
||||||
warn "trying to get chat data for an unexisting chat id", chatId
|
warn "trying to get chat data for an unexisting chat id", chatId
|
||||||
return
|
return
|
||||||
|
|
||||||
return self.chats[chatId]
|
return self.chats[chatId]
|
||||||
|
|
||||||
proc getOneToOneChatNameAndImage*(self: Service, chatId: string):
|
proc getOneToOneChatNameAndImage*(self: Service, chatId: string):
|
||||||
|
@ -740,7 +740,6 @@ QtObject:
|
|||||||
channels: seq[string]) =
|
channels: seq[string]) =
|
||||||
try:
|
try:
|
||||||
let response = status_go.createCommunityCategory(communityId, name, channels)
|
let response = status_go.createCommunityCategory(communityId, name, channels)
|
||||||
|
|
||||||
if response.error != nil:
|
if response.error != nil:
|
||||||
let error = Json.decode($response.error, RpcError)
|
let error = Json.decode($response.error, RpcError)
|
||||||
raise newException(RpcException, "Error creating community category: " & error.message)
|
raise newException(RpcException, "Error creating community category: " & error.message)
|
||||||
@ -748,12 +747,12 @@ QtObject:
|
|||||||
if response.result != nil and response.result.kind != JNull:
|
if response.result != nil and response.result.kind != JNull:
|
||||||
var chats: seq[ChatDto] = @[]
|
var chats: seq[ChatDto] = @[]
|
||||||
for chatId, v in response.result["communityChanges"].getElems()[0]["chatsModified"].pairs():
|
for chatId, v in response.result["communityChanges"].getElems()[0]["chatsModified"].pairs():
|
||||||
let idx = findIndexById(chatId, self.joinedCommunities[communityId].chats)
|
let fullChatId = communityId & chatId
|
||||||
|
let idx = findIndexById(fullChatId, self.joinedCommunities[communityId].chats)
|
||||||
if idx > -1:
|
if idx > -1:
|
||||||
self.joinedCommunities[communityId].chats[idx].categoryId = v["CategoryModified"].getStr()
|
self.joinedCommunities[communityId].chats[idx].categoryId = v["CategoryModified"].getStr()
|
||||||
self.joinedCommunities[communityId].chats[idx].position = v["PositionModified"].getInt()
|
self.joinedCommunities[communityId].chats[idx].position = v["PositionModified"].getInt()
|
||||||
if self.joinedCommunities[communityId].chats[idx].categoryId.len > 0:
|
if self.joinedCommunities[communityId].chats[idx].categoryId.len > 0:
|
||||||
let fullChatId = communityId & chatId
|
|
||||||
var chatDetails = self.chatService.getChatById(fullChatId) # we are free to do this cause channel must be created before we add it to a category
|
var chatDetails = self.chatService.getChatById(fullChatId) # we are free to do this cause channel must be created before we add it to a category
|
||||||
chatDetails.updateMissingFields(self.joinedCommunities[communityId].chats[idx])
|
chatDetails.updateMissingFields(self.joinedCommunities[communityId].chats[idx])
|
||||||
self.chatService.updateOrAddChat(chatDetails) # we have to update chats stored in the chat service.
|
self.chatService.updateOrAddChat(chatDetails) # we have to update chats stored in the chat service.
|
||||||
@ -781,12 +780,12 @@ QtObject:
|
|||||||
if response.result != nil and response.result.kind != JNull:
|
if response.result != nil and response.result.kind != JNull:
|
||||||
var chats: seq[ChatDto] = @[]
|
var chats: seq[ChatDto] = @[]
|
||||||
for chatId, v in response.result["communityChanges"].getElems()[0]["chatsModified"].pairs():
|
for chatId, v in response.result["communityChanges"].getElems()[0]["chatsModified"].pairs():
|
||||||
let idx = findIndexById(chatId, self.joinedCommunities[communityId].chats)
|
let fullChatId = communityId & chatId
|
||||||
|
let idx = findIndexById(fullChatId, self.joinedCommunities[communityId].chats)
|
||||||
if idx > -1:
|
if idx > -1:
|
||||||
self.joinedCommunities[communityId].chats[idx].categoryId = v["CategoryModified"].getStr()
|
self.joinedCommunities[communityId].chats[idx].categoryId = v["CategoryModified"].getStr()
|
||||||
self.joinedCommunities[communityId].chats[idx].position = v["PositionModified"].getInt()
|
self.joinedCommunities[communityId].chats[idx].position = v["PositionModified"].getInt()
|
||||||
|
|
||||||
let fullChatId = communityId & chatId
|
|
||||||
var chatDetails = self.chatService.getChatById(fullChatId) # we are free to do this cause channel must be created before we add it to a category
|
var chatDetails = self.chatService.getChatById(fullChatId) # we are free to do this cause channel must be created before we add it to a category
|
||||||
chatDetails.updateMissingFields(self.joinedCommunities[communityId].chats[idx])
|
chatDetails.updateMissingFields(self.joinedCommunities[communityId].chats[idx])
|
||||||
self.chatService.updateOrAddChat(chatDetails) # we have to update chats stored in the chat service.
|
self.chatService.updateOrAddChat(chatDetails) # we have to update chats stored in the chat service.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user