Skip to content

Commit

Permalink
try fix freeze
Browse files Browse the repository at this point in the history
  • Loading branch information
DRadmir committed Oct 20, 2023
1 parent 6ef0c3a commit d1e5f30
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 38 deletions.
47 changes: 45 additions & 2 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
PODS:
- AppAuth (1.6.2):
- AppAuth/Core (= 1.6.2)
- AppAuth/ExternalUserAgent (= 1.6.2)
- AppAuth/Core (1.6.2)
- AppAuth/ExternalUserAgent (1.6.2):
- AppAuth/Core
- BigInt (5.2.0)
- Charts (4.1.0):
- Charts/Core (= 4.1.0)
Expand All @@ -19,6 +25,23 @@ PODS:
- Cuckoo/Swift (1.10.3)
- FearlessKeys (0.1.1)
- FireMock (3.1)
- GoogleAPIClientForREST/Core (1.2.1):
- GTMSessionFetcher (>= 1.1.7)
- GoogleAPIClientForREST/Drive (1.2.1):
- GoogleAPIClientForREST/Core
- GTMSessionFetcher (>= 1.1.7)
- GoogleSignIn (7.0.0):
- AppAuth (~> 1.5)
- GTMAppAuth (< 3.0, >= 1.3)
- GTMSessionFetcher/Core (< 4.0, >= 1.1)
- GTMAppAuth (2.0.0):
- AppAuth/Core (~> 1.6)
- GTMSessionFetcher/Core (< 4.0, >= 1.5)
- GTMSessionFetcher (3.1.1):
- GTMSessionFetcher/Full (= 3.1.1)
- GTMSessionFetcher/Core (3.1.1)
- GTMSessionFetcher/Full (3.1.1):
- GTMSessionFetcher/Core
- IrohaCrypto (0.10.0):
- IrohaCrypto/BIP39 (= 0.10.0)
- IrohaCrypto/blake2 (= 0.10.0)
Expand Down Expand Up @@ -123,6 +146,13 @@ PODS:
- SSFNetwork
- SSFRuntimeCodingService
- SSFUtils
- SSFCloudStorage (0.1.15):
- GoogleAPIClientForREST/Drive (~> 1.2.1)
- GoogleSignIn (~> 7.0.0)
- IrohaCrypto/Scrypt
- SSFModels
- SSFUtils
- TweetNacl (~> 1.0.0)
- SSFCrypto (0.1.17):
- IrohaCrypto/ed25519
- IrohaCrypto/Scrypt
Expand Down Expand Up @@ -232,6 +262,7 @@ DEPENDENCIES:
- Sourcery (~> 1.4)
- SSFChainConnection (= 0.1.4)
- SSFChainRegistry (= 0.1.4)
- SSFCloudStorage
- SSFCrypto (= 0.1.17)
- SSFEraKit
- SSFExtrinsicKit
Expand All @@ -252,13 +283,18 @@ DEPENDENCIES:
- XNetworking (from `https://raw.githubusercontent.com/soramitsu/x-networking/0.0.37/AppCommonNetworking/XNetworking/XNetworking.podspec`)

SPEC REPOS:
https://github.com/cocoapods/Specs.git:
https://github.com/CocoaPods/Specs.git:
- AppAuth
- BigInt
- Charts
- CocoaLumberjack
- CommonWallet
- Cuckoo
- FireMock
- GoogleAPIClientForREST
- GoogleSignIn
- GTMAppAuth
- GTMSessionFetcher
- IrohaCrypto
- keccak.c
- Kingfisher
Expand All @@ -284,6 +320,7 @@ SPEC REPOS:
- FearlessKeys
- SSFChainConnection
- SSFChainRegistry
- SSFCloudStorage
- SSFCrypto
- SSFEraKit
- SSFExtrinsicKit
Expand Down Expand Up @@ -322,13 +359,18 @@ CHECKOUT OPTIONS:
:tag: 4.0.8

