Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios

This commit is contained in:
overtake 2021-07-02 21:43:06 +03:00
commit 8b434853d1

View File

@ -1420,29 +1420,26 @@ public final class AccountViewTracker {
addHole = true addHole = true
pollingCompleted = .single(true) pollingCompleted = .single(true)
} }
let isAutomaticallyTracked = Promise<Bool>(false) let isAutomaticallyTracked = self.account!.postbox.transaction { transaction -> Bool in
if addHole { if transaction.getPeerChatListIndex(peerId) == nil {
let _ = (self.account!.postbox.transaction { transaction -> Bool in if addHole {
if transaction.getPeerChatListIndex(peerId) == nil {
transaction.addHole(peerId: peerId, namespace: Namespaces.Message.Cloud, space: .everywhere, range: 1 ... (Int32.max - 1)) transaction.addHole(peerId: peerId, namespace: Namespaces.Message.Cloud, space: .everywhere, range: 1 ... (Int32.max - 1))
return false
} else {
return true
} }
return false
} else {
return true
} }
|> deliverOn(self.queue)).start(next: { isTracked in
isAutomaticallyTracked.set(.single(isTracked))
})
} }
let historyIsValid = combineLatest(queue: self.queue, let historyIsValid = combineLatest(queue: self.queue,
pollingCompleted, pollingCompleted,
isAutomaticallyTracked.get() isAutomaticallyTracked
) )
|> map { lhs, rhs -> Bool in |> map { lhs, rhs -> Bool in
return lhs || rhs return lhs || rhs
} }
var loaded = false
let validHistory = historyIsValid let validHistory = historyIsValid
|> distinctUntilChanged |> distinctUntilChanged
|> take(until: { next in |> take(until: { next in
@ -1454,6 +1451,8 @@ public final class AccountViewTracker {
}) })
|> mapToSignal { isValid -> Signal<(MessageHistoryView, ViewUpdateType, InitialMessageHistoryData?), NoError> in |> mapToSignal { isValid -> Signal<(MessageHistoryView, ViewUpdateType, InitialMessageHistoryData?), NoError> in
if isValid { if isValid {
assert(!loaded)
loaded = true
return history return history
} else { } else {
let view = MessageHistoryView(tagMask: nil, namespaces: .all, entries: [], holeEarlier: true, holeLater: true, isLoading: true) let view = MessageHistoryView(tagMask: nil, namespaces: .all, entries: [], holeEarlier: true, holeLater: true, isLoading: true)