fix(@desktop/chat): Fix channel link in chat

Clicking on a #link will open link channel in community

Fix #7636
This commit is contained in:
Michal Iskierko 2022-10-07 10:01:39 +02:00 committed by Michał Iskierko
parent 2710d02fea
commit 95c0721578
5 changed files with 24 additions and 0 deletions

View File

@ -254,6 +254,9 @@ proc getCategories*(self: Controller, communityId: string): seq[Category] =
proc getChats*(self: Controller, communityId: string, categoryId: string): seq[ChatDto] =
return self.communityService.getChats(communityId, categoryId)
proc getAllChats*(self: Controller, communityId: string): seq[ChatDto] =
return self.communityService.getAllChats(communityId)
proc getChatDetails*(self: Controller, chatId: string): ChatDto =
return self.chatService.getChatById(chatId)

View File

@ -316,3 +316,6 @@ method updateLastMessageTimestamp*(self: AccessInterface, chatId: string, lastMe
method contactsStatusUpdated*(self: AccessInterface, statusUpdates: seq[StatusUpdateDto]) =
raise newException(ValueError, "No implementation available")
method switchToChannel*(self: AccessInterface, channelName: string) =
raise newException(ValueError, "No implementation available")

View File

@ -458,6 +458,18 @@ method addNewChat*(
if setChatAsActive:
self.setActiveItemSubItem(categoryItem.id, channelItem.id)
method switchToChannel*(self: Module, channelName: string) =
if(not self.controller.isCommunity()):
return
let chats = self.controller.getAllChats(self.controller.getMySectionId())
for c in chats:
if c.name == channelName:
if c.categoryId == "":
self.setActiveItemSubItem(c.id, "")
else:
self.setActiveItemSubItem(c.categoryId, c.id)
return
method doesCatOrChatExist*(self: Module, id: string): bool =
return self.view.chatsModel().isItemWithIdAdded(id) or
not self.view.chatsModel().getSubItemById(id).isNil

View File

@ -120,6 +120,9 @@ QtObject:
proc setActiveItem*(self: View, itemId: string, subItemId: string = "") {.slot.} =
self.delegate.setActiveItemSubItem(itemId, subItemId)
proc switchToChannel*(self: View, channelName: string) {.slot.} =
self.delegate.switchToChannel(channelName)
proc activeItem*(self: View): ActiveItem =
result = self.activeItem

View File

@ -493,6 +493,9 @@ Loader {
const pubkey = link.replace("//", "");
Global.openProfilePopup(pubkey)
return;
} else if (link.startsWith('#')) {
rootStore.chatCommunitySectionModule.switchToChannel(link.replace("#", ""))
return;
}
Global.openLink(link)