Merge commit '443d0293f65535fcf4bfc606463dfc65a9649e3e'

# Conflicts:
#	submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift
This commit is contained in:
Ali
2023-01-23 14:38:12 +04:00
17 changed files with 142 additions and 48 deletions

View File

@@ -4673,8 +4673,16 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
threadInfo = .single(nil)
}
self.peerDisposable.set((combineLatest(queue: Queue.mainQueue(), peerView.get(), onlineMemberCount, hasScheduledMessages, self.reportIrrelvantGeoNoticePromise.get(), displayedCountSignal, threadInfo)
|> deliverOnMainQueue).start(next: { [weak self] peerView, onlineMemberCount, hasScheduledMessages, peerReportNotice, pinnedCount, threadInfo in
self.peerDisposable.set(combineLatest(
queue: Queue.mainQueue(),
peerView.get(),
context.engine.data.subscribe(TelegramEngine.EngineData.Item.NotificationSettings.Global()),
onlineMemberCount,
hasScheduledMessages,
self.reportIrrelvantGeoNoticePromise.get(),
displayedCountSignal,
threadInfo
).start(next: { [weak self] peerView, globalNotificationSettings, onlineMemberCount, hasScheduledMessages, peerReportNotice, pinnedCount, threadInfo in
if let strongSelf = self {
if strongSelf.peerView === peerView && strongSelf.reportIrrelvantGeoNotice == peerReportNotice && strongSelf.hasScheduledMessages == hasScheduledMessages && strongSelf.threadInfo == threadInfo {
return
@@ -4739,6 +4747,21 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
if let notificationSettings = peerView.notificationSettings as? TelegramPeerNotificationSettings {
if case let .muted(until) = notificationSettings.muteState, until >= Int32(CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970) {
peerIsMuted = true
} else if case .default = notificationSettings.muteState {
if let peer = peerView.peers[peerView.peerId] {
if peer is TelegramUser {
peerIsMuted = !globalNotificationSettings.privateChats.enabled
} else if peer is TelegramGroup {
peerIsMuted = !globalNotificationSettings.groupChats.enabled
} else if let channel = peer as? TelegramChannel {
switch channel.info {
case .group:
peerIsMuted = !globalNotificationSettings.groupChats.enabled
case .broadcast:
peerIsMuted = !globalNotificationSettings.channels.enabled
}
}
}
}
}
var peerDiscussionId: PeerId?
@@ -6704,18 +6727,22 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
let isPremium = self.context.engine.data.subscribe(TelegramEngine.EngineData.Item.Peer.Peer(id: self.context.account.peerId))
|> map { peer -> Bool in
return peer?.isPremium ?? false
}
self.translationStateDisposable = (combineLatest(
queue: .concurrentDefaultQueue(),
isPremium,
self.chatDisplayNode.historyNode.cachedPeerDataAndMessages
) |> mapToSignal { isPremium, cachedDataAndMessages -> Signal<ChatPresentationTranslationState?, NoError> in
} |> distinctUntilChanged
let isHidden = self.chatDisplayNode.historyNode.cachedPeerDataAndMessages
|> map { cachedDataAndMessages -> Bool in
let (cachedData, _) = cachedDataAndMessages
var isHidden = false
if let cachedData = cachedData as? CachedChannelData, cachedData.flags.contains(.translationHidden) {
isHidden = true
}
return isHidden
} |> distinctUntilChanged
self.translationStateDisposable = (combineLatest(
queue: .concurrentDefaultQueue(),
isPremium,
isHidden
) |> mapToSignal { isPremium, isHidden -> Signal<ChatPresentationTranslationState?, NoError> in
if isPremium && !isHidden {
return chatTranslationState(context: context, peerId: peerId)
|> map { translationState -> ChatPresentationTranslationState? in