diff --git a/src/app/chat/view.nim b/src/app/chat/view.nim index a95e4372e2..b73c19f564 100644 --- a/src/app/chat/view.nim +++ b/src/app/chat/view.nim @@ -746,7 +746,11 @@ QtObject: self.chats.updateChat(chat) if(self.activeChannel.id == chat.id): self.activeChannel.setChatItem(chat) + self.activeChannelChanged() self.currentSuggestions.setNewData(self.status.contacts.getContacts()) + if self.contextChannel.id == chat.id: + self.contextChannel.setChatItem(chat) + self.contextChannelChanged() self.calculateUnreadMessages() proc deleteMessage*(self: ChatsView, channelId: string, messageId: string) = diff --git a/src/app/chat/views/chat_item.nim b/src/app/chat/views/chat_item.nim index 5de6eaf934..8f1fbc8be8 100644 --- a/src/app/chat/views/chat_item.nim +++ b/src/app/chat/views/chat_item.nim @@ -131,6 +131,7 @@ QtObject: QtProperty[QVariant] members: read = getMembers + notify = membershipChanged proc isTimelineChat*(self: ChatItemView): bool {.slot.} = result = ?.self.chatItem.id == status_utils.getTimelineChatId() @@ -157,6 +158,15 @@ QtObject: read = isMember notify = membershipChanged + proc isMemberButNotJoined*(self: ChatItemView): bool {.slot.} = + if self.chatItem.isNil: return false + let pubKey = status_settings.getSetting[string](Setting.PublicKey, "0x0") + return self.chatItem.isMemberButNotJoined(pubKey) + + QtProperty[bool] isMemberButNotJoined: + read = isMemberButNotJoined + notify = membershipChanged + proc mutedChanged*(self: ChatItemView) {.signal.} proc muted*(self: ChatItemView): bool {.slot.} = diff --git a/src/status/chat/chat.nim b/src/status/chat/chat.nim index 014dd165c3..6854e46060 100644 --- a/src/status/chat/chat.nim +++ b/src/status/chat/chat.nim @@ -183,7 +183,14 @@ proc findIndexById*(self: seq[CommunityCategory], id: string): int = proc isMember*(self: Chat, pubKey: string): bool = for member in self.members: - if member.id == pubKey and member.joined: return true + if member.id == pubKey: + return member.joined + return false + +proc isMemberButNotJoined*(self: Chat, pubKey: string): bool = + for member in self.members: + if member.id == pubKey: + return not member.joined return false proc contains*(self: Chat, pubKey: string): bool = @@ -193,5 +200,6 @@ proc contains*(self: Chat, pubKey: string): bool = proc isAdmin*(self: Chat, pubKey: string): bool = for member in self.members: - if member.id == pubKey and member.joined and member.admin: return true + if member.id == pubKey: + return member.joined and member.admin return false diff --git a/src/status/chat/utils.nim b/src/status/chat/utils.nim index 7563be08c2..cb27587aa2 100644 --- a/src/status/chat/utils.nim +++ b/src/status/chat/utils.nim @@ -16,7 +16,7 @@ proc processChatUpdate(self: ChatModel, response: JsonNode): (seq[Chat], seq[Mes let pk = status_settings.getSetting[string](Setting.PublicKey, "0x0") var chats: seq[Chat] = @[] var messages: seq[Message] = @[] - if response{"result"}{"chats"} != nil: + if response{"result"}{"messages"} != nil: for jsonMsg in response["result"]["messages"]: messages.add(jsonMsg.toMessage(pk)) if response{"result"}{"chats"} != nil: diff --git a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChannelIdentifier.qml b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChannelIdentifier.qml index d94f1da79e..889eccbb75 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChannelIdentifier.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChannelIdentifier.qml @@ -96,7 +96,7 @@ Column { } Item { - visible: chatsModel.activeChannel.chatType === Constants.chatTypePrivateGroupChat && !chatsModel.activeChannel.isMember + visible: chatsModel.activeChannel.chatType === Constants.chatTypePrivateGroupChat && chatsModel.activeChannel.isMemberButNotJoined anchors.horizontalCenter: parent.horizontalCenter width: visible ? joinChat.width : 0 height: visible ? 100 : 0 @@ -115,7 +115,6 @@ Column { anchors.fill: parent onClicked: { chatsModel.groups.join() - joinOrDecline.visible = false; } } } diff --git a/ui/app/AppLayouts/Chat/ChatColumn/TopBar.qml b/ui/app/AppLayouts/Chat/ChatColumn/TopBar.qml index 046eef1b51..71611c24a7 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/TopBar.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/TopBar.qml @@ -41,7 +41,7 @@ Item { onClicked: { switch (chatsModel.activeChannel.chatType) { case Constants.chatTypePrivateGroupChat: - openPopup(groupInfoPopupComponent, {channel: chatsModel.activeChannel}) + openPopup(groupInfoPopupComponent, {channelType: GroupInfoPopup.ChannelType.ActiveChannel}) break; case Constants.chatTypeOneToOne: const profileImage = appMain.getProfileImage(chatsModel.activeChannel.id) @@ -106,7 +106,7 @@ Item { icon.height: chatTopBarContent.iconSize //% "Group Information" text: qsTrId("group-information") - onTriggered: openPopup(groupInfoPopupComponent, {channel: chatsModel.activeChannel}) + onTriggered: openPopup(groupInfoPopupComponent, {channelType: GroupInfoPopup.ChannelType.ActiveChannel }) } Action { icon.source: "../../../img/close.svg" diff --git a/ui/app/AppLayouts/Chat/components/ChannelContextMenu.qml b/ui/app/AppLayouts/Chat/components/ChannelContextMenu.qml index b5640e9d9e..3ced77cf80 100644 --- a/ui/app/AppLayouts/Chat/components/ChannelContextMenu.qml +++ b/ui/app/AppLayouts/Chat/components/ChannelContextMenu.qml @@ -60,7 +60,7 @@ PopupMenu { ) } if (channelContextMenu.contextChannel.chatType === Constants.chatTypePrivateGroupChat) { - return openPopup(groupInfoPopupComponent, {channel: channelContextMenu.contextChannel}) + return openPopup(groupInfoPopupComponent, {channelType: GroupInfoPopup.ChannelType.ContextChannel}) } } } diff --git a/ui/app/AppLayouts/Chat/components/GroupInfoPopup.qml b/ui/app/AppLayouts/Chat/components/GroupInfoPopup.qml index 3b205a9029..b5cb94c4b2 100644 --- a/ui/app/AppLayouts/Chat/components/GroupInfoPopup.qml +++ b/ui/app/AppLayouts/Chat/components/GroupInfoPopup.qml @@ -8,12 +8,23 @@ import "./" ModalPopup { id: popup + enum ChannelType { + ActiveChannel, + ContextChannel + } property bool addMembers: false property int currMemberCount: 1 property int memberCount: 1 readonly property int maxMembers: 10 property var pubKeys: [] - property var channel + property int channelType: GroupInfoPopup.ChannelType.ActiveChannel + property QtObject channel: { + if (channelType === GroupInfoPopup.ChannelType.ActiveChannel) { + return chatsModel.activeChannel + } else if (channelType === GroupInfoPopup.ChannelType.ContextChannel) { + return chatsModel.contextChannel + } + } property bool isAdmin: false property Component pinnedMessagesPopupComponent @@ -227,6 +238,22 @@ ModalPopup { anchors.topMargin: visible ? Style.current.halfPadding : 0 } + Connections { + target: chatsModel + onActiveChannelChanged: { + if (popup.channelType === GroupInfoPopup.ChannelType.ActiveChannel) { + popup.channel = chatsModel.activeChannel + resetSelectedMembers() + } + } + onContextChannelChanged: { + if (popup.channelType === GroupInfoPopup.ChannelType.ContextChannel) { + popup.channel = chatsModel.contextChannel + resetSelectedMembers() + } + } + } + ListView { id: memberList anchors.top: separator2.bottom