Skip to content

Commit

Permalink
Merge pull request #537 from Adamant-im/dev/trello.com/c/Xo1trmii
Browse files Browse the repository at this point in the history
[trello.com/c/Xo1trmii] fix: lost transactions
  • Loading branch information
IanaaDvlp authored Oct 28, 2024
2 parents 57efc18 + e233578 commit 83805d1
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Adamant/Services/DataProviders/AdamantAccountsProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -256,17 +256,15 @@ extension AdamantAccountsProvider {
account.isDummy = true
let coreAccount = createAndSaveCoreDataAccount(
from: account,
dummy: dummy,
in: stack.container.viewContext
dummy: dummy
)

return coreAccount
}

let coreAccount = createAndSaveCoreDataAccount(
from: account,
dummy: dummy,
in: stack.container.viewContext
dummy: dummy
)

return coreAccount
Expand Down Expand Up @@ -387,15 +385,17 @@ extension AdamantAccountsProvider {

private func createAndSaveCoreDataAccount(
from account: AdamantAccount,
dummy: DummyAccount?,
in context: NSManagedObjectContext
dummy: DummyAccount?
) -> CoreDataAccount {
let result = getAccount(byPredicate: NSPredicate(format: "address == %@", account.address))
if case .core(let account) = result {
return account
}

let coreAccount = createCoreDataAccount(from: account, context: context)
let privateContext = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
privateContext.parent = stack.container.viewContext

let coreAccount = createCoreDataAccount(from: account, context: privateContext)

coreAccount.isDummy = account.isDummy

Expand All @@ -411,10 +411,10 @@ extension AdamantAccountsProvider {
chatroom.updateLastTransaction()
}
}
context.delete(dummy)
privateContext.delete(dummy)
}

try? context.save()
try? privateContext.save()
return coreAccount
}

Expand Down

0 comments on commit 83805d1

Please sign in to comment.