Set initial state to empty chat view instead of selecting the first chat

This commit is contained in:
Richard Ramos 2020-06-05 10:50:39 -04:00 committed by RichΛrd
parent 76e1944de1
commit 1cc5d9155f
4 changed files with 11 additions and 6 deletions

View File

@ -69,7 +69,6 @@ proc init*(self: ChatController) =
self.status.mailservers.init()
self.status.chat.init()
self.view.setActiveChannelByIndex(0)
proc handleMessage(self: ChatController, data: MessageSignal) =
for c in data.chats:

View File

@ -79,7 +79,6 @@ proc init*(self: ChatModel) =
filters.add status_chat.buildFilter(chatId = chat.id, oneToOne = chat.chatType.isOneToOne)
self.channels.incl chat.id
self.events.emit("channelJoined", ChannelArgs(channel: chat.id, chatTypeInt: chat.chatType))
self.events.emit("activeChannelChanged", ChannelArgs(channel: self.getActiveChannel()))
if filters.len == 0: return

View File

@ -13,7 +13,7 @@ StackLayout {
Layout.fillWidth: true
Layout.minimumWidth: 300
currentIndex: chatGroupsListViewCount > 0 ? 0 : 1
currentIndex: chatsModel.activeChannelIndex > -1 && chatGroupsListViewCount > 0 ? 0 : 1
ColumnLayout {
id: chatColumn

View File

@ -18,10 +18,17 @@ Item {
model: chatsModel.chats
delegate: Channel {}
onCountChanged: {
// If a chat is added or removed, we set the current index to the first value
if (count > 0) {
currentIndex = 0;
if (count > 0 && chatsModel.activeChannelIndex > -1) {
// If a chat is added or removed, we set the current index to the first value
chatsModel.activeChannelIndex = 0;
currentIndex = 0;
} else {
if(chatsModel.activeChannelIndex > -1){
chatGroupsListView.currentIndex = 0;
} else {
// Initial state. No chat has been selected yet
chatGroupsListView.currentIndex = -1;
}
}
}
}