Fix room at index 0 not highlightable

This commit is contained in:
miruka 2020-03-10 06:07:09 -04:00
parent 89ee4c2361
commit 8d594e3e83
3 changed files with 25 additions and 15 deletions

View File

@ -2,7 +2,6 @@
## Before release ## Before release
- Fix highlighted account/room in MainPane
- nio ClientTimeout - nio ClientTimeout
- Default theme? - Default theme?
- Name - Name

View File

@ -61,14 +61,22 @@ Column {
highlight: null // managed by the AccountRoomsList highlight: null // managed by the AccountRoomsList
readonly property bool hasActiveRoom:
window.uiState.page === "Pages/Chat/Chat.qml" &&
window.uiState.pageProperties.userId === userId
readonly property var activeRoomIndex:
hasActiveRoom ?
model.findIndex(window.uiState.pageProperties.roomId) : null
Binding on currentIndex { Binding on currentIndex {
value: value:
window.uiState.page === "Pages/Chat/Chat.qml" && roomList.hasActiveRoom ?
window.uiState.pageProperties.userId === userId ? (
roomList.activeRoomIndex === null ?
roomList.model.findIndex(window.uiState.pageProperties.roomId) -1 : roomList.activeRoomIndex
|| -1 : ) : -1
-1
when: ! view.detachedCurrentIndex when: ! view.detachedCurrentIndex
} }

View File

@ -59,6 +59,15 @@ HListView {
readonly property Room selectedRoom: readonly property Room selectedRoom:
currentItem ? currentItem.roomList.currentItem : null currentItem ? currentItem.roomList.currentItem : null
readonly property bool hasActiveAccount:
window.uiState.page === "Pages/Chat/Chat.qml" ||
window.uiState.page === "Pages/AddChat/AddChat.qml" ||
window.uiState.page === "Pages/AccountSettings/AccountSettings.qml"
readonly property var activeAccountIndex:
hasActiveAccount ?
model.findIndex(window.uiState.pageProperties.userId) : null
function previous() { function previous() {
detachedCurrentIndex = true detachedCurrentIndex = true
@ -198,14 +207,8 @@ HListView {
Binding on currentIndex { Binding on currentIndex {
value: value:
[ hasActiveAccount ?
"Pages/Chat/Chat.qml", (activeAccountIndex === null ? -1 : activeAccountIndex) : -1
"Pages/AddChat/AddChat.qml",
"Pages/AccountSettings/AccountSettings.qml",
].includes(window.uiState.page) ?
model.findIndex(window.uiState.pageProperties.userId) || -1 :
-1
when: ! detachedCurrentIndex when: ! detachedCurrentIndex
} }