Skip to content

Commit c67c0e8

Browse files
authored
Merge pull request #721 from Adamant-im/trello.com/c/B9LfGpfD
[trello.com/c/B9LfGpfD] Spinner retrieved back
2 parents e710850 + 64deb8f commit c67c0e8

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

Adamant/Modules/Chat/View/ChatViewController.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,24 +478,28 @@ private extension ChatViewController {
478478
self?.didTapSelectText(text: text)
479479
}
480480
.store(in: &subscriptions)
481+
481482
viewModel.$unreadMesaggesIndexes
482483
.removeDuplicates()
483484
.sink { [weak self] _ in
484485
self?.updateUnreadMessages()
485486
}
486487
.store(in: &subscriptions)
488+
487489
viewModel.$unreadMessagesIds
488490
.removeDuplicates()
489491
.sink { _ in
490492
self.updateScrollDownButtonVisibility()
491493
}
492494
.store(in: &subscriptions)
495+
493496
viewModel.$messagesWithUnredReactionsIds
494497
.removeDuplicates()
495498
.sink { [weak self] _ in
496499
self?.updateScrollToUnreadButtonVisibility()
497500
}
498501
.store(in: &subscriptions)
502+
499503
viewModel.showBuyAndSell
500504
.sink { [weak self] in
501505
self?.presentBuyAndSell()

Adamant/Modules/Chat/ViewModel/ChatViewModel.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,9 @@ final class ChatViewModel: NSObject {
271271
return
272272
}
273273

274-
let isChatLoaded = await chatsProvider.isChatLoaded(with: address)
275-
let isChatLoading = await chatsProvider.isChatLoading(with: address)
274+
async let chatLoadingState = (chatsProvider.isChatLoaded(with: address), chatsProvider.isChatLoading(with: address))
275+
276+
let (isChatLoaded, isChatLoading) = await chatLoadingState
276277

277278
guard !isChatLoading else {
278279
await waitForChatLoading(with: address)
@@ -1149,7 +1150,7 @@ private extension ChatViewModel {
11491150
await chatsProvider.stateObserver
11501151
.receive(on: DispatchQueue.main)
11511152
.sink { [weak self] state in
1152-
self?.isHeaderLoading = state == .updating ? true : false
1153+
self?.isHeaderLoading = state.isUpdating
11531154
}
11541155
.store(in: &subscriptions)
11551156
}.stored(in: tasksStorage)

Adamant/Modules/ChatsList/ChatListViewController.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,15 +1589,6 @@ extension ChatListViewController {
15891589
}
15901590
}
15911591

1592-
private extension DataProviderState {
1593-
var isUpdating: Bool {
1594-
switch self {
1595-
case .updating: true
1596-
case .failedToUpdate, .upToDate, .empty: false
1597-
}
1598-
}
1599-
}
1600-
16011592
private extension UITableView {
16021593
func reloadRowsAndPreserveSelection(at indexPaths: [IndexPath]) {
16031594
let selectedRowIndexPath = indexPathForSelectedRow

Adamant/ServiceProtocols/DataProviders/DataProvider.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ enum DataProviderState {
1414
case updating
1515
case upToDate
1616
case failedToUpdate(Error)
17+
18+
var isUpdating: Bool {
19+
switch self {
20+
case .updating: true
21+
case .failedToUpdate, .upToDate, .empty: false
22+
}
23+
}
1724
}
1825

1926
protocol DataProvider: AnyObject, Actor {

0 commit comments

Comments
 (0)