Skip to content

Commit 5dbb65b

Browse files
authored
Merge pull request #720 from Adamant-im/trello.com/c/AvS5QpYb
[trello.com/c/AvS5QpYb] Updating again the popup logic
2 parents 9990cbe + 9f1a00b commit 5dbb65b

File tree

5 files changed

+13
-17
lines changed

5 files changed

+13
-17
lines changed

Adamant/Modules/Account/AccountViewController/AccountViewController.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,12 @@ final class AccountViewController: FormViewController {
204204

205205
viewModel.$state
206206
.removeDuplicates()
207+
.debounce(for: .nanoseconds(500_000_000), scheduler: DispatchQueue.main)
207208
.receive(on: DispatchQueue.main)
208209
.sink { [weak self] _ in
209210
guard let self = self else { return }
210211
self.pagingViewController.reloadMenu()
212+
self.pagingViewController.select(index: currentWalletIndex, animated: false)
211213
}
212214
.store(in: &notificationsSet)
213215

@@ -900,11 +902,8 @@ final class AccountViewController: FormViewController {
900902
}
901903

902904
private func updatePagingItemHeight() {
903-
if walletViewControllers.count > 0 {
904-
pagingViewController.menuItemSize = .fixed(width: 110, height: 114)
905-
} else {
906-
pagingViewController.menuItemSize = .fixed(width: 110, height: 0)
907-
}
905+
let itemHeight: CGFloat = walletViewControllers.count > .zero ? 114 : .zero
906+
pagingViewController.menuItemSize = .fixed(width: 110, height: itemHeight)
908907

909908
updateHeaderSize(with: pagingViewController.menuItemSize.height, animated: true)
910909
}
@@ -978,9 +977,9 @@ final class AccountViewController: FormViewController {
978977
)
979978
}
980979

981-
refreshControl.endRefreshing()
982-
DispatchQueue.background.async { [accountService] in
983-
accountService.reloadWallets()
980+
Task { @MainActor in
981+
await accountService.reloadWallets()
982+
refreshControl.endRefreshing()
984983
}
985984
}
986985
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ private extension AccountWalletsViewModel {
4848
state.wallets[index].isBalanceInitialized = coreService.wallet?.isBalanceInitialized ?? false
4949
state.wallets[index].notificationBadgeCount = coreService.wallet?.notifications ?? 0
5050
} else {
51-
let network = ERC20Token.supportedTokens.contains(where: { $0.symbol == coreService.tokenSymbol })
52-
? type(of: coreService).tokenNetworkSymbol
53-
: ""
51+
let network = type(of: coreService).tokenNetworkSymbol
52+
5453
let model = WalletCollectionViewCell.Model(
5554
index: state.wallets.count,
5655
coinID: coreService.tokenUniqueID,

Adamant/Modules/Account/WalletCollectionViewCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class WalletCollectionViewCell: PagingCell {
3333
private extension WalletCollectionViewCell {
3434
func update(item: WalletCollectionViewCell.Model) {
3535
currencyImageView.image = item.currencyImage
36-
if item.currencyNetwork.isEmpty {
36+
if item.currencyNetwork == item.currencySymbol {
3737
currencySymbolLabel.text = item.currencySymbol
3838
} else {
3939
let currencyFont = currencySymbolLabel.font ?? .systemFont(ofSize: 12)

Adamant/ServiceProtocols/AccountService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ protocol AccountService: AnyObject, Sendable {
171171
func logout()
172172

173173
/// Reload current wallets state
174-
func reloadWallets()
174+
func reloadWallets() async
175175

176176
// MARK: Stay in functions
177177

Adamant/Services/AdamantAccountService.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,8 @@ extension AdamantAccountService {
408408
}
409409
}
410410

411-
func reloadWallets() {
412-
Task {
413-
_ = await initWallets()
414-
}
411+
func reloadWallets() async {
412+
_ = await initWallets()
415413
}
416414

417415
func initWallets() async -> [WalletAccount?] {

0 commit comments

Comments
 (0)