fix: fix calling setActiveChannel from QML

This commit is contained in:
Jonathan Rainville 2021-02-19 13:58:25 -05:00 committed by Iuri Matias
parent da77487746
commit c57356235b
1 changed files with 5 additions and 2 deletions

View File

@ -226,7 +226,7 @@ QtObject:
if not response.hasKey("error"):
self.chats.clearUnreadMessagesCount(channel)
proc setActiveChannelByIndex*(self: ChatsView, index: int, forceUpdate: bool = false) {.slot.} =
proc setActiveChannelByIndexWithForce*(self: ChatsView, index: int, forceUpdate: bool) {.slot.} =
if((self.communities.activeCommunity.active and self.communities.activeCommunity.chats.chats.len == 0) or (not self.communities.activeCommunity.active and self.chats.chats.len == 0)): return
let selectedChannel =
if (self.communities.activeCommunity.active):
@ -250,6 +250,9 @@ QtObject:
self.activeChannel.setChatItem(selectedChannel)
self.status.chat.setActiveChannel(selectedChannel.id)
proc setActiveChannelByIndex*(self: ChatsView, index: int) {.slot.} =
self.setActiveChannelByIndexWithForce(index, false)
proc getActiveChannelIdx(self: ChatsView): int {.slot.} =
if (self.communities.activeCommunity.active):
return self.communities.activeCommunity.chats.chats.findIndexById(self.activeChannel.id)
@ -305,7 +308,7 @@ QtObject:
proc restorePreviousActiveChannel*(self: ChatsView) {.slot.} =
if self.previousActiveChannelIndex != -1:
self.setActiveChannelByIndex(self.previousActiveChannelIndex, true)
self.setActiveChannelByIndexWithForce(self.previousActiveChannelIndex, true)
proc getCurrentSuggestions(self: ChatsView): QVariant {.slot.} =
return newQVariant(self.currentSuggestions)