Fix timeline occasionally breaking on room switch

When a chat page is recycled, set the eventList model to
null, wait for any animations to finish, then explicitely reassign it.
This prevents from model from randomly mixing up old and news delegates.
This commit is contained in:
miruka 2020-11-10 21:47:35 -04:00
parent 9ef13c9d50
commit ce3ed86bef

View File

@ -11,6 +11,9 @@ import "../../../PythonBridge"
import "../../../ShortcutBundles"
Rectangle {
readonly property var modelSyncId:
[chat.userRoomId[0], chat.userRoomId[1], "events"]
readonly property alias eventList: eventList
readonly property alias contextMenu: contextMenu
@ -512,7 +515,6 @@ Rectangle {
// reloaded from network.
cacheBuffer: Screen.desktopAvailableHeight * 2
model: ModelStore.get(chat.userRoomId[0], chat.userRoomId[1], "events")
delegate: EventDelegate {}
highlight: Rectangle {
@ -555,6 +557,21 @@ Rectangle {
}
}
Connections {
target: pageLoader
onRecycled: {
eventList.model = null
updateModelTimer.restart()
}
}
Timer {
id: updateModelTimer
interval: pageLoader.appearAnimation.duration / 2
running: true
onTriggered: eventList.model = ModelStore.get(modelSyncId)
}
Timer {
interval: 200
running: