Reset room pane state when recycling chat page

Side effect: the members filter field's text is no longer saved to disk
This commit is contained in:
miruka 2020-09-03 17:59:48 -04:00
parent 601b42a503
commit 2545ba6c00
6 changed files with 36 additions and 14 deletions

View File

@ -15,6 +15,7 @@ HLoader {
property var history: [] property var history: []
property int historyLength: 20 property int historyLength: 20
signal aboutToRecycle()
signal recycled() signal recycled()
signal previousShown(string componentUrl, var properties) signal previousShown(string componentUrl, var properties)
@ -28,6 +29,8 @@ HLoader {
item item
if (recycle) { if (recycle) {
aboutToRecycle()
for (const [prop, value] of Object.entries(properties)) for (const [prop, value] of Object.entries(properties))
item[prop] = value item[prop] = value
@ -55,20 +58,16 @@ HLoader {
return true return true
} }
function closeMainPane() {
if (mainPane.collapse) mainPane.close()
}
function takeFocus() { function takeFocus() {
pageLoader.item.forceActiveFocus() pageLoader.item.forceActiveFocus()
closeMainPane() if (mainPane.collapse) mainPane.close()
} }
clip: appearAnimation.running clip: appearAnimation.running
onLoaded: { takeFocus(); appearAnimation.restart() } onLoaded: { takeFocus(); appearAnimation.restart() }
onRecycled: { closeMainPane(); appearAnimation.restart() } onRecycled: { takeFocus(); appearAnimation.restart() }
Component.onCompleted: { Component.onCompleted: {
if (! py.startupAnyAccountsSaved) { if (! py.startupAnyAccountsSaved) {

View File

@ -22,8 +22,6 @@ Item {
property string replyToUserId: "" property string replyToUserId: ""
property string replyToDisplayName: "" property string replyToDisplayName: ""
readonly property string pageIdentity: userId + "/" + roomId
readonly property alias loader: loader readonly property alias loader: loader
readonly property alias roomPane: roomPaneLoader.item readonly property alias roomPane: roomPaneLoader.item
@ -39,7 +37,6 @@ Item {
} }
onPageIdentityChanged: if (roomPane) roomPane.appearAnimation.restart()
onFocusChanged: if (focus && loader.item) loader.item.composer.takeFocus() onFocusChanged: if (focus && loader.item) loader.item.composer.takeFocus()
onReadyChanged: longLoading = false onReadyChanged: longLoading = false
@ -127,6 +124,11 @@ Item {
factor: 2 factor: 2
running: true running: true
} }
Connections {
target: pageLoader
function onRecycled() { roomPane.appearAnimation.restart() }
}
} }
} }
} }

View File

@ -14,6 +14,15 @@ HColumnLayout {
readonly property alias filterField: filterField readonly property alias filterField: filterField
Connections {
target: pageLoader
function onAboutToRecycle() {
stackView.pop(stackView.initialItem)
filterField.reset()
}
}
HStackView { HStackView {
id: stackView id: stackView
@ -79,8 +88,6 @@ HColumnLayout {
HTextField { HTextField {
id: filterField id: filterField
saveName: "memberFilterField"
saveId: chat.roomId
backgroundColor: backgroundColor:
theme.chat.roomPane.bottomBar.filterMembers.background theme.chat.roomPane.bottomBar.filterMembers.background

View File

@ -90,11 +90,20 @@ MultiviewPane {
target: swipeView target: swipeView
function onCurrentItemChanged() { function onCurrentItemChanged() {
swipeView.currentItem.keybindFocusItem.forceActiveFocus() roomPane.swipeView.currentItem.keybindFocusItem.forceActiveFocus()
}
}
Connections {
target: pageLoader
function onAboutToRecycle() {
roomPane.swipeView.currentIndex = 0
} }
} }
MemberView {} MemberView {}
SettingsView { SettingsView {
enabled: accountModel.presence !== "offline" enabled: accountModel.presence !== "offline"
} }

View File

@ -80,6 +80,11 @@ HFlickableColumnPage {
onKeyboardAccept: if (applyButton.enabled) applyButton.clicked() onKeyboardAccept: if (applyButton.enabled) applyButton.clicked()
onKeyboardCancel: cancel() onKeyboardCancel: cancel()
Connections {
target: pageLoader
function onAboutToRecycle() { cancel() }
}
HRoomAvatar { HRoomAvatar {
id: avatar id: avatar
clientUserId: chat.userId clientUserId: chat.userId

View File

@ -576,8 +576,8 @@ Rectangle {
} }
Connections { Connections {
target: chat target: pageLoader
function onPageIdentityChanged() { eventList.moreToLoad = true } function onRecycled() { eventList.moreToLoad = true }
} }
} }