diff --git a/src/app/modules/main/chat_section/controller.nim b/src/app/modules/main/chat_section/controller.nim index 90a6a38c0e..91bb6e8eef 100644 --- a/src/app/modules/main/chat_section/controller.nim +++ b/src/app/modules/main/chat_section/controller.nim @@ -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) diff --git a/src/app/modules/main/chat_section/io_interface.nim b/src/app/modules/main/chat_section/io_interface.nim index aca6fa749e..bd27c7546c 100644 --- a/src/app/modules/main/chat_section/io_interface.nim +++ b/src/app/modules/main/chat_section/io_interface.nim @@ -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") diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index e88a1081c0..7033516f09 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -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 diff --git a/src/app/modules/main/chat_section/view.nim b/src/app/modules/main/chat_section/view.nim index e7d1408ec0..5e8b1f5142 100644 --- a/src/app/modules/main/chat_section/view.nim +++ b/src/app/modules/main/chat_section/view.nim @@ -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 diff --git a/ui/imports/shared/views/chat/MessageView.qml b/ui/imports/shared/views/chat/MessageView.qml index 6b7a5dfb9a..33d76df6a9 100644 --- a/ui/imports/shared/views/chat/MessageView.qml +++ b/ui/imports/shared/views/chat/MessageView.qml @@ -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)