Let a queued message be taken back into the composer
This commit is contained in:
@@ -135,6 +135,7 @@ struct PendingSend: Identifiable {
|
||||
let local: Bool
|
||||
let queued: Bool
|
||||
let md: [MDBlock]
|
||||
var inputId: Int? = nil
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@@ -231,6 +232,10 @@ final class TranscriptBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
func withdrawn(_ inputId: Int) {
|
||||
pending.removeAll { $0.inputId == inputId }
|
||||
}
|
||||
|
||||
private func confirmPending(_ text: String, queued: Bool, local: Bool) {
|
||||
let i = queued ? pending.firstIndex { !$0.local && $0.text == text } : nil
|
||||
if let i = i ?? (local ? pending.firstIndex { $0.local && $0.text == text } : nil) {
|
||||
@@ -417,7 +422,13 @@ final class TranscriptBuilder {
|
||||
confirmPending(text, queued: false, local: true)
|
||||
pendingIds += 1
|
||||
let images = (p["images"] as? [(any Sendable)?] ?? []).map { jsString($0) }
|
||||
pending.append(PendingSend(id: pendingIds, text: text, images: [], imageIds: images, local: false, queued: true, md: trimmed(text).isEmpty ? [] : parseMarkdown(text)))
|
||||
pending.append(PendingSend(id: pendingIds, text: text, images: [], imageIds: images, local: false, queued: true, md: trimmed(text).isEmpty ? [] : parseMarkdown(text), inputId: int(p, "id")))
|
||||
}
|
||||
continue
|
||||
}
|
||||
if ev.kind == "user.unqueued" {
|
||||
if sink == nil, let id = int(p, "id") {
|
||||
withdrawn(id)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user