Set initial state to empty chat view instead of selecting the first chat
This commit is contained in:
parent
76e1944de1
commit
1cc5d9155f
|
@ -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:
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -18,10 +18,17 @@ Item {
|
||||||
model: chatsModel.chats
|
model: chatsModel.chats
|
||||||
delegate: Channel {}
|
delegate: Channel {}
|
||||||
onCountChanged: {
|
onCountChanged: {
|
||||||
|
if (count > 0 && chatsModel.activeChannelIndex > -1) {
|
||||||
// If a chat is added or removed, we set the current index to the first value
|
// If a chat is added or removed, we set the current index to the first value
|
||||||
if (count > 0) {
|
|
||||||
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue