jump to next attention item
This commit is contained in:
@@ -337,14 +337,27 @@ final class ChatModel {
|
||||
return groups
|
||||
}
|
||||
|
||||
var held: Int? {
|
||||
var attentionRows: [Int] {
|
||||
let ids = Set(attention().flatMap(\.rows))
|
||||
guard let first = builder.root.rows.first(where: { ids.contains($0.id) })?.id, first != released else {
|
||||
return builder.root.rows.filter { ids.contains($0.id) }.map(\.id)
|
||||
}
|
||||
|
||||
var held: Int? {
|
||||
guard let first = attentionRows.first, first != released else {
|
||||
return nil
|
||||
}
|
||||
return first
|
||||
}
|
||||
|
||||
func closed(_ old: [Int], _ new: [Int]) {
|
||||
guard let gone = old.first(where: { !new.contains($0) }), let first = new.first else {
|
||||
return
|
||||
}
|
||||
let rows = builder.root.rows
|
||||
let at = rows.firstIndex { $0.id == gone } ?? rows.endIndex
|
||||
scrollTo(rows[at...].first { new.contains($0.id) }?.id ?? first)
|
||||
}
|
||||
|
||||
func release() {
|
||||
released = held ?? released
|
||||
}
|
||||
@@ -812,6 +825,9 @@ private struct TranscriptScroll: View {
|
||||
position.scrollTo(edge: .bottom)
|
||||
}
|
||||
}
|
||||
.onChange(of: model.attentionRows) { old, new in
|
||||
model.closed(old, new)
|
||||
}
|
||||
.onChange(of: model.older == nil) {
|
||||
if !scrolling {
|
||||
model.prependOlder()
|
||||
|
||||
Reference in New Issue
Block a user