mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Fix build
This commit is contained in:
parent
4f2c77dcbb
commit
0f478d3506
@ -287,12 +287,11 @@ private final class NotificationServiceHandler {
|
||||
|
||||
stateManager.network.shouldKeepConnection.set(.single(true))
|
||||
if peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||
strongSelf.pollDisposable.set(pollChannelOnce(
|
||||
strongSelf.pollDisposable.set(standalonePollChannelOnce(
|
||||
postbox: stateManager.postbox,
|
||||
network: stateManager.network,
|
||||
peerId: peerId,
|
||||
stateManager: stateManager,
|
||||
delayCompletion: false
|
||||
stateManager: stateManager
|
||||
).start(completed: {
|
||||
pollCompletion()
|
||||
}))
|
||||
|
@ -1706,11 +1706,15 @@ private func resolveMissingPeerChatInfos(network: Network, state: AccountMutable
|
||||
}
|
||||
}
|
||||
|
||||
public func pollChannelOnce(postbox: Postbox, network: Network, peerId: PeerId, stateManager: AccountStateManager, delayCompletion: Bool) -> Signal<Int32, NoError> {
|
||||
func pollChannelOnce(postbox: Postbox, network: Network, peerId: PeerId, stateManager: AccountStateManager, delayCompletion: Bool) -> Signal<Int32, NoError> {
|
||||
return postbox.transaction { transaction -> Signal<Int32, NoError> in
|
||||
guard let accountState = (transaction.getState() as? AuthorizedAccountState)?.state, let peer = transaction.getPeer(peerId) else {
|
||||
return .complete()
|
||||
|> delay(30.0, queue: Queue.concurrentDefaultQueue())
|
||||
if delayCompletion {
|
||||
return .complete()
|
||||
|> delay(30.0, queue: Queue.concurrentDefaultQueue())
|
||||
} else {
|
||||
return .complete()
|
||||
}
|
||||
}
|
||||
|
||||
var channelStates: [PeerId: AccountStateChannelState] = [:]
|
||||
@ -1761,6 +1765,49 @@ public func pollChannelOnce(postbox: Postbox, network: Network, peerId: PeerId,
|
||||
|> switchToLatest
|
||||
}
|
||||
|
||||
public func standalonePollChannelOnce(postbox: Postbox, network: Network, peerId: PeerId, stateManager: AccountStateManager) -> Signal<Never, NoError> {
|
||||
return postbox.transaction { transaction -> Signal<Never, NoError> in
|
||||
guard let accountState = (transaction.getState() as? AuthorizedAccountState)?.state, let peer = transaction.getPeer(peerId) else {
|
||||
return .complete()
|
||||
}
|
||||
|
||||
var channelStates: [PeerId: AccountStateChannelState] = [:]
|
||||
if let channelState = transaction.getPeerChatState(peerId) as? ChannelState {
|
||||
channelStates[peerId] = AccountStateChannelState(pts: channelState.pts)
|
||||
}
|
||||
let initialPeers: [PeerId: Peer] = [peerId: peer]
|
||||
var peerChatInfos: [PeerId: PeerChatInfo] = [:]
|
||||
let inclusion = transaction.getPeerChatListInclusion(peerId)
|
||||
var hasValidInclusion = false
|
||||
switch inclusion {
|
||||
case .ifHasMessagesOrOneOf:
|
||||
hasValidInclusion = true
|
||||
case .notIncluded:
|
||||
hasValidInclusion = false
|
||||
}
|
||||
if hasValidInclusion {
|
||||
if let notificationSettings = transaction.getPeerNotificationSettings(peerId) as? TelegramPeerNotificationSettings {
|
||||
peerChatInfos[peerId] = PeerChatInfo(notificationSettings: notificationSettings)
|
||||
}
|
||||
}
|
||||
let initialState = AccountMutableState(initialState: AccountInitialState(state: accountState, peerIds: Set(), peerIdsRequiringLocalChatState: Set(), channelStates: channelStates, peerChatInfos: peerChatInfos, locallyGeneratedMessageTimestamps: [:], cloudReadStates: [:], channelsToPollExplicitely: Set()), initialPeers: initialPeers, initialReferencedMessageIds: Set(), initialStoredMessages: Set(), initialReadInboxMaxIds: [:], storedMessagesByPeerIdAndTimestamp: [:])
|
||||
return pollChannel(network: network, peer: peer, state: initialState)
|
||||
|> mapToSignal { (finalState, _, timeout) -> Signal<Never, NoError> in
|
||||
return resolveAssociatedMessages(network: network, state: finalState)
|
||||
|> mapToSignal { resultingState -> Signal<AccountFinalState, NoError> in
|
||||
return resolveMissingPeerChatInfos(network: network, state: resultingState)
|
||||
|> map { resultingState, _ -> AccountFinalState in
|
||||
return AccountFinalState(state: resultingState, shouldPoll: false, incomplete: false, missingUpdatesFromChannels: Set(), discard: false)
|
||||
}
|
||||
}
|
||||
|> mapToSignal { finalState -> Signal<Never, NoError> in
|
||||
return stateManager.standaloneReplayAsynchronouslyBuiltFinalState(finalState: finalState)
|
||||
}
|
||||
}
|
||||
}
|
||||
|> switchToLatest
|
||||
}
|
||||
|
||||
func keepPollingChannel(postbox: Postbox, network: Network, peerId: PeerId, stateManager: AccountStateManager) -> Signal<Int32, NoError> {
|
||||
return pollChannelOnce(postbox: postbox, network: network, peerId: peerId, stateManager: stateManager, delayCompletion: true)
|
||||
|> restart
|
||||
|
@ -838,7 +838,7 @@ public final class AccountStateManager {
|
||||
}
|
||||
}
|
||||
|
||||
func standaloneReplayAsynchronouslyBuiltFinalState(finalState: AccountFinalState) {
|
||||
func standaloneReplayAsynchronouslyBuiltFinalState(finalState: AccountFinalState) -> Signal<Never, NoError> {
|
||||
if !finalState.state.preCachedResources.isEmpty {
|
||||
for (resource, data) in finalState.state.preCachedResources {
|
||||
self.postbox.mediaBox.storeResourceData(resource.id, data: data)
|
||||
@ -864,22 +864,8 @@ public final class AccountStateManager {
|
||||
|> map({ ($0, finalState) })
|
||||
|> deliverOn(self.queue)
|
||||
|
||||
let _ = signal.start(next: { [weak self] replayedState, finalState in
|
||||
if let strongSelf = self {
|
||||
if case .replayAsynchronouslyBuiltFinalState = strongSelf.operations.removeFirst().content {
|
||||
if let replayedState = replayedState {
|
||||
let events = AccountFinalStateEvents(state: replayedState)
|
||||
if !events.isEmpty {
|
||||
strongSelf.insertProcessEvents(events)
|
||||
}
|
||||
}
|
||||
strongSelf.startFirstOperation()
|
||||
} else {
|
||||
assertionFailure()
|
||||
}
|
||||
completion()
|
||||
}
|
||||
})
|
||||
return signal
|
||||
|> ignoreValues
|
||||
}
|
||||
|
||||
public func standalonePollDifference() -> Signal<Bool, NoError> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user