Faster switching of rooms from different accounts
Use a single [userId, roomId] property for the chat page. This gets read of the intermediate state where the userId property has been updated but the roomId one not yet, which led to the page unloading and reloading itself until both were properly set. Side-effect: when starting Mirage after this commit for the first time, the last saved page will not load and user must click a room or other page manually.
This commit is contained in:
parent
32679aa7f8
commit
6df9647b59
|
@ -19,10 +19,10 @@ HListView {
|
||||||
window.uiState.page === "Pages/Chat/Chat.qml"
|
window.uiState.page === "Pages/Chat/Chat.qml"
|
||||||
|
|
||||||
readonly property string wantedUserId:
|
readonly property string wantedUserId:
|
||||||
window.uiState.pageProperties.userId || ""
|
(window.uiState.pageProperties.userRoomId || [])[0] || ""
|
||||||
|
|
||||||
readonly property string wantedRoomId:
|
readonly property string wantedRoomId:
|
||||||
window.uiState.pageProperties.roomId || ""
|
(window.uiState.pageProperties.userRoomId || [])[1] || ""
|
||||||
|
|
||||||
readonly property var accountIndice: {
|
readonly property var accountIndice: {
|
||||||
const accounts = {}
|
const accounts = {}
|
||||||
|
|
|
@ -45,7 +45,7 @@ HLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
function showRoom(userId, roomId) {
|
function showRoom(userId, roomId) {
|
||||||
show("Pages/Chat/Chat.qml", {userId, roomId})
|
show("Pages/Chat/Chat.qml", {userRoomId: [userId, roomId]})
|
||||||
}
|
}
|
||||||
|
|
||||||
function showPrevious(timesBack=1) {
|
function showPrevious(timesBack=1) {
|
||||||
|
|
|
@ -9,19 +9,28 @@ import "RoomPane"
|
||||||
Item {
|
Item {
|
||||||
id: chat
|
id: chat
|
||||||
|
|
||||||
property string userId
|
// [userId, roomId] - Set this instead of changing the userId and roomId
|
||||||
property string roomId
|
// properties one by one, else QML has time to be in an invalid state
|
||||||
|
// between the two changes.
|
||||||
property QtObject userInfo: ModelStore.get("accounts").find(userId)
|
property var userRoomId
|
||||||
property QtObject roomInfo: ModelStore.get(userId, "rooms").find(roomId)
|
|
||||||
|
|
||||||
property bool ready: Boolean(userInfo && roomInfo)
|
|
||||||
property bool longLoading: false
|
|
||||||
|
|
||||||
property string replyToEventId: ""
|
property string replyToEventId: ""
|
||||||
property string replyToUserId: ""
|
property string replyToUserId: ""
|
||||||
property string replyToDisplayName: ""
|
property string replyToDisplayName: ""
|
||||||
|
|
||||||
|
property bool longLoading: false
|
||||||
|
|
||||||
|
readonly property string userId: userRoomId[0]
|
||||||
|
readonly property string roomId: userRoomId[1]
|
||||||
|
|
||||||
|
readonly property QtObject userInfo:
|
||||||
|
ModelStore.get("accounts").find(userRoomId[0])
|
||||||
|
|
||||||
|
readonly property QtObject roomInfo:
|
||||||
|
ModelStore.get(userRoomId[0], "rooms").find(userRoomId[1])
|
||||||
|
|
||||||
|
readonly property bool ready: Boolean(userInfo && roomInfo)
|
||||||
|
|
||||||
readonly property alias loader: loader
|
readonly property alias loader: loader
|
||||||
readonly property alias roomPane: roomPaneLoader.item
|
readonly property alias roomPane: roomPaneLoader.item
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import "../../../../Base"
|
||||||
HColumnLayout {
|
HColumnLayout {
|
||||||
readonly property alias keybindFocusItem: filterField
|
readonly property alias keybindFocusItem: filterField
|
||||||
readonly property var modelSyncId:
|
readonly property var modelSyncId:
|
||||||
[chat.userId, chat.roomId, "filtered_members"]
|
[chat.userRoomId[0], chat.userRoomId[1], "filtered_members"]
|
||||||
|
|
||||||
readonly property alias viewDepth: stackView.depth
|
readonly property alias viewDepth: stackView.depth
|
||||||
readonly property alias filterField: filterField
|
readonly property alias filterField: filterField
|
||||||
|
|
|
@ -201,8 +201,8 @@ Rectangle {
|
||||||
onActivated: window.makePopup(
|
onActivated: window.makePopup(
|
||||||
"Popups/ClearMessagesPopup.qml",
|
"Popups/ClearMessagesPopup.qml",
|
||||||
{
|
{
|
||||||
userId: window.uiState.pageProperties.userId,
|
userId: window.uiState.pageProperties.userRoomId[0],
|
||||||
roomId: window.uiState.pageProperties.roomId,
|
roomId: window.uiState.pageProperties.userRoomId[1],
|
||||||
preClearCallback: eventList.uncheckAll,
|
preClearCallback: eventList.uncheckAll,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -506,7 +506,7 @@ Rectangle {
|
||||||
// reloaded from network.
|
// reloaded from network.
|
||||||
cacheBuffer: Screen.desktopAvailableHeight * 2
|
cacheBuffer: Screen.desktopAvailableHeight * 2
|
||||||
|
|
||||||
model: ModelStore.get(chat.userId, chat.roomId, "events")
|
model: ModelStore.get(chat.userRoomId[0], chat.userRoomId[1], "events")
|
||||||
delegate: EventDelegate {}
|
delegate: EventDelegate {}
|
||||||
|
|
||||||
highlight: Rectangle {
|
highlight: Rectangle {
|
||||||
|
|
|
@ -16,8 +16,8 @@ HFlickableColumnPopup {
|
||||||
function forget() {
|
function forget() {
|
||||||
py.callClientCoro(userId, "room_forget", [roomId], () => {
|
py.callClientCoro(userId, "room_forget", [roomId], () => {
|
||||||
if (window.uiState.page === "Pages/Chat/Chat.qml" &&
|
if (window.uiState.page === "Pages/Chat/Chat.qml" &&
|
||||||
window.uiState.pageProperties.userId === userId &&
|
window.uiState.pageProperties.userRoomId[0] === userId &&
|
||||||
window.uiState.pageProperties.roomId === roomId)
|
window.uiState.pageProperties.userRoomId[1] === roomId)
|
||||||
{
|
{
|
||||||
window.mainUI.pageLoader.showPrevious() ||
|
window.mainUI.pageLoader.showPrevious() ||
|
||||||
window.mainUI.pageLoader.show("Pages/Default.qml")
|
window.mainUI.pageLoader.show("Pages/Default.qml")
|
||||||
|
|
|
@ -31,7 +31,10 @@ HFlickableColumnPopup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClosed: if (window.uiState.pageProperties.userId === userId) addAccount()
|
onClosed: if (
|
||||||
|
window.uiState.pageProperties.userId === userId ||
|
||||||
|
(window.uiState.pageProperties.userRoomId || [])[0] === userId
|
||||||
|
) addAccount()
|
||||||
|
|
||||||
SummaryLabel {
|
SummaryLabel {
|
||||||
text: qsTr("Signed out from %1").arg(coloredNameHtml("", userId))
|
text: qsTr("Signed out from %1").arg(coloredNameHtml("", userId))
|
||||||
|
|
|
@ -35,9 +35,13 @@ HFlickableColumnPopup {
|
||||||
icon.name: "sign-out"
|
icon.name: "sign-out"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (ModelStore.get("accounts").count < 2 ||
|
const showAdd =
|
||||||
window.uiState.pageProperties.userId === userId)
|
ModelStore.get("accounts").count < 2 ||
|
||||||
{
|
window.uiState.pageProperties.userId === userId ||
|
||||||
|
(window.uiState.pageProperties.userRoomId || [])[0] ===
|
||||||
|
userId
|
||||||
|
|
||||||
|
if (showAdd) {
|
||||||
const page = "Pages/AddAccount/AddAccount.qml"
|
const page = "Pages/AddAccount/AddAccount.qml"
|
||||||
window.mainUI.pageLoader.show(page)
|
window.mainUI.pageLoader.show(page)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user