ζ-3.5b: Pending-Queue-UI + NWPathMonitor-Reconnect-Flush
Pending-Queue-UI: - AccountView.pendingQueueCard listet alle wartenden Submissions mit Text-Preview (120c), Author, createdAt, retryCount, lastError - "Jetzt versuchen"-Button triggert tryFlush(api:) - Trash-Icon pro Row löscht einzeln aus der Queue - Pull-to-Refresh aktualisiert beide Listen - Card-View nur sichtbar wenn Queue-Tiefe > 0 ReachabilityWatcher: - NWPathMonitor erkennt Reconnect-Flanke (offline → online) - Bei Reconnect: SubmissionQueue.tryFlush auf @MainActor - Filtert reine Wifi↔Mobil-Switches raus (nur "wieder erreichbar" zählt) - Lebt im App-Root, startet nach Launch via .task Files: - Sources/Core/Submit/ReachabilityWatcher.swift (neu) - Sources/App/ZitareNativeApp.swift: reachability.start in .task - Sources/Features/Account/AccountView.swift: pendingQueueCard iOS + macOS BUILD SUCCEEDED. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
61927d27a3
commit
53f8043a2d
3 changed files with 148 additions and 0 deletions
|
|
@ -9,8 +9,12 @@ import SwiftUI
|
|||
struct AccountView: View {
|
||||
@Environment(AuthClient.self) private var auth
|
||||
@Environment(ManaAuthGate.self) private var authGate
|
||||
@Environment(SubmissionQueue.self) private var submissionQueue
|
||||
let healthStatus: HealthStatus
|
||||
|
||||
@State private var pendingEntries: [PendingSubmission] = []
|
||||
@State private var refreshTick: Int = 0
|
||||
|
||||
private var isSignedIn: Bool {
|
||||
if case .signedIn = auth.status { return true }
|
||||
return false
|
||||
|
|
@ -25,6 +29,10 @@ struct AccountView: View {
|
|||
|
||||
authActionCard
|
||||
|
||||
if !pendingEntries.isEmpty {
|
||||
pendingQueueCard
|
||||
}
|
||||
|
||||
Spacer(minLength: 32)
|
||||
|
||||
aboutCard
|
||||
|
|
@ -33,6 +41,86 @@ struct AccountView: View {
|
|||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.background(ZitareTheme.background)
|
||||
.task {
|
||||
reload()
|
||||
}
|
||||
.refreshable {
|
||||
reload()
|
||||
}
|
||||
}
|
||||
|
||||
private var pendingQueueCard: some View {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
HStack {
|
||||
Label("Offline-Warteschlange", systemImage: "tray.and.arrow.up")
|
||||
.font(.headline)
|
||||
Spacer()
|
||||
Button {
|
||||
Task {
|
||||
let api = ZitareAPI(auth: auth)
|
||||
_ = await submissionQueue.tryFlush(api: api)
|
||||
reload()
|
||||
}
|
||||
} label: {
|
||||
Label("Jetzt versuchen", systemImage: "arrow.clockwise")
|
||||
.font(.callout)
|
||||
}
|
||||
.tint(ZitareTheme.primary)
|
||||
}
|
||||
ForEach(pendingEntries) { entry in
|
||||
pendingRow(entry)
|
||||
if entry.id != pendingEntries.last?.id {
|
||||
Divider()
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.background(ZitareTheme.surface)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 12))
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 12)
|
||||
.stroke(ZitareTheme.border, lineWidth: 1)
|
||||
)
|
||||
}
|
||||
|
||||
private func pendingRow(_ entry: PendingSubmission) -> some View {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
Text(entry.text.prefix(120) + (entry.text.count > 120 ? "…" : ""))
|
||||
.font(.callout)
|
||||
.foregroundStyle(ZitareTheme.foreground)
|
||||
HStack(spacing: 8) {
|
||||
if let author = entry.authorName {
|
||||
Text(author)
|
||||
.font(.caption.weight(.medium))
|
||||
}
|
||||
Text(entry.createdAt, format: .dateTime.day().month().hour().minute())
|
||||
.font(.caption)
|
||||
if entry.retryCount > 0 {
|
||||
Text("· \(entry.retryCount) Versuch(e)")
|
||||
.font(.caption)
|
||||
}
|
||||
Spacer()
|
||||
Button(role: .destructive) {
|
||||
submissionQueue.delete(id: entry.id)
|
||||
reload()
|
||||
} label: {
|
||||
Image(systemName: "trash")
|
||||
.foregroundStyle(ZitareTheme.mutedForeground)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
.foregroundStyle(ZitareTheme.mutedForeground)
|
||||
if let err = entry.lastError {
|
||||
Text(err)
|
||||
.font(.caption)
|
||||
.foregroundStyle(ZitareTheme.error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func reload() {
|
||||
pendingEntries = submissionQueue.loadAll()
|
||||
refreshTick &+= 1
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue