Skip to content

Commit d9d32de

Browse files
authored
Merge pull request #862 from Adamant-im/trello.com/c/dEf1yVQr
[trello.com/c/dEf1yVQr] Fix crash because of unsafe access for AccountWalletsState in multithread environment
2 parents 2aa72c4 + 73a0485 commit d9d32de

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

Adamant/Modules/Account/AccountViewController/AccountWallets/AccountWalletsState.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99
import CommonKit
1010
import Parchment
1111

12-
struct AccountWalletsState {
13-
var wallets: [AccountWalletCellState]
14-
15-
static let `default` = Self(wallets: [])
12+
struct AccountWalletsState: Sendable {
13+
@Atomic var wallets: [AccountWalletCellState] = []
1614
}
1715

1816
struct AccountWalletCellState {

Adamant/Modules/Account/AccountViewController/AccountWallets/AccountWalletsViewModel.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ import Foundation
1212

1313
@MainActor
1414
final class AccountWalletsViewModel {
15-
var state: AccountWalletsState = .default
15+
var state: AccountWalletsState
1616

1717
private let walletsStoreService: WalletStoreServiceProviderProtocol
1818
private var subscriptions = Set<AnyCancellable>()
1919

2020
init(walletsStoreService: WalletStoreServiceProviderProtocol) {
2121
self.walletsStoreService = walletsStoreService
22+
state = AccountWalletsState()
2223
setup()
2324
}
2425
}

0 commit comments

Comments
 (0)