fix scroll: use named Timer instead of Timer.singleShot (scope issue)

This commit is contained in:
Levi Neely 2026-08-01 10:23:24 +02:00
parent 50c3b5979c
commit 95d6da75f6
1 changed files with 14 additions and 12 deletions

View File

@ -59,12 +59,21 @@ ApplicationWindow {
palette.disabled.light: theme.lightColor
palette.disabled.shadow: theme.shadowColor
// Deferred scroll timer — fires once after model changes settle
Timer {
id: scrollTimer
interval: 0
repeat: false
onTriggered: chatView.positionViewAtEnd()
}
Component.onCompleted: {
var log = ollie.readLog()
if (log) {
chatModel.appendData(log)
chatModel.trimFront(30)
}
scrollTimer.start()
}
Connections {
@ -76,6 +85,7 @@ ApplicationWindow {
chatModel.appendData(log)
chatModel.trimFront(30)
}
scrollTimer.start()
}
function onStreamingDone() {
chatModel.appendData("\n[info]\nsession ended\n")
@ -313,23 +323,15 @@ ApplicationWindow {
boundsBehavior: Flickable.StopAtBounds
onCountChanged: {
if (count > 0) {
var idx = count - 1
Timer.singleShot(0, function() {
positionViewAtIndex(idx, ListView.End)
})
}
if (count > 0)
scrollTimer.start()
}
Connections {
target: chatModel
function onDataChanged() {
if (chatView.atYEnd && chatView.count > 0) {
var idx = chatView.count - 1
Timer.singleShot(0, function() {
chatView.positionViewAtIndex(idx, ListView.End)
})
}
if (chatView.atYEnd && chatView.count > 0)
scrollTimer.start()
}
}