diff --git a/TODO.md b/TODO.md index 53947060..969622ef 100644 --- a/TODO.md +++ b/TODO.md @@ -2,7 +2,6 @@ ## Before release -- Fix highlighted account/room in MainPane - nio ClientTimeout - Default theme? - Name diff --git a/src/gui/MainPane/AccountRoomsDelegate.qml b/src/gui/MainPane/AccountRoomsDelegate.qml index 627c1730..e8d3d786 100644 --- a/src/gui/MainPane/AccountRoomsDelegate.qml +++ b/src/gui/MainPane/AccountRoomsDelegate.qml @@ -61,14 +61,22 @@ Column { 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 { value: - window.uiState.page === "Pages/Chat/Chat.qml" && - window.uiState.pageProperties.userId === userId ? - - roomList.model.findIndex(window.uiState.pageProperties.roomId) - || -1 : - -1 + roomList.hasActiveRoom ? + ( + roomList.activeRoomIndex === null ? + -1 : roomList.activeRoomIndex + ) : -1 when: ! view.detachedCurrentIndex } diff --git a/src/gui/MainPane/AccountRoomsList.qml b/src/gui/MainPane/AccountRoomsList.qml index d9dab4e6..c13c3508 100644 --- a/src/gui/MainPane/AccountRoomsList.qml +++ b/src/gui/MainPane/AccountRoomsList.qml @@ -59,6 +59,15 @@ HListView { readonly property Room selectedRoom: 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() { detachedCurrentIndex = true @@ -198,14 +207,8 @@ HListView { Binding on currentIndex { value: - [ - "Pages/Chat/Chat.qml", - "Pages/AddChat/AddChat.qml", - "Pages/AccountSettings/AccountSettings.qml", - ].includes(window.uiState.page) ? - - model.findIndex(window.uiState.pageProperties.userId) || -1 : - -1 + hasActiveAccount ? + (activeAccountIndex === null ? -1 : activeAccountIndex) : -1 when: ! detachedCurrentIndex }