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.mailservers.init()
self.status.chat.init() self.status.chat.init()
self.view.setActiveChannelByIndex(0)
proc handleMessage(self: ChatController, data: MessageSignal) = proc handleMessage(self: ChatController, data: MessageSignal) =
for c in data.chats: 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) filters.add status_chat.buildFilter(chatId = chat.id, oneToOne = chat.chatType.isOneToOne)
self.channels.incl chat.id self.channels.incl chat.id
self.events.emit("channelJoined", ChannelArgs(channel: chat.id, chatTypeInt: chat.chatType)) self.events.emit("channelJoined", ChannelArgs(channel: chat.id, chatTypeInt: chat.chatType))
self.events.emit("activeChannelChanged", ChannelArgs(channel: self.getActiveChannel()))
if filters.len == 0: return if filters.len == 0: return

View File

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

View File

@ -18,10 +18,17 @@ Item {
model: chatsModel.chats model: chatsModel.chats
delegate: Channel {} delegate: Channel {}
onCountChanged: { onCountChanged: {
// If a chat is added or removed, we set the current index to the first value if (count > 0 && chatsModel.activeChannelIndex > -1) {
if (count > 0) { // If a chat is added or removed, we set the current index to the first value
currentIndex = 0;
chatsModel.activeChannelIndex = 0; 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;
}
} }
} }
} }