diff --git a/src/python/matrix_client.py b/src/python/matrix_client.py index 31de70d9..cc2f3baa 100644 --- a/src/python/matrix_client.py +++ b/src/python/matrix_client.py @@ -817,6 +817,9 @@ class MatrixClient(nio.AsyncClient): if not self.first_sync_done.is_set(): return + if room.room_id not in self.models[Room, self.user_id]: + return + self.models[Room, self.user_id][room.room_id].typing_members = sorted( room.user_name(user_id) for user_id in ev.users if user_id not in self.backend.clients diff --git a/src/qml/Chat/Banners/LeftBanner.qml b/src/qml/Chat/Banners/LeftBanner.qml index 98922f05..210a9cdc 100644 --- a/src/qml/Chat/Banners/LeftBanner.qml +++ b/src/qml/Chat/Banners/LeftBanner.qml @@ -24,19 +24,16 @@ Banner { forget: button => { Utils.makePopup( "Popups/ForgetRoomPopup.qml", - chatPage, + mainUI, // Must not be destroyed with chatPage { - userId: chatPage.userId, - roomId: chatPage.roomId, - roomName: chatPage.roomInfo.display_name, - forgottenCallback: () => { - button.loading = false - Qt.callLater(pageLoader.showPage, "Default") - }, + userId: chatPage.userId, + roomId: chatPage.roomId, + roomName: chatPage.roomInfo.display_name, }, obj => { obj.onOk.connect(() => { button.loading = true }) }, + false, ) } }) diff --git a/src/qml/Popups/ForgetRoomPopup.qml b/src/qml/Popups/ForgetRoomPopup.qml index 15637544..ef095a74 100644 --- a/src/qml/Popups/ForgetRoomPopup.qml +++ b/src/qml/Popups/ForgetRoomPopup.qml @@ -1,6 +1,7 @@ import QtQuick 2.12 BoxPopup { + id: popup summary.text: qsTr("Leave %1 and discard the history?").arg(roomName) details.text: qsTr( "You will not be able to see the messages you received in " + @@ -12,11 +13,23 @@ BoxPopup { okText: qsTr("Forget") box.focusButton: "ok" - onOk: py.callClientCoro(userId, "room_forget", [roomId], forgottenCallback) + onOk: py.callClientCoro(userId, "room_forget", [roomId], () => { + if (window.uiState.page == "Chat/Chat.qml" && + window.uiState.pageProperties.userId == userId && + window.uiState.pageProperties.roomId == roomId) + { + pageLoader.showPage("Default") + Qt.callLater(popup.destroy) + } + }) + + onCancel: canDestroy = true + onClosed: if (canDestroy) Qt.callLater(popup.destroy) property string userId: "" property string roomId: "" property string roomName: "" - property var forgottenCallback: null + + property bool canDestroy: false } diff --git a/src/qml/SidePane/RoomDelegate.qml b/src/qml/SidePane/RoomDelegate.qml index b494c404..b019b961 100644 --- a/src/qml/SidePane/RoomDelegate.qml +++ b/src/qml/SidePane/RoomDelegate.qml @@ -131,7 +131,9 @@ HTileDelegate { userId: model.user_id, roomId: model.data.room_id, roomName: model.data.display_name, - } + }, + null, + false, ) } } diff --git a/src/qml/utils.js b/src/qml/utils.js index e0d9d3eb..2764a103 100644 --- a/src/qml/utils.js +++ b/src/qml/utils.js @@ -31,11 +31,12 @@ function makeObject(url, parent=null, properties={}, callback=null) { } -function makePopup(url, parent=null, properties={}, callback=null) { +function makePopup(url, parent=null, properties={}, callback=null, + autoDestruct=true) { makeObject(url, parent, properties, (popup) => { popup.open() - popup.closed.connect(() => { popup.destroy() }) - if (callback) callback(popup) + if (autoDestruct) popup.closed.connect(() => { popup.destroy() }) + if (callback) callback(popup) }) }