taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

commit 74f3b4fa5ba0180602b1045ed4f5942668c8ffe4
parent 0759a398896ea6f00f74d0f70c3f22cd4a20a044
Author: Marc Stibane <marc@taler.net>
Date:   Mon, 10 Aug 2026 19:00:12 +0200

DbStatus when returning from background

Diffstat:
MTalerWallet1/Model/WalletModel.swift | 12++++++++----
MTalerWallet1/Views/Main/MainView.swift | 14+++++++++++++-
2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/TalerWallet1/Model/WalletModel.swift b/TalerWallet1/Model/WalletModel.swift @@ -166,9 +166,13 @@ final class WalletModel: ObservableObject, Sendable { } } // MARK: - +struct DbStatus: Decodable, Sendable { + var dbReadHealthy: Bool + var dbWriteHealthy: Bool +} /// A request to tell wallet-core about the network. fileprivate struct ApplicationResumedRequest: WalletBackendFormattedRequest { - struct Response: Decodable {} + typealias Response = DbStatus var operation: String { "hintApplicationResumed" } func args() -> Args { Args() } @@ -193,10 +197,10 @@ extension WalletModel { let request = NetworkAvailabilityRequest(isNetworkAvailable: isNetworkAvailable) _ = try? await sendRequest(request) } - func hintApplicationResumedT() async { + func hintApplicationResumedT() async throws -> DbStatus { // T for any Thread let request = ApplicationResumedRequest() - _ = try? await sendRequest(request) + return try await sendRequest(request) } } // MARK: - @@ -265,7 +269,7 @@ extension WalletModel { let _ = try await sendRequest(request) } nonisolated func retryProgressTokenNow(_ op: String, token: String) - async throws { + async throws { let request = RetryProgressTokenNow(op: op, token: token) let _ = try await sendRequest(request) } diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift @@ -68,7 +68,19 @@ struct MainView: View { func hintApplicationResumed() { Task.detached { - await model.hintApplicationResumedT() + if let result = try? await model.hintApplicationResumedT() { + if !result.dbReadHealthy { + let error = TalerErrorDetail(code: 53, // GENERIC_DB_FETCH_FAILED + when: .now(), + hint: "Can't read from database") + await model.setError(WalletBackendError.walletCoreError(error)) + } else if !result.dbWriteHealthy { + let error = TalerErrorDetail(code: 52, // GENERIC_DB_STORE_FAILED + when: .now(), + hint: "Can't write to database") + await model.setError(WalletBackendError.walletCoreError(error)) + } + } } }