Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Bitkit/AppScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ struct AppScene: View {
PaykitFeatureFlags.enforceBuildAvailability()
ContactPaymentsService.enableAllPaymentOptions()

_app = StateObject(wrappedValue: AppViewModel(sheetViewModel: sheetViewModel, navigationViewModel: navigationViewModel))
_app = StateObject(wrappedValue: AppViewModel(
sheetViewModel: sheetViewModel,
navigationViewModel: navigationViewModel
))
_sheets = StateObject(wrappedValue: sheetViewModel)
_navigation = StateObject(wrappedValue: navigationViewModel)
let feeEstimatesManager = FeeEstimatesManager()
Expand Down Expand Up @@ -878,6 +881,10 @@ struct AppScene: View {
wallet.resetSendState(speed: settings.defaultTransactionSpeed)
return
}
} catch ScanHandlingError.pubkyAuthRequest {
guard paykitPaymentRequestManager.isCurrentPresentation(request) else { return }
_ = paykitPaymentRequestManager.markPresentedIfPending(request)
continue
} catch is CancellationError {
if app.ownsContactPaymentContext(contactPaymentContext) {
app.resetSendState()
Expand Down
46 changes: 46 additions & 0 deletions Bitkit/MainNavView.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
import SwiftUI

enum PendingProfileSetupResumeState {
case inactive
case waiting
case ready

func shouldResume(didResume: inout Bool) -> Bool {
if self == .inactive {
didResume = false
}
guard self == .ready, !didResume else { return false }
didResume = true
return true
}
}

func resolvePendingProfileSetupResumeState(
isProfileSetupPending: Bool,
isPaykitUIActive: Bool,
isAuthenticated: Bool,
hasActiveSheet: Bool,
isReplacingSheet: Bool,
currentRoute: Route?
) -> PendingProfileSetupResumeState {
guard isProfileSetupPending else { return .inactive }
guard isPaykitUIActive, isAuthenticated, !hasActiveSheet, !isReplacingSheet, currentRoute != .createProfile else {
return .waiting
}
return .ready
}

struct MainNavView: View {
@AppStorage(PaykitFeatureFlags.uiEnabledKey) private var isPaykitUIEnabled = false

Expand All @@ -20,11 +50,23 @@ struct MainNavView: View {

@State private var showClipboardAlert = false
@State private var clipboardUri: String?
@State private var didResumePendingPubkyProfileSetup = false

private var isPaykitUIActive: Bool {
PaykitFeatureFlags.isUIAvailable && isPaykitUIEnabled
}

private var pendingProfileSetupResumeState: PendingProfileSetupResumeState {
Comment thread
ovitrif marked this conversation as resolved.
resolvePendingProfileSetupResumeState(
isProfileSetupPending: pubkyProfile.isProfileSetupPending,
isPaykitUIActive: isPaykitUIActive,
isAuthenticated: pubkyProfile.isAuthenticated,
hasActiveSheet: sheets.activeSheetConfiguration != nil,
isReplacingSheet: sheets.isReplacingSheet,
currentRoute: navigation.currentRoute
)
}

// Delay constants for clipboard processing
private static let nodeReadyDelayNanoseconds: UInt64 = 500_000_000 // 0.5 seconds
private static let statePropagationDelayNanoseconds: UInt64 = 500_000_000 // 0.5 seconds
Expand All @@ -39,6 +81,10 @@ struct MainNavView: View {
navigation.navigate(.spendingHwSigned)
}
}
.onChange(of: pendingProfileSetupResumeState, initial: true) { _, resumeState in
guard resumeState.shouldResume(didResume: &didResumePendingPubkyProfileSetup) else { return }
navigation.navigate(.createProfile)
}
.sheet(
item: $sheets.addTagSheetItem,
onDismiss: {
Expand Down
Loading
Loading