fix: Send Message button not working in profile popup
Fixes: #2364 The Send Message button click event was erroring due to a refactor that had been done to allow for changing app sections. This has been updated to follow the current way to change app sections. fix: “Send Message” button crash in communities This required switching from communities to normal view. fix: crash when clicking channel link in community message When a message in communities contains a link to another channel (ie #otherchannel), the search for this channel needed to be updated to also search for the channel by name, allowing for switching between channels within a community by message link. Additionally, when in a community, if the channel was located in a normal chat, it will switch the view to the normal chat after being found.
This commit is contained in:
parent
daabef3a3c
commit
0850835b34
|
@ -167,17 +167,24 @@ QtObject:
|
|||
return self.communities.activeCommunity.chats.getChannel(index)
|
||||
else:
|
||||
return self.chats.getChannel(index)
|
||||
|
||||
proc getCommunityChannelById(self: ChatsView, channel: string): Chat =
|
||||
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
|
||||
|
||||
proc getChannelById*(self: ChatsView, channel: string): Chat =
|
||||
if (self.communities.activeCommunity.active):
|
||||
let index = self.communities.activeCommunity.chats.chats.findIndexById(channel)
|
||||
if (index == -1):
|
||||
return
|
||||
return self.communities.activeCommunity.chats.getChannel(index)
|
||||
else:
|
||||
let index = self.chats.chats.findIndexById(channel)
|
||||
if (index == -1):
|
||||
return
|
||||
if self.communities.activeCommunity.active:
|
||||
result = self.getCommunityChannelById(channel)
|
||||
if not result.isNil:
|
||||
return result
|
||||
# even if communities are active, if we don't find a chat, it's possibly
|
||||
# because we are looking for a normal chat, so continue below
|
||||
let index = self.chats.chats.findIndexById(channel)
|
||||
if index > -1:
|
||||
return self.chats.getChannel(index)
|
||||
|
||||
proc updateChannelInRightList*(self: ChatsView, channel: Chat) =
|
||||
|
@ -579,8 +586,13 @@ QtObject:
|
|||
self.getLinkPreviewData("linkPreviewDataReceived", link, uuid)
|
||||
|
||||
proc joinChat*(self: ChatsView, channel: string, chatTypeInt: int): int {.slot.} =
|
||||
self.status.chat.join(channel, ChatType(chatTypeInt))
|
||||
var chatType = ChatType(chatTypeInt)
|
||||
let selectedChannel = self.getChannelById(channel)
|
||||
if not selectedChannel.isNil:
|
||||
chatType = selectedChannel.chatType
|
||||
self.status.chat.join(channel, chatType)
|
||||
self.setActiveChannel(channel)
|
||||
chatType.int
|
||||
|
||||
proc joinChatWithENS*(self: ChatsView, channel: string, ensName: string): int {.slot.} =
|
||||
self.status.chat.join(channel, ChatType.OneToOne, ensName=status_ens.addDomain(ensName))
|
||||
|
|
|
@ -197,10 +197,12 @@ proc toCommunity*(jsonCommunity: JsonNode): Community =
|
|||
for chatId, chat in jsonCommunity{"chats"}:
|
||||
result.chats.add(Chat(
|
||||
id: result.id & chatId,
|
||||
communityId: result.id,
|
||||
name: chat{"name"}.getStr,
|
||||
canPost: chat{"canPost"}.getBool,
|
||||
chatType: ChatType.CommunityChat
|
||||
# TODO get this from access
|
||||
chatType: ChatType.Public#chat{"permissions"}{"access"}.getInt,
|
||||
#chat{"permissions"}{"access"}.getInt,
|
||||
))
|
||||
|
||||
if jsonCommunity.hasKey("members") and jsonCommunity["members"].kind != JNull:
|
||||
|
|
|
@ -44,7 +44,12 @@ Item {
|
|||
clip: true
|
||||
onLinkActivated: function (link) {
|
||||
if(link.startsWith("#")) {
|
||||
chatsModel.joinChat(link.substring(1), Constants.chatTypePublic);
|
||||
const chatType = chatsModel.communities.activeCommunity.active ? Constants.chatTypeCommunity : Constants.chatTypePublic;
|
||||
const foundChatType = chatsModel.joinChat(link.substring(1), chatType);
|
||||
if (foundChatType === Constants.chatTypePublic && chatsModel.communities.activeCommunity.active) {
|
||||
chatsModel.communities.activeCommunity.active = false
|
||||
appMain.changeAppSection(Constants.chat)
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -337,8 +337,7 @@ ModalPopup {
|
|||
visible: !isBlocked && chatsModel.activeChannel.id !== popup.fromAuthor
|
||||
width: visible ? implicitWidth : 0
|
||||
onClicked: {
|
||||
if (tabBar.currentIndex !== 0)
|
||||
tabBar.currentIndex = 0
|
||||
appMain.changeAppSection(Constants.chat)
|
||||
chatsModel.joinChat(fromAuthor, Constants.chatTypeOneToOne)
|
||||
popup.close()
|
||||
}
|
||||
|
|
|
@ -362,6 +362,7 @@ RowLayout {
|
|||
}
|
||||
|
||||
function changeAppSection(section) {
|
||||
chatsModel.communities.activeCommunity.active = false
|
||||
sLayout.currentIndex = Utils.getAppSectionIndex(section)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue