Fix ForgetRoomPopup destruction/callback
This commit is contained in:
parent
3e01eeef71
commit
988ab94772
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
},
|
||||
},
|
||||
obj => {
|
||||
obj.onOk.connect(() => { button.loading = true })
|
||||
},
|
||||
false,
|
||||
)
|
||||
}
|
||||
})
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -131,7 +131,9 @@ HTileDelegate {
|
|||
userId: model.user_id,
|
||||
roomId: model.data.room_id,
|
||||
roomName: model.data.display_name,
|
||||
}
|
||||
},
|
||||
null,
|
||||
false,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,10 +31,11 @@ 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 (autoDestruct) popup.closed.connect(() => { popup.destroy() })
|
||||
if (callback) callback(popup)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user