Skip to content

Commit 1c412e3

Browse files
committed
Fixes
1 parent 9f99ffb commit 1c412e3

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Bitkit/Services/MigrationsService.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,9 +1199,13 @@ extension MigrationsService {
11991199
// MARK: - RN Remote Backup Restore
12001200

12011201
extension MigrationsService {
1202+
private func normalizePassphrase(_ passphrase: String?) -> String? {
1203+
passphrase?.isEmpty == true ? nil : passphrase
1204+
}
1205+
12021206
func hasRNRemoteBackup(mnemonic: String, passphrase: String?) async -> Bool {
12031207
do {
1204-
let effectivePassphrase = passphrase?.isEmpty == true ? nil : passphrase
1208+
let effectivePassphrase = normalizePassphrase(passphrase)
12051209
RNBackupClient.shared.reset()
12061210
try await RNBackupClient.shared.setup(mnemonic: mnemonic, passphrase: effectivePassphrase)
12071211
return try await RNBackupClient.shared.hasBackup()
@@ -1212,7 +1216,7 @@ extension MigrationsService {
12121216
}
12131217

12141218
func restoreFromRNRemoteBackup(mnemonic: String, passphrase: String?) async throws {
1215-
let effectivePassphrase = passphrase?.isEmpty == true ? nil : passphrase
1219+
let effectivePassphrase = normalizePassphrase(passphrase)
12161220
try await RNBackupClient.shared.setup(mnemonic: mnemonic, passphrase: effectivePassphrase)
12171221

12181222
isRestoringFromRNRemoteBackup = true

Bitkit/Services/RNBackupClient.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,11 @@ class RNBackupClient {
220220
else { continue }
221221

222222
let ts = UInt64(timestamp / 1000) // Convert ms to seconds
223-
if latestTimestamp == nil || ts > latestTimestamp! {
223+
if let latest = latestTimestamp {
224+
if ts > latest {
225+
latestTimestamp = ts
226+
}
227+
} else {
224228
latestTimestamp = ts
225229
}
226230
}

0 commit comments

Comments
 (0)