Reset composer when recycling chat page

This commit is contained in:
miruka 2020-09-03 18:30:36 -04:00
parent 82bcc29475
commit 99ae075bb4
3 changed files with 19 additions and 6 deletions

View File

@ -38,6 +38,10 @@ TextArea {
text = Qt.binding(() => defaultText || "") text = Qt.binding(() => defaultText || "")
} }
function loadState() {
if (! text) insertAtCursor(window.getState(this, "text", ""))
}
function insertAtCursor(text) { function insertAtCursor(text) {
insert(cursorPosition, text) insert(cursorPosition, text)
} }
@ -87,9 +91,7 @@ TextArea {
Component.onCompleted: { Component.onCompleted: {
// Break binding // Break binding
previousDefaultText = previousDefaultText previousDefaultText = previousDefaultText
loadState()
// Set it only on component creation to avoid binding loops
if (! text) insertAtCursor(window.getState(this, "text", ""))
} }
onTextChanged: window.saveState(this) onTextChanged: window.saveState(this)

View File

@ -34,6 +34,10 @@ TextField {
text = Qt.binding(() => defaultText || "") text = Qt.binding(() => defaultText || "")
} }
function loadState() {
if (! text) insertAtCursor(window.getState(this, "text", ""))
}
function insertAtCursor(text) { function insertAtCursor(text) {
insert(cursorPosition, text) insert(cursorPosition, text)
} }
@ -74,9 +78,7 @@ TextField {
Component.onCompleted: { Component.onCompleted: {
// Break binding // Break binding
previousDefaultText = previousDefaultText previousDefaultText = previousDefaultText
loadState()
// Set it only on component creation to avoid binding loops
if (! text) insertAtCursor(window.getState(this, "text", ""))
} }
onTextChanged: window.saveState(this) onTextChanged: window.saveState(this)

View File

@ -245,4 +245,13 @@ HTextArea {
// ) // )
// } // }
} }
Connections {
target: pageLoader
function onRecycled() {
area.reset()
area.loadState()
}
}
} }