SPEC CHECKSUMS:
AppAuth: 3bb1d1cd9340bd09f5ed189fb00b1cc28e1e8570
BigInt: f668a80089607f521586bbe29513d708491ef2f7
Charts: ce0768268078eee0336f122c3c4ca248e4e204c5
CocoaLumberjack: 5c7e64cdb877770859bddec4d3d5a0d7c9299df9
CommonWallet: 3c67d5fd85593a20f6b55777c2660ff886fc4148
Cuckoo: 930598bd4ae95860c658b3eea30903d946ebef36
FearlessKeys: 5248fbd49df75338e61901c89880ae4e9f99c054
FireMock: 3eed872059c12f94855413347da83b9d6d1a6fac
GoogleAPIClientForREST: a8b95a252014ce2e618df6b75dc72eca2c00b4af
GoogleSignIn: b232380cf495a429b8095d3178a8d5855b42e842
GTMAppAuth: 99fb010047ba3973b7026e45393f51f27ab965ae
GTMSessionFetcher: e8647203b65cee28c5f73d0f473d096653945e72
IrohaCrypto: eb3772088068d8938198205b62b0a9dc5b8ce005
keccak.c: 859583afdaccb4e4fcc0f0096064d101580313f4
Kingfisher: 1d14e9f59cbe19389f591c929000332bf70efd32
Expand All @@ -347,6 +389,7 @@ SPEC CHECKSUMS:
Sourcery: 179539341c2261068528cd15a31837b7238fd901
SSFChainConnection: 760f0bbe0d711cc0f184b951dea9e840a2962346
SSFChainRegistry: adfcfa6f8e7dae4730e258989c2a58ee674bf1e1
SSFCloudStorage: 37fbba3ad3e93a637d9c1a9b85910f4fa29596de
SSFCrypto: 7ea544e61213538744ef8fd075e5e4487b7cf502
SSFEraKit: a6f2a8bdefcdfa3ad8ff8f48b242000ea50744cd
SSFExtrinsicKit: f5ab32700622894d2e7a5fca254a3f659d3a6a9f
Expand All @@ -369,6 +412,6 @@ SPEC CHECKSUMS:
XNetworking: 516d982bd74ff208222381d27e07052a5d897aaf
xxHash-Swift: 30bd6a7507b3b7348a277c49b1cb6346c2905ec7

PODFILE CHECKSUM: 53383695a0656421c77d79fb7a06bd1be3926011
PODFILE CHECKSUM: c4e802ef4df1a83d5af2e0466c71b18abb869ed5

COCOAPODS: 1.11.3
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,21 @@ final class AlchemyNftFetchingService: BaseNftFetchingService {
throw AddressFactoryError.unexpectedAddress
}

return try await withCheckedThrowingContinuation { continuation in
let fetchNftsOperation = operationFactory.fetchNFTs(chain: chain, address: address)

fetchNftsOperation.targetOperation.completionBlock = {
do {
let nfts = try fetchNftsOperation.targetOperation.extractNoCancellableResultData()
continuation.resume(with: .success(nfts))
} catch {
continuation.resume(with: .failure(error))
}
}

self.operationQueue.addOperations(fetchNftsOperation.allOperations, waitUntilFinished: true)
}
return nil
// return try await withCheckedThrowingContinuation { continuation in
// let fetchNftsOperation = operationFactory.fetchNFTs(chain: chain, address: address)
//
// fetchNftsOperation.targetOperation.completionBlock = {
// do {
// let nfts = try fetchNftsOperation.targetOperation.extractNoCancellableResultData()
// continuation.resume(with: .success(nfts))
// } catch {
// continuation.resume(with: .failure(error))
// }
// }
//
// self.operationQueue.addOperations(fetchNftsOperation.allOperations, waitUntilFinished: true)
// }
}
}

Expand Down
7 changes: 2 additions & 5 deletions fearless/Common/ChainIssuesCenter/ChainIssuesCenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,8 @@ extension ChainsIssuesCenter: NetworkIssuesCenterListener {
}

extension ChainsIssuesCenter: EventVisitorProtocol {
func processSelectedAccountChanged(event _: SelectedAccountChanged) {
guard let wallet = SelectedWalletSettings.shared.value else {
return
}
self.wallet = wallet
func processSelectedAccountChanged(event: SelectedAccountChanged) {
wallet = event.account

missingAccountFetcher.fetchMissingAccounts(for: wallet) { [weak self] missingAccounts in
self?.missingAccountsChains = missingAccounts
Expand Down
7 changes: 7 additions & 0 deletions fearless/Common/Operation/OperationManagerFacade.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,12 @@ final class OperationManagerFacade {
return operationQueue
}()

static let persistentQueue: OperationQueue = {
let operationQueue = OperationQueue()
operationQueue.qualityOfService = .userInitiated
operationQueue.maxConcurrentOperationCount = 20
return operationQueue
}()

static let sharedManager = OperationManager(operationQueue: sharedDefaultQueue)
}
7 changes: 3 additions & 4 deletions fearless/Common/Storage/SelectedWalletSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import RobinHood
final class SelectedWalletSettings: PersistentValueSettings<MetaAccountModel> {
static let shared = SelectedWalletSettings(
storageFacade: UserDataStorageFacade.shared,
operationQueue: OperationManagerFacade.sharedDefaultQueue
operationQueue: OperationManagerFacade.persistentQueue
)

let operationQueue: OperationQueue
let mapper = ManagedMetaAccountMapper()
lazy var repository = storageFacade.createRepository(mapper: AnyCoreDataMapper(mapper))

init(storageFacade: StorageFacadeProtocol, operationQueue: OperationQueue) {
self.operationQueue = operationQueue
Expand Down Expand Up @@ -42,9 +44,6 @@ final class SelectedWalletSettings: PersistentValueSettings<MetaAccountModel> {
value: MetaAccountModel,
completionClosure: @escaping (Result<MetaAccountModel, Error>) -> Void
) {
let mapper = ManagedMetaAccountMapper()
let repository = storageFacade.createRepository(mapper: AnyCoreDataMapper(mapper))

let options = RepositoryFetchOptions(includesProperties: true, includesSubentities: true)
let maybeCurrentAccountOperation = internalValue.map {
repository.fetchOperation(by: $0.identifier, options: options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ final class WalletsManagmentAssembly {
contextTag: Int = 0,
moduleOutput: WalletsManagmentModuleOutput?
) -> WalletsManagmentModuleCreationResult? {
guard let wallet = SelectedWalletSettings.shared.value else { return nil }
let sharedDefaultQueue = OperationManagerFacade.sharedDefaultQueue
let localizationManager = LocalizationManager.shared
let eventCenter = EventCenter.shared
Expand Down
28 changes: 16 additions & 12 deletions fearless/Modules/WalletsManagment/WalletsManagmentInteractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,24 @@ extension WalletsManagmentInteractor: WalletsManagmentInteractorInput {
output?.didCompleteSelection()
return
}
let oldMetaAccount = settings.value
DispatchQueue.global().async {
let oldMetaAccount = self.settings.value

guard wallet.info.identifier != oldMetaAccount?.identifier else {
output?.didCompleteSelection()
return
}
guard wallet.info.identifier != oldMetaAccount?.identifier else {
DispatchQueue.main.async {
self.output?.didCompleteSelection()
}
return
}

settings.save(value: wallet.info, runningCompletionIn: .main) { [weak self] result in
switch result {
case .success:
self?.eventCenter.notify(with: SelectedAccountChanged(account: wallet.info))
self?.output?.didCompleteSelection()
case let .failure(error):
self?.output?.didReceive(error: error)
self.settings.save(value: wallet.info, runningCompletionIn: .main) { [weak self] result in
switch result {
case .success:
self?.eventCenter.notify(with: SelectedAccountChanged(account: wallet.info))
self?.output?.didCompleteSelection()
case let .failure(error):
self?.output?.didReceive(error: error)
}
}
}
}
Expand Down

0 comments on commit d1e5f30

Please sign in to comment.