diff --git a/src/app/chat/view.nim b/src/app/chat/view.nim index 960762effb..9c5d703fe4 100644 --- a/src/app/chat/view.nim +++ b/src/app/chat/view.nim @@ -293,11 +293,12 @@ QtObject: proc getLinkPreviewData*(self: ChatsView, link: string, uuid: string) {.slot.} = self.getLinkPreviewData("linkPreviewDataReceived", link, uuid) - proc getChatType*(self: ChatsView, channel: string): int {.slot.} = + proc getChannel*(self: ChatsView, channel: string): string {.slot.} = let selectedChannel = self.channelView.getChannelById(channel) if selectedChannel == nil: - return -1 - selectedChannel.chatType.int + return "" + + result = Json.encode(selectedChannel.toJsonNode()) proc asyncActivityNotificationLoad*(self: ChatsView) {.slot.} = self.asyncActivityNotificationLoad("asyncActivityNotificationLoaded") diff --git a/src/app/chat/views/channel.nim b/src/app/chat/views/channel.nim index f874a68c14..96538e7e05 100644 --- a/src/app/chat/views/channel.nim +++ b/src/app/chat/views/channel.nim @@ -49,9 +49,8 @@ QtObject: let index = self.communities.activeCommunity.chats.chats.findIndexById(channel) if (index > -1): return self.communities.activeCommunity.chats.getChannel(index) - let chan = self.communities.activeCommunity.chats.getChannelByName(channel) - if not chan.isNil: - return chan + + return self.communities.activeCommunity.chats.getChannelByName(channel) proc getChannelById*(self: ChannelView, channel: string): Chat = if self.communities.activeCommunity.active: diff --git a/src/app/chat/views/channels_list.nim b/src/app/chat/views/channels_list.nim index 8327ff24e5..43f8fad1d5 100644 --- a/src/app/chat/views/channels_list.nim +++ b/src/app/chat/views/channels_list.nim @@ -125,7 +125,7 @@ QtObject: proc getChannel*(self: ChannelsList, index: int): Chat = if index < 0 or index >= self.chats.len: - return + return nil result = self.chats[index] @@ -146,6 +146,8 @@ QtObject: if chat.name == name: return chat + return nil + proc upsertChannel(self: ChannelsList, channel: Chat): int = let idx = self.chats.findIndexById(channel.id) if idx == -1: diff --git a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatText.qml b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatText.qml index 831e7d4e09..d3edb20396 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatText.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatText.qml @@ -44,21 +44,40 @@ Item { onLinkActivated: { if(link.startsWith("#")) { const channelName = link.substring(1); - const chatType = chatsModel.communities.activeCommunity.active ? Constants.chatTypeCommunity : Constants.chatTypePublic; - const foundChatType = chatsModel.getChatType(channelName); + const foundChannelObj = chatsModel.getChannel(channelName); - if(foundChatType === -1 || foundChatType !== Constants.chatTypePublic){ - chatsModel.channelView.joinPublicChat(channelName); - if(chatsModel.communities.activeCommunity.active) { - chatsModel.communities.activeCommunity.active = false + if (!foundChannelObj) + { + chatsModel.channelView.joinPublicChat(channelName) + if(chatsModel.communities.activeCommunity.active) + { + chatsModel.channelView.joinPublicChat(channelName) appMain.changeAppSection(Constants.chat) - } - } else { - appMain.changeAppSection(Constants.chat) + } + return + } + + let obj = JSON.parse(foundChannelObj) + + if(obj.chatType === -1 || obj.chatType === Constants.chatTypePublic) + { + if(chatsModel.communities.activeCommunity.active) + { + chatsModel.channelView.joinPublicChat(channelName) + appMain.changeAppSection(Constants.chat) + } + + chatsModel.channelView.setActiveChannel(channelName); + } + else if(obj.communityId === chatsModel.communities.activeCommunity.id && + obj.chatType === Constants.chatTypeCommunity && + chatsModel.channelView.activeChannel.id !== obj.id + ) + { chatsModel.channelView.setActiveChannel(channelName); } - return; + return } if (link.startsWith('//')) { diff --git a/vendor/status-lib b/vendor/status-lib index ea02568fbc..4f7e899953 160000 --- a/vendor/status-lib +++ b/vendor/status-lib @@ -1 +1 @@ -Subproject commit ea02568fbc1cdb22a2309dfcf1594a5934730581 +Subproject commit 4f7e899953843a316336fa72ae049f7880f6f7bd