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)
|
return self.communities.activeCommunity.chats.getChannel(index)
|
||||||
else:
|
else:
|
||||||
return self.chats.getChannel(index)
|
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 =
|
proc getChannelById*(self: ChatsView, channel: string): Chat =
|
||||||
if (self.communities.activeCommunity.active):
|
if self.communities.activeCommunity.active:
|
||||||
let index = self.communities.activeCommunity.chats.chats.findIndexById(channel)
|
result = self.getCommunityChannelById(channel)
|
||||||
if (index == -1):
|
if not result.isNil:
|
||||||
return
|
return result
|
||||||
return self.communities.activeCommunity.chats.getChannel(index)
|
# even if communities are active, if we don't find a chat, it's possibly
|
||||||
else:
|
# because we are looking for a normal chat, so continue below
|
||||||
let index = self.chats.chats.findIndexById(channel)
|
let index = self.chats.chats.findIndexById(channel)
|
||||||
if (index == -1):
|
if index > -1:
|
||||||
return
|
|
||||||
return self.chats.getChannel(index)
|
return self.chats.getChannel(index)
|
||||||
|
|
||||||
proc updateChannelInRightList*(self: ChatsView, channel: Chat) =
|
proc updateChannelInRightList*(self: ChatsView, channel: Chat) =
|
||||||
|
@ -579,8 +586,13 @@ QtObject:
|
||||||
self.getLinkPreviewData("linkPreviewDataReceived", link, uuid)
|
self.getLinkPreviewData("linkPreviewDataReceived", link, uuid)
|
||||||
|
|
||||||
proc joinChat*(self: ChatsView, channel: string, chatTypeInt: int): int {.slot.} =
|
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)
|
self.setActiveChannel(channel)
|
||||||
|
chatType.int
|
||||||
|
|
||||||
proc joinChatWithENS*(self: ChatsView, channel: string, ensName: string): int {.slot.} =
|
proc joinChatWithENS*(self: ChatsView, channel: string, ensName: string): int {.slot.} =
|
||||||
self.status.chat.join(channel, ChatType.OneToOne, ensName=status_ens.addDomain(ensName))
|
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"}:
|
for chatId, chat in jsonCommunity{"chats"}:
|
||||||
result.chats.add(Chat(
|
result.chats.add(Chat(
|
||||||
id: result.id & chatId,
|
id: result.id & chatId,
|
||||||
|
communityId: result.id,
|
||||||
name: chat{"name"}.getStr,
|
name: chat{"name"}.getStr,
|
||||||
canPost: chat{"canPost"}.getBool,
|
canPost: chat{"canPost"}.getBool,
|
||||||
|
chatType: ChatType.CommunityChat
|
||||||
# TODO get this from access
|
# 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:
|
if jsonCommunity.hasKey("members") and jsonCommunity["members"].kind != JNull:
|
||||||
|
|
|
@ -44,7 +44,12 @@ Item {
|
||||||
clip: true
|
clip: true
|
||||||
onLinkActivated: function (link) {
|
onLinkActivated: function (link) {
|
||||||
if(link.startsWith("#")) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -337,8 +337,7 @@ ModalPopup {
|
||||||
visible: !isBlocked && chatsModel.activeChannel.id !== popup.fromAuthor
|
visible: !isBlocked && chatsModel.activeChannel.id !== popup.fromAuthor
|
||||||
width: visible ? implicitWidth : 0
|
width: visible ? implicitWidth : 0
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (tabBar.currentIndex !== 0)
|
appMain.changeAppSection(Constants.chat)
|
||||||
tabBar.currentIndex = 0
|
|
||||||
chatsModel.joinChat(fromAuthor, Constants.chatTypeOneToOne)
|
chatsModel.joinChat(fromAuthor, Constants.chatTypeOneToOne)
|
||||||
popup.close()
|
popup.close()
|
||||||
}
|
}
|
||||||
|
|
|
@ -362,6 +362,7 @@ RowLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeAppSection(section) {
|
function changeAppSection(section) {
|
||||||
|
chatsModel.communities.activeCommunity.active = false
|
||||||
sLayout.currentIndex = Utils.getAppSectionIndex(section)
|
sLayout.currentIndex = Utils.getAppSectionIndex(section)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue