field_ios

In-the-field app for Radroots on iOS
git clone https://radroots.dev/git/field_ios.git
Log | Files | Refs | README | LICENSE

TeraRestoreRecoverySection.swift (1900B)


      1 import SwiftUI
      2 
      3 struct TeraRestoreRecoverySection: View {
      4   @ObservedObject var store: TeraRestoreRecoveryStore
      5   @State private var confirmResume = false
      6 
      7   var body: some View {
      8     Group {
      9       if let status = store.status, status.phase != .resumed {
     10         Section("Restored work is paused") {
     11           Text("You can use local drafts while saved publications are checked. Nothing resumes just because a backup was restored.")
     12           Text("\(status.targets.filter { $0.observation == .observed }.count) destination checks found the original publication.")
     13           Text("\(status.targets.filter { $0.observation == .notObserved }.count) checks did not find it. This does not prove it was never received.")
     14           if status.targets.contains(where: { $0.observation == nil || $0.observation == .incomplete }) {
     15             Button("Check next destination") { Task { await store.checkNext() } }
     16           }
     17           Button("Review saved work") { Task { await store.review() } }
     18           if store.reviewedInventory != nil {
     19             Button("Resume original saved work…") { confirmResume = true }
     20           }
     21         }
     22         .disabled(store.isWorking)
     23         .accessibilityIdentifier("tera.restore.review")
     24       }
     25       if let message = store.message {
     26         Section("Restore recovery") {
     27           Text(message)
     28           Button("Check recovery status") { Task { await store.load() } }.disabled(store.isWorking)
     29         }
     30       }
     31     }
     32     .task { await store.load() }
     33     .confirmationDialog("Resume original saved work?", isPresented: $confirmResume, titleVisibility: .visible) {
     34       Button("Resume original saved work") { Task { await store.resume() } }
     35       Button("Keep paused", role: .cancel) {}
     36     } message: {
     37       Text("Destinations may already have received this work. Resuming keeps the original publication identities and saved destination policy.")
     38     }
     39   }
     40 }