field_ios

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

TeraAddStartupSnapshot.swift (1015B)


      1 struct TeraAddStartupSnapshot {
      2   let schemas: [TeraAddSchema]
      3   let drafts: [TeraDraftStatus]
      4   let support: TeraAddMediaSupport
      5   let mediaMessage: String?
      6 
      7   @MainActor
      8   static func load(
      9     client: TeraRuntimeClient, support: @MainActor () async throws -> TeraAddMediaSupport,
     10     ready: @MainActor ([TeraAddSchema]) -> Void
     11   ) async throws -> Self {
     12     let schemas = try await TeraProductSurfaceContract.validate(schemas: client.addSchemas())
     13     // Presentation and scoped editing recovery start before optional legacy or
     14     // media work. A media failure cannot make a valid composer unavailable.
     15     ready(schemas)
     16     async let draftResult = try? client.draftHeads(limit: 100)
     17     async let supportResult = try? support()
     18     let (drafts, support) = await (draftResult, supportResult)
     19     return Self(schemas: schemas, drafts: drafts ?? [], support: support ?? .unavailable,
     20                 mediaMessage: support == nil ? "Photo support is unavailable. Saved editing is still available." : nil)
     21   }
     22 }