commit f5d399ef4239c5be20f7c9bb8d1ec8d1d14e87d8 parent d243328ba79f0b8b46017150631ac8ab5e1f2859 Author: Marc Stibane <marc@taler.net> Date: Thu, 18 Jan 2024 00:13:20 +0100 cleanup Diffstat:
7 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/TalerWallet1/Controllers/TalerWallet1App.swift b/TalerWallet1/Controllers/TalerWallet1App.swift @@ -104,7 +104,7 @@ final class ViewState : ObservableObject { @Published var rootViewId = UUID() let logger = Logger(subsystem: "net.taler.gnu", category: "ViewState") - public func popToRootView() -> Void { + public func popToRootView(_ stack: CallStack) -> Void { logger.info("popToRootView") rootViewId = UUID() // setting a new ID will cause tableView popToRootView behaviour } diff --git a/TalerWallet1/Quickjs/quickjs.swift b/TalerWallet1/Quickjs/quickjs.swift @@ -23,20 +23,21 @@ func logging_callback(userdata: Optional<UnsafeMutableRawPointer>, tag: Optional<UnsafePointer<Int8>>, message: Optional<UnsafePointer<Int8>>) { let native = Unmanaged<Quickjs>.fromOpaque(userdata!).takeUnretainedValue() + let logger = native.logger let theTag = String(cString: tag!) let theMessage = String(cString: message!) switch level { case TALER_WALLET_LOG_ERROR: - native.logger.error("\(theTag, privacy: .public) \(theMessage, privacy: .public)") + logger.error("\(theTag, privacy: .public) \(theMessage, privacy: .public)") case TALER_WALLET_LOG_WARN: - native.logger.warning("\(theTag, privacy: .public) \(theMessage, privacy: .public)") + logger.warning("\(theTag, privacy: .public) \(theMessage, privacy: .public)") case TALER_WALLET_LOG_MESSAGE: - native.logger.notice("\(theTag, privacy: .public) \(theMessage, privacy: .public)") + logger.notice("\(theTag, privacy: .public) \(theMessage, privacy: .public)") case TALER_WALLET_LOG_INFO: - native.logger.info("\(theTag, privacy: .public) \(theMessage, privacy: .public)") + logger.info("\(theTag, privacy: .public) \(theMessage, privacy: .public)") case TALER_WALLET_LOG_TRACE: - native.logger.trace("\(theTag, privacy: .public) \(theMessage, privacy: .public)") + logger.trace("\(theTag, privacy: .public) \(theMessage, privacy: .public)") default: break } } diff --git a/TalerWallet1/Views/Banking/ManualWithdrawDone.swift b/TalerWallet1/Views/Banking/ManualWithdrawDone.swift @@ -23,6 +23,9 @@ struct ManualWithdrawDone: View { func reloadOneAction(_ transactionId: String) async throws -> Transaction { return try await model.getTransactionByIdT(transactionId) } + func dismissTopAnimated(_ stack: CallStack) { + dismissTop() + } var body: some View { #if PRINT_CHANGES @@ -35,7 +38,7 @@ struct ManualWithdrawDone: View { transactionId: transactionId, reloadAction: reloadOneAction, navTitle: navTitle, - doneAction: ViewState.shared.popToRootView, + doneAction: dismissTopAnimated, // ViewState.shared.popToRootView, abortAction: nil, deleteAction: nil, failAction: nil, diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift @@ -221,13 +221,10 @@ extension MainView { .onChange(of: balances) { newArray in for balance in newArray { let scope = balance.scopeInfo - logger.info("balance changed: \(scope.currency, privacy: .public)") if controller.hasInfo(for: scope.currency) == nil { Task { // runs on MainActor -// logger.info("Task to get info for: \(scope.currency, privacy: .public)") do { let info = try await model.getCurrencyInfoM(scope: scope, delay: delay) -// logger.info("got info: \(scope.currency, privacy: .public)") await controller.setInfo(info) } catch { // TODO: error handling - couldn't get CurrencyInfo logger.error("Couldn't get info for: \(scope.currency, privacy: .public)\n\(error)") diff --git a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift @@ -22,7 +22,10 @@ struct P2pAcceptDone: View { func reloadOneAction(_ transactionId: String) async throws -> Transaction { return try await model.getTransactionByIdT(transactionId) } - + func dismissTopAnimated(_ stack: CallStack) { + dismissTop() + } + var body: some View { #if PRINT_CHANGES let _ = Self._printChanges() @@ -34,7 +37,7 @@ struct P2pAcceptDone: View { transactionId: transactionId, reloadAction: reloadOneAction, navTitle: navTitle, - doneAction: { dismissTop() }, + doneAction: dismissTopAnimated, abortAction: nil, deleteAction: nil, failAction: nil, diff --git a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptDone.swift b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptDone.swift @@ -22,6 +22,9 @@ struct WithdrawAcceptDone: View { func reloadOneAction(_ transactionId: String) async throws -> Transaction { return try await model.getTransactionByIdT(transactionId) } + func dismissTopAnimated(_ stack: CallStack) { + dismissTop() + } var body: some View { #if PRINT_CHANGES @@ -34,7 +37,7 @@ struct WithdrawAcceptDone: View { transactionId: transactionId, reloadAction: reloadOneAction, navTitle: navTitle, - doneAction: { dismissTop() }, + doneAction: dismissTopAnimated, abortAction: nil, deleteAction: nil, failAction: nil, diff --git a/TalerWallet1/Views/Transactions/TransactionDetailView.swift b/TalerWallet1/Views/Transactions/TransactionDetailView.swift @@ -27,7 +27,7 @@ struct TransactionDetailView: View { let transactionId: String let reloadAction: ((_ transactionId: String) async throws -> Transaction) let navTitle: String? - let doneAction: (() -> Void)? + let doneAction: ((_ stack: CallStack) -> Void)? let abortAction: ((_ transactionId: String) async throws -> Void)? let deleteAction: ((_ transactionId: String) async throws -> Void)? let failAction: ((_ transactionId: String) async throws -> Void)? @@ -71,7 +71,7 @@ struct TransactionDetailView: View { if let transition = notification.userInfo?[TRANSACTIONTRANSITION] as? TransactionTransition { if transition.transactionId == transaction.common.transactionId { // is the transition for THIS transaction? symLog.log(logStr) - doneAction() // if this view is in a sheet then dissmiss the sheet + doneAction(stack.push()) // if this view is in a sheet then dissmiss the sheet return true } } @@ -160,7 +160,7 @@ struct TransactionDetailView: View { action: deleteAction) } } // Delete button if let doneAction { - Button(transaction.shouldConfirm ? "Confirm later" : "Done", action: doneAction) + Button(transaction.shouldConfirm ? "Confirm later" : "Done", action: { doneAction(stack.push()) } ) .buttonStyle(TalerButtonStyle(type: transaction.shouldConfirm ? .bordered : .prominent)) } // Done button }.id(viewId) // change viewId to enforce a draw update