-
Notifications
You must be signed in to change notification settings - Fork 1
feat: support RN app migration #290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,7 +54,7 @@ | |
| } | ||
| } | ||
| await MainActor.run { | ||
| self.cachedTxIdsInBoostTxIds = txIds | ||
| } | ||
| } catch { | ||
| Logger.error("Failed to refresh boostTxIds cache: \(error)", context: "ActivityService") | ||
|
|
@@ -109,7 +109,7 @@ | |
|
|
||
| func isActivitySeen(id: String) async -> Bool { | ||
| do { | ||
| if let activity = try await getActivityById(activityId: id) { | ||
| switch activity { | ||
| case let .onchain(onchain): | ||
| return onchain.seenAt != nil | ||
|
|
@@ -154,6 +154,42 @@ | |
| } | ||
| } | ||
|
|
||
| func markAllUnseenActivitiesAsSeen() async { | ||
| let timestamp = UInt64(Date().timeIntervalSince1970) | ||
|
|
||
| do { | ||
| let activities = try await get() | ||
| var didMarkAny = false | ||
|
|
||
| for activity in activities { | ||
| let id: String | ||
| let isSeen: Bool | ||
|
|
||
| switch activity { | ||
| case let .onchain(onchain): | ||
| id = onchain.id | ||
| isSeen = onchain.seenAt != nil | ||
| case let .lightning(lightning): | ||
| id = lightning.id | ||
| isSeen = lightning.seenAt != nil | ||
| } | ||
|
|
||
| if !isSeen { | ||
| try await ServiceQueue.background(.core) { | ||
| try BitkitCore.markActivityAsSeen(activityId: id, seenAt: timestamp) | ||
| } | ||
|
Comment on lines
+178
to
+180
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: maybe could apply some parallelization in case the wallet has many activities, but I'm not sure if it would make a big difference |
||
| didMarkAny = true | ||
| } | ||
| } | ||
|
|
||
| if didMarkAny { | ||
| activitiesChangedSubject.send() | ||
| } | ||
| } catch { | ||
| Logger.error("Failed to mark all activities as seen: \(error)", context: "ActivityService") | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Transaction Status Checks | ||
|
|
||
| func wasTransactionReplaced(txid: String) async -> Bool { | ||
|
|
@@ -582,7 +618,7 @@ | |
| } | ||
|
|
||
| private func processLightningPayment(_ payment: PaymentDetails) async throws { | ||
| guard case let .bolt11(hash, preimage, secret, description, bolt11) = payment.kind else { return } | ||
|
Check warning on line 621 in Bitkit/Services/CoreService.swift
|
||
|
|
||
| // Skip pending inbound payments - just means they created an invoice | ||
| guard !(payment.status == .pending && payment.direction == .inbound) else { return } | ||
|
|
@@ -635,7 +671,7 @@ | |
|
|
||
| for payment in payments { | ||
| do { | ||
| let state: BitkitCore.PaymentState = switch payment.status { | ||
| case .failed: | ||
| .failed | ||
| case .pending: | ||
|
|
@@ -671,7 +707,7 @@ | |
| latestCaughtError = error | ||
| } | ||
| } | ||
| } catch { | ||
| Logger.error("Error syncing LDK payment: \(error)", context: "CoreService") | ||
| latestCaughtError = error | ||
| } | ||
|
|
@@ -705,7 +741,7 @@ | |
| /// Check if a transaction spends a closed channel's funding UTXO | ||
| private func findClosedChannelForTransaction(txid: String, transactionDetails: BitkitCore.TransactionDetails? = nil) async -> String? { | ||
| do { | ||
| let closedChannels = try await getAllClosedChannels(sortDirection: .desc) | ||
| guard !closedChannels.isEmpty else { return nil } | ||
|
|
||
| let details = if let provided = transactionDetails { provided } else { await fetchTransactionDetails(txid: txid) } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.