diff --git a/submodules/TelegramCore/TelegramCore/BlockedPeersContext.swift b/submodules/TelegramCore/TelegramCore/BlockedPeersContext.swift index 30b417b530..37dbd9f7e3 100644 --- a/submodules/TelegramCore/TelegramCore/BlockedPeersContext.swift +++ b/submodules/TelegramCore/TelegramCore/BlockedPeersContext.swift @@ -159,11 +159,21 @@ public final class BlockedPeersContext { } |> mapToSignal { _ -> Signal in return postbox.transaction { transaction -> Peer? in + transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in + let previous: CachedUserData + if let current = current as? CachedUserData { + previous = current + } else { + previous = CachedUserData() + } + return previous.withUpdatedIsBlocked(true) + }) return transaction.getPeer(peerId) } |> introduceError(BlockedPeersContextAddError.self) } |> deliverOnMainQueue + |> mapToSignal { peer -> Signal in guard let strongSelf = self, let peer = peer else { return .complete() @@ -190,7 +200,7 @@ public final class BlockedPeersContext { public func remove(peerId: PeerId) -> Signal { assert(Queue.mainQueue().isCurrent()) - + let postbox = self.account.postbox let network = self.account.network return self.account.postbox.transaction { transaction -> Api.InputUser? in return transaction.getPeer(peerId).flatMap(apiInputUser) @@ -204,6 +214,21 @@ public final class BlockedPeersContext { |> mapError { _ -> BlockedPeersContextRemoveError in return .generic } + |> mapToSignal { value in + return postbox.transaction { transaction -> Peer? in + transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in + let previous: CachedUserData + if let current = current as? CachedUserData { + previous = current + } else { + previous = CachedUserData() + } + return previous.withUpdatedIsBlocked(false) + }) + return transaction.getPeer(peerId) + } + |> introduceError(BlockedPeersContextRemoveError.self) + } |> deliverOnMainQueue |> mapToSignal { _ -> Signal in guard let strongSelf = self else { diff --git a/submodules/TelegramCore/TelegramCore/Holes.swift b/submodules/TelegramCore/TelegramCore/Holes.swift index 1b7511e425..ad0be1f4bd 100644 --- a/submodules/TelegramCore/TelegramCore/Holes.swift +++ b/submodules/TelegramCore/TelegramCore/Holes.swift @@ -379,7 +379,7 @@ func fetchMessageHistoryHole(accountPeerId: PeerId, source: FetchMessageHistoryH let messageRange = ids.min()! ... ids.max()! switch direction { case let .aroundId(aroundId): - filledRange = min(aroundId.id, messageRange.lowerBound) ... max(aroundId.id, messageRange.lowerBound) + filledRange = min(aroundId.id, messageRange.lowerBound) ... max(aroundId.id, messageRange.upperBound) case let .range(start, end): if start.id <= end.id { let minBound = start.id diff --git a/submodules/TelegramCore/TelegramCore/TelegramMediaFile.swift b/submodules/TelegramCore/TelegramCore/TelegramMediaFile.swift index b475a37ca9..21eb30bc6c 100644 --- a/submodules/TelegramCore/TelegramCore/TelegramMediaFile.swift +++ b/submodules/TelegramCore/TelegramCore/TelegramMediaFile.swift @@ -347,6 +347,17 @@ public final class TelegramMediaFile: Media, Equatable { return false } + public var isStaticSticker: Bool { + for attribute in self.attributes { + if case .Sticker = attribute { + if let s = self.size, s < 200 * 1024 { + return !isAnimatedSticker + } + } + } + return false + } + public var isVideo: Bool { for attribute in self.attributes { if case .Video = attribute {