Questions tab, question bubbles, answer snapshots; errors to transcript
This commit is contained in:
@@ -41,23 +41,6 @@ final class Notifier: NSObject, UNUserNotificationCenterDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
private func wants(_ p: NotificationPrefs, _ item: InboxItem) -> Bool {
|
||||
switch item.kind {
|
||||
case .question: p.questions
|
||||
case .sessionError: p.errors
|
||||
case .rateLimited: p.rateLimits
|
||||
}
|
||||
}
|
||||
|
||||
private func itemText(_ item: InboxItem) -> String {
|
||||
let p = item.payload.value
|
||||
switch item.kind {
|
||||
case .question: return str(p, "question") ?? ""
|
||||
case .sessionError: return "Error: \(str(p, "error") ?? "")"
|
||||
case .rateLimited: return "Rate limited"
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private var queue: Task<Void, Never>?
|
||||
|
||||
@@ -94,10 +77,22 @@ private func show(_ store: Store, _ taskId: String, _ tag: String, _ text: Strin
|
||||
|
||||
@MainActor
|
||||
func notifyInbox(_ store: Store, _ item: InboxItem) {
|
||||
guard let me = store.me, wants(me.notificationPrefs, item) else {
|
||||
guard let me = store.me, me.notificationPrefs.questions else {
|
||||
return
|
||||
}
|
||||
show(store, item.taskId, item.id, itemText(item))
|
||||
show(store, item.taskId, item.id, str(item.payload.value, "question") ?? "")
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func notifyError(_ store: Store, _ ev: ByreEvent) {
|
||||
guard let me = store.me, let taskId = ev.taskId, !taskId.isEmpty else {
|
||||
return
|
||||
}
|
||||
let limited = ev.kind == "session.rate_limited"
|
||||
if !(limited ? me.notificationPrefs.rateLimits : me.notificationPrefs.errors) {
|
||||
return
|
||||
}
|
||||
show(store, taskId, "error-\(ev.seq)", limited ? "Rate limited" : "Error: \(str(ev.payload.value, "error") ?? "")")
|
||||
}
|
||||
|
||||
@MainActor
|
||||
|
||||
Reference in New Issue
Block a user