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
4 changes: 4 additions & 0 deletions Bitkit/AppScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -945,9 +945,11 @@ struct AppScene: View {
}
if wallet.walletExists == true {
Task {
async let sessionRecovery: Void = network.isConnected ? pubkyProfile.restoreSessionIfNeeded() : ()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low severity. While restoration keeps failing, "Profile Disconnected" now fires on every foreground and every reconnect. The saved session is now kept on failure, so hasStoredIdentity() stays true. Each retry sets sessionRestorationFailed from false back to true (:228 → :262), and the onChange at :470 toasts each time. Steps: a Ring identity whose grant was revoked, or a wrong clock, where "session has expired" is also misleading. On reconnect it stacks with "Connection restored". Before this PR it fired once per launch.

Fix: announce only from startup or manual retries, e.g. an announceFailure: Bool that is false from restoreSessionIfNeeded.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automatic foreground and reconnect retries no longer set sessionRestorationFailed, so they do not repeat the Profile Disconnected notification. Startup and manual retries still report restoration failures.

await clearDeliveredNotifications()
await LightningService.shared.reconnectPeers()
try? await wallet.sync()
await sessionRecovery
await retryPendingPaykitEndpointRemoval()
await wallet.refreshPublicPaykitEndpointsOnForeground()
if PaykitFeatureFlags.isUIEnabled {
Expand Down Expand Up @@ -1371,7 +1373,9 @@ struct AppScene: View {
// Refresh currency rates when network is restored - critical for UI
// to display balances (MoneyText returns "0" if rates are nil)
Task {
async let sessionRecovery: Void = pubkyProfile.restoreSessionIfNeeded()
await currency.refresh()
await sessionRecovery
if scenePhase == .active {
await PubkyService.republishIdentityIfNeeded(publicKey: pubkyProfile.publicKey)
}
Expand Down
2 changes: 1 addition & 1 deletion Bitkit/Components/Header.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ struct Header: View {
return
}

if pubkyProfile.isAuthenticated || pubkyProfile.cachedName != nil {
if pubkyProfile.isAuthenticated {
navigation.navigate(.profile)
} else if pubkyProfile.initializationErrorMessage != nil {
navigation.navigate(.profile)
Expand Down
Loading
Loading