fix: ste channels correctly when going back and forth to communities
This commit is contained in:
parent
f9817d4f52
commit
807048522a
|
@ -58,8 +58,14 @@ proc handleChatEvents(self: ChatController) =
|
||||||
self.view.appReady()
|
self.view.appReady()
|
||||||
|
|
||||||
self.status.events.on("communityActiveChanged") do(e:Args):
|
self.status.events.on("communityActiveChanged") do(e:Args):
|
||||||
# TODO set this back to the previous one instead
|
var evArgs = CommunityActiveChangedArgs(e)
|
||||||
|
if (evArgs.active == false):
|
||||||
|
self.view.restorePreviousActiveChannel()
|
||||||
|
else:
|
||||||
|
if (self.view.activeCommunity.communityItem.lastChannelSeen == ""):
|
||||||
self.view.setActiveChannelByIndex(0)
|
self.view.setActiveChannelByIndex(0)
|
||||||
|
else:
|
||||||
|
self.view.setActiveChannel(self.view.activeCommunity.communityItem.lastChannelSeen)
|
||||||
|
|
||||||
self.status.events.on("channelJoined") do(e: Args):
|
self.status.events.on("channelJoined") do(e: Args):
|
||||||
var channel = ChannelArgs(e)
|
var channel = ChannelArgs(e)
|
||||||
|
|
|
@ -240,6 +240,9 @@ QtObject:
|
||||||
|
|
||||||
self.clearUnreadIfNeeded(self.activeChannel.chatItem)
|
self.clearUnreadIfNeeded(self.activeChannel.chatItem)
|
||||||
self.clearUnreadIfNeeded(selectedChannel)
|
self.clearUnreadIfNeeded(selectedChannel)
|
||||||
|
if (self.activeCommunity.active and self.activeCommunity.communityItem.lastChannelSeen != selectedChannel.id):
|
||||||
|
self.activeCommunity.communityItem.lastChannelSeen = selectedChannel.id
|
||||||
|
self.joinedCommunityList.replaceCommunity(self.activeCommunity.communityItem)
|
||||||
|
|
||||||
if self.activeChannel.id == selectedChannel.id: return
|
if self.activeChannel.id == selectedChannel.id: return
|
||||||
|
|
||||||
|
@ -304,7 +307,7 @@ QtObject:
|
||||||
self.activeChannelChanged()
|
self.activeChannelChanged()
|
||||||
|
|
||||||
proc restorePreviousActiveChannel*(self: ChatsView) {.slot.} =
|
proc restorePreviousActiveChannel*(self: ChatsView) {.slot.} =
|
||||||
if self.activeChannel.id == self.timelineChat.id and not self.previousActiveChannelIndex == -1:
|
if self.previousActiveChannelIndex != -1:
|
||||||
self.setActiveChannelByIndex(self.previousActiveChannelIndex)
|
self.setActiveChannelByIndex(self.previousActiveChannelIndex)
|
||||||
|
|
||||||
proc getCurrentSuggestions(self: ChatsView): QVariant {.slot.} =
|
proc getCurrentSuggestions(self: ChatsView): QVariant {.slot.} =
|
||||||
|
|
|
@ -41,7 +41,7 @@ QtObject:
|
||||||
|
|
||||||
proc setActive*(self: CommunityItemView, value: bool) {.slot.} =
|
proc setActive*(self: CommunityItemView, value: bool) {.slot.} =
|
||||||
self.active = value
|
self.active = value
|
||||||
self.status.events.emit("communityActiveChanged", Args())
|
self.status.events.emit("communityActiveChanged", CommunityActiveChangedArgs(active: value))
|
||||||
self.activeChanged()
|
self.activeChanged()
|
||||||
|
|
||||||
proc nbMembersChanged*(self: CommunityItemView) {.signal.}
|
proc nbMembersChanged*(self: CommunityItemView) {.signal.}
|
||||||
|
|
|
@ -36,6 +36,9 @@ type
|
||||||
ChatArgs* = ref object of Args
|
ChatArgs* = ref object of Args
|
||||||
chats*: seq[Chat]
|
chats*: seq[Chat]
|
||||||
|
|
||||||
|
CommunityActiveChangedArgs* = ref object of Args
|
||||||
|
active*: bool
|
||||||
|
|
||||||
TopicArgs* = ref object of Args
|
TopicArgs* = ref object of Args
|
||||||
topics*: seq[MailserverTopic]
|
topics*: seq[MailserverTopic]
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,7 @@ type CommunityMembershipRequest* = object
|
||||||
type Community* = object
|
type Community* = object
|
||||||
id*: string
|
id*: string
|
||||||
name*: string
|
name*: string
|
||||||
|
lastChannelSeen*: string
|
||||||
description*: string
|
description*: string
|
||||||
chats*: seq[Chat]
|
chats*: seq[Chat]
|
||||||
members*: seq[string]
|
members*: seq[string]
|
||||||
|
|
|
@ -40,8 +40,7 @@ proc blockContact*(self: ContactModel, id: string): string =
|
||||||
proc unblockContact*(self: ContactModel, id: string): string =
|
proc unblockContact*(self: ContactModel, id: string): string =
|
||||||
var contact = self.getContactByID(id)
|
var contact = self.getContactByID(id)
|
||||||
contact.systemTags.delete(contact.systemTags.find(":contact/blocked"))
|
contact.systemTags.delete(contact.systemTags.find(":contact/blocked"))
|
||||||
discard status_contacts.saveContact(contact.id, contact.ensVerified, contact.ensName, contact.ensVerifiedAt, contact.ensVerificationRetries,contact.alias, contact.identicon, contact.identityImage.thumbnail, contact.systemTags, contact.localNickname)
|
discard status_contacts.saveContact(contact.id, contact.ensVerified, contact.ensName, contact.alias, contact.identicon, contact.identityImage.thumbnail, contact.systemTags, contact.localNickname)
|
||||||
discard status_contacts.saveContact(contact.id, contact.ensVerified, contact.ensName, contact.alias, contact.identicon, contact.systemTags, contact.localNickname)
|
|
||||||
self.events.emit("contactUnblocked", Args())
|
self.events.emit("contactUnblocked", Args())
|
||||||
|
|
||||||
proc getAllContacts*(): seq[Profile] =
|
proc getAllContacts*(): seq[Profile] =
|
||||||
|
@ -85,7 +84,7 @@ proc addContact*(self: ContactModel, id: string, localNickname: string): string
|
||||||
if contact.identityImage != nil:
|
if contact.identityImage != nil:
|
||||||
thumbnail = contact.identityImage.thumbnail
|
thumbnail = contact.identityImage.thumbnail
|
||||||
|
|
||||||
result = status_contacts.saveContact(contact.id, contact.ensVerified, contact.ensName, contact.ensVerifiedAt, contact.ensVerificationRetries, contact.alias, contact.identicon, thumbnail, contact.systemTags, nickname)
|
result = status_contacts.saveContact(contact.id, contact.ensVerified, contact.ensName, contact.alias, contact.identicon, thumbnail, contact.systemTags, nickname)
|
||||||
self.events.emit("contactAdded", Args())
|
self.events.emit("contactAdded", Args())
|
||||||
discard requestContactUpdate(contact.id)
|
discard requestContactUpdate(contact.id)
|
||||||
|
|
||||||
|
@ -114,7 +113,7 @@ proc removeContact*(self: ContactModel, id: string) =
|
||||||
if contact.identityImage != nil:
|
if contact.identityImage != nil:
|
||||||
thumbnail = contact.identityImage.thumbnail
|
thumbnail = contact.identityImage.thumbnail
|
||||||
|
|
||||||
discard status_contacts.saveContact(contact.id, contact.ensVerified, contact.ensName, contact.ensVerifiedAt, contact.ensVerificationRetries, contact.alias, contact.identicon, thumbnail, contact.systemTags, contact.localNickname)
|
discard status_contacts.saveContact(contact.id, contact.ensVerified, contact.ensName, contact.alias, contact.identicon, thumbnail, contact.systemTags, contact.localNickname)
|
||||||
self.events.emit("contactRemoved", Args())
|
self.events.emit("contactRemoved", Args())
|
||||||
|
|
||||||
proc isAdded*(self: ContactModel, id: string): bool =
|
proc isAdded*(self: ContactModel, id: string): bool =
|
||||||
|
|
|
@ -24,8 +24,7 @@ proc getContacts*(): JsonNode =
|
||||||
return %* []
|
return %* []
|
||||||
return response["result"]
|
return response["result"]
|
||||||
|
|
||||||
proc saveContact*(id: string, ensVerified: bool, ensName: string, ensVerifiedAt: int, ensVerificationRetries: int, alias: string, identicon: string, thumbnail: string, systemTags: seq[string], localNickname: string): string =
|
proc saveContact*(id: string, ensVerified: bool, ensName: string, alias: string, identicon: string, thumbnail: string, systemTags: seq[string], localNickname: string): string =
|
||||||
proc saveContact*(id: string, ensVerified: bool, ensName: string, alias: string, identicon: string, systemTags: seq[string], localNickname: string): string =
|
|
||||||
let payload = %* [{
|
let payload = %* [{
|
||||||
"id": id,
|
"id": id,
|
||||||
"name": ensName,
|
"name": ensName,
|
||||||
|
|
|
@ -39,7 +39,7 @@ Item {
|
||||||
iconColor: Style.current.inputColor
|
iconColor: Style.current.inputColor
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: Style.current.bigPadding
|
anchors.leftMargin: Style.current.bigPadding
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: communityHeaderButton.verticalCenter
|
||||||
onClicked: chatsModel.activeCommunity.active = false
|
onClicked: chatsModel.activeCommunity.active = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,9 +43,7 @@ Item {
|
||||||
}
|
}
|
||||||
onCountChanged: {
|
onCountChanged: {
|
||||||
if (count > 0 && chatsModel.activeChannelIndex > -1) {
|
if (count > 0 && chatsModel.activeChannelIndex > -1) {
|
||||||
// If a chat is added or removed, we set the current index to the first value
|
currentIndex = chatsModel.activeChannelIndex;
|
||||||
chatsModel.activeChannelIndex = 0;
|
|
||||||
currentIndex = 0;
|
|
||||||
} else {
|
} else {
|
||||||
if (chatsModel.activeChannelIndex > -1) {
|
if (chatsModel.activeChannelIndex > -1) {
|
||||||
chatGroupsListView.currentIndex = 0;
|
chatGroupsListView.currentIndex = 0;
|
||||||
|
|
Loading…
Reference in New Issue