fix(@desktop/chat): channel links sends to main public channel instead of a channel in that community

In case clicked channel:
- exists in a community -> the app will switch you to it
- doesn't exist in a community, but exists in the public chat list -> the app
  will switch to `Chat` section and also to the appropriate channel there
- doesn't exist in a community and doesn't exist in the public chat list -> the app
  will switch to `Chat` section and join new channel

Fixes: #3489
This commit is contained in:
Sale Djenic 2021-09-20 15:49:51 +02:00 committed by Iuri Matias
parent b5e8132859
commit 0c73febf2c
5 changed files with 39 additions and 18 deletions

View File

@ -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")

View File

@ -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:

View File

@ -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:

View File

@ -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('//')) {

2
vendor/status-lib vendored

@ -1 +1 @@
Subproject commit ea02568fbc1cdb22a2309dfcf1594a5934730581
Subproject commit 4f7e899953843a316336fa72ae049f7880f6f7bd