Fix forum & topics notification settings

This commit is contained in:
Ilya Laktyushin 2023-03-24 16:26:59 +04:00
parent 09780bc0a4
commit 85408023ab
7 changed files with 151 additions and 135 deletions

View File

@ -89,7 +89,7 @@ public func peerAvatarCompleteImage(account: Account, peer: EnginePeer, forcePro
let clipStyle: AvatarNodeClipStyle let clipStyle: AvatarNodeClipStyle
if round { if round {
if case let .channel(channel) = peer, channel.flags.contains(.isForum) { if case let .channel(channel) = peer, channel.isForum {
clipStyle = .roundedRect clipStyle = .roundedRect
} else { } else {
clipStyle = .round clipStyle = .round

View File

@ -265,7 +265,7 @@ private final class ContextControllerActionsListActionItemNode: HighlightTrackin
textColor: titleColor) textColor: titleColor)
} }
self.titleLabelNode.isUserInteractionEnabled = self.titleLabelNode.tapAttributeAction != nil self.titleLabelNode.isUserInteractionEnabled = self.titleLabelNode.tapAttributeAction != nil && self.item.action == nil
self.subtitleNode.attributedText = subtitle.flatMap { subtitle in self.subtitleNode.attributedText = subtitle.flatMap { subtitle in
return NSAttributedString( return NSAttributedString(

View File

@ -1323,7 +1323,12 @@ public class ItemListPeerItemNode: ItemListRevealOptionsItemNode, ItemListItemNo
overrideImage = .deletedIcon overrideImage = .deletedIcon
} }
strongSelf.avatarNode.imageNode.animateFirstTransition = item.animateFirstAvatarTransition strongSelf.avatarNode.imageNode.animateFirstTransition = item.animateFirstAvatarTransition
strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: item.peer, overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoad)
var clipStyle: AvatarNodeClipStyle = .round
if case let .channel(channel) = item.peer, channel.isForum {
clipStyle = .roundedRect
}
strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: item.peer, overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, clipStyle: clipStyle, synchronousLoad: synchronousLoad)
} }
} }

View File

@ -341,8 +341,12 @@ private enum ChannelPermissionsEntry: ItemListNodeEntry {
case let .member(_, _, _, banInfo, _): case let .member(_, _, _, banInfo, _):
var exceptionsString = "" var exceptionsString = ""
if let banInfo = banInfo { if let banInfo = banInfo {
let sendMediaRights = banSendMediaSubList().map { $0.0 }
for (rights, _) in internal_allPossibleGroupPermissionList { for (rights, _) in internal_allPossibleGroupPermissionList {
if !defaultBannedRights.contains(rights) && banInfo.rights.flags.contains(rights) { if !defaultBannedRights.contains(rights) && banInfo.rights.flags.contains(rights) {
if banInfo.rights.flags.contains(.banSendMedia) && sendMediaRights.contains(rights) {
continue
}
if !exceptionsString.isEmpty { if !exceptionsString.isEmpty {
exceptionsString.append(", ") exceptionsString.append(", ")
} }

View File

@ -183,7 +183,8 @@ final class PeerInfoScreenData {
let chatPeer: Peer? let chatPeer: Peer?
let cachedData: CachedPeerData? let cachedData: CachedPeerData?
let status: PeerInfoStatusData? let status: PeerInfoStatusData?
let notificationSettings: TelegramPeerNotificationSettings? let peerNotificationSettings: TelegramPeerNotificationSettings?
let threadNotificationSettings: TelegramPeerNotificationSettings?
let globalNotificationSettings: EngineGlobalNotificationSettings? let globalNotificationSettings: EngineGlobalNotificationSettings?
let isContact: Bool let isContact: Bool
let availablePanes: [PeerInfoPaneKey] let availablePanes: [PeerInfoPaneKey]
@ -204,7 +205,8 @@ final class PeerInfoScreenData {
chatPeer: Peer?, chatPeer: Peer?,
cachedData: CachedPeerData?, cachedData: CachedPeerData?,
status: PeerInfoStatusData?, status: PeerInfoStatusData?,
notificationSettings: TelegramPeerNotificationSettings?, peerNotificationSettings: TelegramPeerNotificationSettings?,
threadNotificationSettings: TelegramPeerNotificationSettings?,
globalNotificationSettings: EngineGlobalNotificationSettings?, globalNotificationSettings: EngineGlobalNotificationSettings?,
isContact: Bool, isContact: Bool,
availablePanes: [PeerInfoPaneKey], availablePanes: [PeerInfoPaneKey],
@ -224,7 +226,8 @@ final class PeerInfoScreenData {
self.chatPeer = chatPeer self.chatPeer = chatPeer
self.cachedData = cachedData self.cachedData = cachedData
self.status = status self.status = status
self.notificationSettings = notificationSettings self.peerNotificationSettings = peerNotificationSettings
self.threadNotificationSettings = threadNotificationSettings
self.globalNotificationSettings = globalNotificationSettings self.globalNotificationSettings = globalNotificationSettings
self.isContact = isContact self.isContact = isContact
self.availablePanes = availablePanes self.availablePanes = availablePanes
@ -521,7 +524,8 @@ func peerInfoScreenSettingsData(context: AccountContext, peerId: EnginePeer.Id,
chatPeer: peer, chatPeer: peer,
cachedData: peerView.cachedData, cachedData: peerView.cachedData,
status: nil, status: nil,
notificationSettings: nil, peerNotificationSettings: nil,
threadNotificationSettings: nil,
globalNotificationSettings: nil, globalNotificationSettings: nil,
isContact: false, isContact: false,
availablePanes: [], availablePanes: [],
@ -550,7 +554,8 @@ func peerInfoScreenData(context: AccountContext, peerId: PeerId, strings: Presen
chatPeer: nil, chatPeer: nil,
cachedData: nil, cachedData: nil,
status: nil, status: nil,
notificationSettings: nil, peerNotificationSettings: nil,
threadNotificationSettings: nil,
globalNotificationSettings: nil, globalNotificationSettings: nil,
isContact: false, isContact: false,
availablePanes: [], availablePanes: [],
@ -683,7 +688,8 @@ func peerInfoScreenData(context: AccountContext, peerId: PeerId, strings: Presen
chatPeer: peerView.peers[peerId], chatPeer: peerView.peers[peerId],
cachedData: peerView.cachedData, cachedData: peerView.cachedData,
status: status, status: status,
notificationSettings: peerView.notificationSettings as? TelegramPeerNotificationSettings, peerNotificationSettings: peerView.notificationSettings as? TelegramPeerNotificationSettings,
threadNotificationSettings: nil,
globalNotificationSettings: globalNotificationSettings, globalNotificationSettings: globalNotificationSettings,
isContact: peerView.peerIsContact, isContact: peerView.peerIsContact,
availablePanes: availablePanes ?? [], availablePanes: availablePanes ?? [],
@ -761,7 +767,8 @@ func peerInfoScreenData(context: AccountContext, peerId: PeerId, strings: Presen
chatPeer: peerView.peers[peerId], chatPeer: peerView.peers[peerId],
cachedData: peerView.cachedData, cachedData: peerView.cachedData,
status: status, status: status,
notificationSettings: peerView.notificationSettings as? TelegramPeerNotificationSettings, peerNotificationSettings: peerView.notificationSettings as? TelegramPeerNotificationSettings,
threadNotificationSettings: nil,
globalNotificationSettings: globalNotificationSettings, globalNotificationSettings: globalNotificationSettings,
isContact: peerView.peerIsContact, isContact: peerView.peerIsContact,
availablePanes: availablePanes ?? [], availablePanes: availablePanes ?? [],
@ -948,12 +955,8 @@ func peerInfoScreenData(context: AccountContext, peerId: PeerId, strings: Presen
} }
} }
var notificationSettings: TelegramPeerNotificationSettings? let peerNotificationSettings = peerView.notificationSettings as? TelegramPeerNotificationSettings
if let threadData = threadData { let threadNotificationSettings = threadData?.notificationSettings
notificationSettings = threadData.notificationSettings
} else {
notificationSettings = peerView.notificationSettings as? TelegramPeerNotificationSettings
}
let appConfiguration: AppConfiguration = preferencesView.values[PreferencesKeys.appConfiguration]?.get(AppConfiguration.self) ?? .defaultValue let appConfiguration: AppConfiguration = preferencesView.values[PreferencesKeys.appConfiguration]?.get(AppConfiguration.self) ?? .defaultValue
@ -962,7 +965,8 @@ func peerInfoScreenData(context: AccountContext, peerId: PeerId, strings: Presen
chatPeer: peerView.peers[groupId], chatPeer: peerView.peers[groupId],
cachedData: peerView.cachedData, cachedData: peerView.cachedData,
status: status, status: status,
notificationSettings: notificationSettings, peerNotificationSettings: peerNotificationSettings,
threadNotificationSettings: threadNotificationSettings,
globalNotificationSettings: globalNotificationSettings, globalNotificationSettings: globalNotificationSettings,
isContact: peerView.peerIsContact, isContact: peerView.peerIsContact,
availablePanes: availablePanes ?? [], availablePanes: availablePanes ?? [],
@ -1305,3 +1309,42 @@ func peerInfoCanEdit(peer: Peer?, chatLocation: ChatLocation, threadData: Messag
} }
return false return false
} }
func peerInfoIsChatMuted(peer: Peer?, peerNotificationSettings: TelegramPeerNotificationSettings?, threadNotificationSettings: TelegramPeerNotificationSettings?, globalNotificationSettings: EngineGlobalNotificationSettings?) -> Bool {
func isPeerMuted(peer: Peer?, peerNotificationSettings: TelegramPeerNotificationSettings?, globalNotificationSettings: EngineGlobalNotificationSettings?) -> Bool {
var peerIsMuted = false
if let peerNotificationSettings {
if case .muted = peerNotificationSettings.muteState {
peerIsMuted = true
} else if case .default = peerNotificationSettings.muteState, let globalNotificationSettings {
if let peer {
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
}
}
}
}
}
return peerIsMuted
}
var chatIsMuted = false
if let threadNotificationSettings {
if case .muted = threadNotificationSettings.muteState {
chatIsMuted = true
} else if let peerNotificationSettings {
chatIsMuted = isPeerMuted(peer: peer, peerNotificationSettings: peerNotificationSettings, globalNotificationSettings: globalNotificationSettings)
}
} else {
chatIsMuted = isPeerMuted(peer: peer, peerNotificationSettings: peerNotificationSettings, globalNotificationSettings: globalNotificationSettings)
}
return chatIsMuted
}

View File

@ -2554,7 +2554,7 @@ final class PeerInfoHeaderNode: ASDisplayNode {
private var currentCredibilityIcon: CredibilityIcon? private var currentCredibilityIcon: CredibilityIcon?
private var currentPanelStatusData: PeerInfoStatusData? private var currentPanelStatusData: PeerInfoStatusData?
func update(width: CGFloat, containerHeight: CGFloat, containerInset: CGFloat, statusBarHeight: CGFloat, navigationHeight: CGFloat, isModalOverlay: Bool, isMediaOnly: Bool, contentOffset: CGFloat, paneContainerY: CGFloat, presentationData: PresentationData, peer: Peer?, cachedData: CachedPeerData?, threadData: MessageHistoryThreadData?, notificationSettings: TelegramPeerNotificationSettings?, globalNotificationSettings: EngineGlobalNotificationSettings?, statusData: PeerInfoStatusData?, panelStatusData: (PeerInfoStatusData?, PeerInfoStatusData?, CGFloat?), isSecretChat: Bool, isContact: Bool, isSettings: Bool, state: PeerInfoState, metrics: LayoutMetrics, deviceMetrics: DeviceMetrics, transition: ContainedViewLayoutTransition, additive: Bool) -> CGFloat { func update(width: CGFloat, containerHeight: CGFloat, containerInset: CGFloat, statusBarHeight: CGFloat, navigationHeight: CGFloat, isModalOverlay: Bool, isMediaOnly: Bool, contentOffset: CGFloat, paneContainerY: CGFloat, presentationData: PresentationData, peer: Peer?, cachedData: CachedPeerData?, threadData: MessageHistoryThreadData?, peerNotificationSettings: TelegramPeerNotificationSettings?, threadNotificationSettings: TelegramPeerNotificationSettings?, globalNotificationSettings: EngineGlobalNotificationSettings?, statusData: PeerInfoStatusData?, panelStatusData: (PeerInfoStatusData?, PeerInfoStatusData?, CGFloat?), isSecretChat: Bool, isContact: Bool, isSettings: Bool, state: PeerInfoState, metrics: LayoutMetrics, deviceMetrics: DeviceMetrics, transition: ContainedViewLayoutTransition, additive: Bool) -> CGFloat {
self.state = state self.state = state
self.peer = peer self.peer = peer
self.threadData = threadData self.threadData = threadData
@ -3494,28 +3494,8 @@ final class PeerInfoHeaderNode: ASDisplayNode {
} }
buttonIcon = .voiceChat buttonIcon = .voiceChat
case .mute: case .mute:
var peerIsMuted = false let chatIsMuted = peerInfoIsChatMuted(peer: peer, peerNotificationSettings: peerNotificationSettings, threadNotificationSettings: threadNotificationSettings, globalNotificationSettings: globalNotificationSettings)
if let notificationSettings { if chatIsMuted {
if case .muted = notificationSettings.muteState {
peerIsMuted = true
} else if case .default = notificationSettings.muteState, let globalNotificationSettings {
if let peer {
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
}
}
}
}
}
if peerIsMuted {
buttonText = presentationData.strings.PeerInfo_ButtonUnmute buttonText = presentationData.strings.PeerInfo_ButtonUnmute
buttonIcon = .unmute buttonIcon = .unmute
} else { } else {

View File

@ -4260,30 +4260,9 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
self.requestCall(isVideo: false, gesture: gesture) self.requestCall(isVideo: false, gesture: gesture)
case .mute: case .mute:
var displayCustomNotificationSettings = false var displayCustomNotificationSettings = false
var peerIsMuted = false let chatIsMuted = peerInfoIsChatMuted(peer: self.data?.peer, peerNotificationSettings: self.data?.peerNotificationSettings, threadNotificationSettings: self.data?.threadNotificationSettings, globalNotificationSettings: self.data?.globalNotificationSettings)
if let notificationSettings = self.data?.notificationSettings { if chatIsMuted {
if case .muted = notificationSettings.muteState {
peerIsMuted = true
} else if case .default = notificationSettings.muteState, let globalNotificationSettings = self.data?.globalNotificationSettings {
if let peer = self.data?.peer {
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
}
}
}
}
}
if peerIsMuted {
} else { } else {
displayCustomNotificationSettings = true displayCustomNotificationSettings = true
} }
@ -4360,7 +4339,8 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
items.append(.separator) items.append(.separator)
var isSoundEnabled = true var isSoundEnabled = true
if let notificationSettings = self.data?.notificationSettings { let notificationSettings = self.data?.threadNotificationSettings ?? self.data?.peerNotificationSettings
if let notificationSettings {
switch notificationSettings.messageSound { switch notificationSettings.messageSound {
case .none: case .none:
isSoundEnabled = false isSoundEnabled = false
@ -4369,53 +4349,34 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
} }
} }
if let notificationSettings = self.data?.notificationSettings, case .muted = notificationSettings.muteState { if !chatIsMuted {
items.append(.action(ContextMenuActionItem(text: self.presentationData.strings.PeerInfo_ButtonUnmute, icon: { theme in if !isSoundEnabled {
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/SoundOn"), color: theme.contextMenu.primaryColor) items.append(.action(ContextMenuActionItem(text: self.presentationData.strings.PeerInfo_EnableSound, icon: { theme in
}, action: { [weak self] _, f in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/SoundOn"), color: theme.contextMenu.primaryColor)
f(.default) }, action: { [weak self] _, f in
f(.default)
guard let self else {
return guard let strongSelf = self else {
} return
}
let _ = self.context.engine.peers.updatePeerMuteSetting(peerId: peerId, threadId: self.chatLocation.threadId, muteInterval: nil).start() let _ = strongSelf.context.engine.peers.updatePeerNotificationSoundInteractive(peerId: peerId, threadId: strongSelf.chatLocation.threadId, sound: .default).start()
let iconColor: UIColor = .white strongSelf.controller?.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .universal(animation: "anim_sound_on", scale: 0.056, colors: [:], title: nil, text: strongSelf.presentationData.strings.PeerInfo_TooltipSoundEnabled, customUndoText: nil, timeout: nil), elevatedLayout: false, animateInAsReplacement: true, action: { _ in return false }), in: .current)
self.controller?.present(UndoOverlayController(presentationData: self.presentationData, content: .universal(animation: "anim_profileunmute", scale: 0.075, colors: [ })))
"Middle.Group 1.Fill 1": iconColor, } else {
"Top.Group 1.Fill 1": iconColor, items.append(.action(ContextMenuActionItem(text: self.presentationData.strings.PeerInfo_DisableSound, icon: { theme in
"Bottom.Group 1.Fill 1": iconColor, return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/SoundOff"), color: theme.contextMenu.primaryColor)
"EXAMPLE.Group 1.Fill 1": iconColor, }, action: { [weak self] _, f in
"Line.Group 1.Stroke 1": iconColor f(.default)
], title: nil, text: self.presentationData.strings.PeerInfo_TooltipUnmuted, customUndoText: nil, timeout: nil), elevatedLayout: false, animateInAsReplacement: true, action: { _ in return false }), in: .current)
}))) guard let strongSelf = self else {
} else if !isSoundEnabled { return
items.append(.action(ContextMenuActionItem(text: self.presentationData.strings.PeerInfo_EnableSound, icon: { theme in }
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/SoundOn"), color: theme.contextMenu.primaryColor) let _ = strongSelf.context.engine.peers.updatePeerNotificationSoundInteractive(peerId: peerId, threadId: strongSelf.chatLocation.threadId, sound: .none).start()
}, action: { [weak self] _, f in
f(.default) strongSelf.controller?.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .universal(animation: "anim_sound_off", scale: 0.056, colors: [:], title: nil, text: strongSelf.presentationData.strings.PeerInfo_TooltipSoundDisabled, customUndoText: nil, timeout: nil), elevatedLayout: false, animateInAsReplacement: true, action: { _ in return false }), in: .current)
})))
guard let strongSelf = self else { }
return
}
let _ = strongSelf.context.engine.peers.updatePeerNotificationSoundInteractive(peerId: peerId, threadId: strongSelf.chatLocation.threadId, sound: .default).start()
strongSelf.controller?.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .universal(animation: "anim_sound_on", scale: 0.056, colors: [:], title: nil, text: strongSelf.presentationData.strings.PeerInfo_TooltipSoundEnabled, customUndoText: nil, timeout: nil), elevatedLayout: false, animateInAsReplacement: true, action: { _ in return false }), in: .current)
})))
} else {
items.append(.action(ContextMenuActionItem(text: self.presentationData.strings.PeerInfo_DisableSound, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/SoundOff"), color: theme.contextMenu.primaryColor)
}, action: { [weak self] _, f in
f(.default)
guard let strongSelf = self else {
return
}
let _ = strongSelf.context.engine.peers.updatePeerNotificationSoundInteractive(peerId: peerId, threadId: strongSelf.chatLocation.threadId, sound: .none).start()
strongSelf.controller?.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .universal(animation: "anim_sound_off", scale: 0.056, colors: [:], title: nil, text: strongSelf.presentationData.strings.PeerInfo_TooltipSoundDisabled, customUndoText: nil, timeout: nil), elevatedLayout: false, animateInAsReplacement: true, action: { _ in return false }), in: .current)
})))
} }
let context = self.context let context = self.context
@ -4505,26 +4466,49 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
}) })
}))) })))
items.append(.action(ContextMenuActionItem(text: self.presentationData.strings.PeerInfo_MuteForever, textColor: .destructive, icon: { theme in if chatIsMuted {
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Muted"), color: theme.contextMenu.destructiveColor) items.append(.action(ContextMenuActionItem(text: self.presentationData.strings.PeerInfo_ButtonUnmute, icon: { theme in
}, action: { [weak self] _, f in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Unmute"), color: theme.contextMenu.primaryColor)
f(.default) }, action: { [weak self] _, f in
f(.default)
guard let strongSelf = self else {
return guard let self else {
} return
}
let _ = strongSelf.context.engine.peers.updatePeerMuteSetting(peerId: peerId, threadId: strongSelf.chatLocation.threadId, muteInterval: Int32.max).start()
let _ = self.context.engine.peers.updatePeerMuteSetting(peerId: peerId, threadId: self.chatLocation.threadId, muteInterval: 0).start()
let iconColor: UIColor = .white
strongSelf.controller?.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .universal(animation: "anim_profilemute", scale: 0.075, colors: [ let iconColor: UIColor = .white
"Middle.Group 1.Fill 1": iconColor, self.controller?.present(UndoOverlayController(presentationData: self.presentationData, content: .universal(animation: "anim_profileunmute", scale: 0.075, colors: [
"Top.Group 1.Fill 1": iconColor, "Middle.Group 1.Fill 1": iconColor,
"Bottom.Group 1.Fill 1": iconColor, "Top.Group 1.Fill 1": iconColor,
"EXAMPLE.Group 1.Fill 1": iconColor, "Bottom.Group 1.Fill 1": iconColor,
"Line.Group 1.Stroke 1": iconColor "EXAMPLE.Group 1.Fill 1": iconColor,
], title: nil, text: strongSelf.presentationData.strings.PeerInfo_TooltipMutedForever, customUndoText: nil, timeout: nil), elevatedLayout: false, animateInAsReplacement: true, action: { _ in return false }), in: .current) "Line.Group 1.Stroke 1": iconColor
}))) ], title: nil, text: self.presentationData.strings.PeerInfo_TooltipUnmuted, customUndoText: nil, timeout: nil), elevatedLayout: false, animateInAsReplacement: true, action: { _ in return false }), in: .current)
})))
} else {
items.append(.action(ContextMenuActionItem(text: self.presentationData.strings.PeerInfo_MuteForever, textColor: .destructive, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Muted"), color: theme.contextMenu.destructiveColor)
}, action: { [weak self] _, f in
f(.default)
guard let strongSelf = self else {
return
}
let _ = strongSelf.context.engine.peers.updatePeerMuteSetting(peerId: peerId, threadId: strongSelf.chatLocation.threadId, muteInterval: Int32.max).start()
let iconColor: UIColor = .white
strongSelf.controller?.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .universal(animation: "anim_profilemute", scale: 0.075, colors: [
"Middle.Group 1.Fill 1": iconColor,
"Top.Group 1.Fill 1": iconColor,
"Bottom.Group 1.Fill 1": iconColor,
"EXAMPLE.Group 1.Fill 1": iconColor,
"Line.Group 1.Stroke 1": iconColor
], title: nil, text: strongSelf.presentationData.strings.PeerInfo_TooltipMutedForever, customUndoText: nil, timeout: nil), elevatedLayout: false, animateInAsReplacement: true, action: { _ in return false }), in: .current)
})))
}
var tip: ContextController.Tip? var tip: ContextController.Tip?
tip = nil tip = nil
@ -8689,7 +8673,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
} }
let headerInset = sectionInset let headerInset = sectionInset
var headerHeight = self.headerNode.update(width: layout.size.width, containerHeight: layout.size.height, containerInset: headerInset, statusBarHeight: layout.statusBarHeight ?? 0.0, navigationHeight: navigationHeight, isModalOverlay: layout.isModalOverlay, isMediaOnly: self.isMediaOnly, contentOffset: self.isMediaOnly ? 212.0 : self.scrollNode.view.contentOffset.y, paneContainerY: self.paneContainerNode.frame.minY, presentationData: self.presentationData, peer: self.data?.peer, cachedData: self.data?.cachedData, threadData: self.data?.threadData, notificationSettings: self.data?.notificationSettings, globalNotificationSettings: self.data?.globalNotificationSettings, statusData: self.data?.status, panelStatusData: self.customStatusData, isSecretChat: self.peerId.namespace == Namespaces.Peer.SecretChat, isContact: self.data?.isContact ?? false, isSettings: self.isSettings, state: self.state, metrics: layout.metrics, deviceMetrics: layout.deviceMetrics, transition: transition, additive: additive) var headerHeight = self.headerNode.update(width: layout.size.width, containerHeight: layout.size.height, containerInset: headerInset, statusBarHeight: layout.statusBarHeight ?? 0.0, navigationHeight: navigationHeight, isModalOverlay: layout.isModalOverlay, isMediaOnly: self.isMediaOnly, contentOffset: self.isMediaOnly ? 212.0 : self.scrollNode.view.contentOffset.y, paneContainerY: self.paneContainerNode.frame.minY, presentationData: self.presentationData, peer: self.data?.peer, cachedData: self.data?.cachedData, threadData: self.data?.threadData, peerNotificationSettings: self.data?.peerNotificationSettings, threadNotificationSettings: self.data?.threadNotificationSettings, globalNotificationSettings: self.data?.globalNotificationSettings, statusData: self.data?.status, panelStatusData: self.customStatusData, isSecretChat: self.peerId.namespace == Namespaces.Peer.SecretChat, isContact: self.data?.isContact ?? false, isSettings: self.isSettings, state: self.state, metrics: layout.metrics, deviceMetrics: layout.deviceMetrics, transition: transition, additive: additive)
if !self.isSettings && !self.state.isEditing { if !self.isSettings && !self.state.isEditing {
headerHeight += 71.0 headerHeight += 71.0
} }
@ -9054,7 +9038,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
} }
let headerInset = sectionInset let headerInset = sectionInset
let _ = self.headerNode.update(width: layout.size.width, containerHeight: layout.size.height, containerInset: headerInset, statusBarHeight: layout.statusBarHeight ?? 0.0, navigationHeight: navigationHeight, isModalOverlay: layout.isModalOverlay, isMediaOnly: self.isMediaOnly, contentOffset: self.isMediaOnly ? 212.0 : offsetY, paneContainerY: self.paneContainerNode.frame.minY, presentationData: self.presentationData, peer: self.data?.peer, cachedData: self.data?.cachedData, threadData: self.data?.threadData, notificationSettings: self.data?.notificationSettings, globalNotificationSettings: self.data?.globalNotificationSettings, statusData: self.data?.status, panelStatusData: self.customStatusData, isSecretChat: self.peerId.namespace == Namespaces.Peer.SecretChat, isContact: self.data?.isContact ?? false, isSettings: self.isSettings, state: self.state, metrics: layout.metrics, deviceMetrics: layout.deviceMetrics, transition: transition, additive: additive) let _ = self.headerNode.update(width: layout.size.width, containerHeight: layout.size.height, containerInset: headerInset, statusBarHeight: layout.statusBarHeight ?? 0.0, navigationHeight: navigationHeight, isModalOverlay: layout.isModalOverlay, isMediaOnly: self.isMediaOnly, contentOffset: self.isMediaOnly ? 212.0 : offsetY, paneContainerY: self.paneContainerNode.frame.minY, presentationData: self.presentationData, peer: self.data?.peer, cachedData: self.data?.cachedData, threadData: self.data?.threadData, peerNotificationSettings: self.data?.peerNotificationSettings, threadNotificationSettings: self.data?.threadNotificationSettings, globalNotificationSettings: self.data?.globalNotificationSettings, statusData: self.data?.status, panelStatusData: self.customStatusData, isSecretChat: self.peerId.namespace == Namespaces.Peer.SecretChat, isContact: self.data?.isContact ?? false, isSettings: self.isSettings, state: self.state, metrics: layout.metrics, deviceMetrics: layout.deviceMetrics, transition: transition, additive: additive)
} }
let paneAreaExpansionDistance: CGFloat = 32.0 let paneAreaExpansionDistance: CGFloat = 32.0
@ -10287,7 +10271,7 @@ private final class PeerInfoNavigationTransitionNode: ASDisplayNode, CustomNavig
} }
let headerInset = sectionInset let headerInset = sectionInset
topHeight = self.headerNode.update(width: layout.size.width, containerHeight: layout.size.height, containerInset: headerInset, statusBarHeight: layout.statusBarHeight ?? 0.0, navigationHeight: topNavigationBar.bounds.height, isModalOverlay: layout.isModalOverlay, isMediaOnly: false, contentOffset: 0.0, paneContainerY: 0.0, presentationData: self.presentationData, peer: self.screenNode.data?.peer, cachedData: self.screenNode.data?.cachedData, threadData: self.screenNode.data?.threadData, notificationSettings: self.screenNode.data?.notificationSettings, globalNotificationSettings: self.screenNode.data?.globalNotificationSettings, statusData: self.screenNode.data?.status, panelStatusData: (nil, nil, nil), isSecretChat: self.screenNode.peerId.namespace == Namespaces.Peer.SecretChat, isContact: self.screenNode.data?.isContact ?? false, isSettings: self.screenNode.isSettings, state: self.screenNode.state, metrics: layout.metrics, deviceMetrics: layout.deviceMetrics, transition: transition, additive: false) topHeight = self.headerNode.update(width: layout.size.width, containerHeight: layout.size.height, containerInset: headerInset, statusBarHeight: layout.statusBarHeight ?? 0.0, navigationHeight: topNavigationBar.bounds.height, isModalOverlay: layout.isModalOverlay, isMediaOnly: false, contentOffset: 0.0, paneContainerY: 0.0, presentationData: self.presentationData, peer: self.screenNode.data?.peer, cachedData: self.screenNode.data?.cachedData, threadData: self.screenNode.data?.threadData, peerNotificationSettings: self.screenNode.data?.peerNotificationSettings, threadNotificationSettings: self.screenNode.data?.threadNotificationSettings, globalNotificationSettings: self.screenNode.data?.globalNotificationSettings, statusData: self.screenNode.data?.status, panelStatusData: (nil, nil, nil), isSecretChat: self.screenNode.peerId.namespace == Namespaces.Peer.SecretChat, isContact: self.screenNode.data?.isContact ?? false, isSettings: self.screenNode.isSettings, state: self.screenNode.state, metrics: layout.metrics, deviceMetrics: layout.deviceMetrics, transition: transition, additive: false)
} }
let titleScale = (fraction * previousTitleNode.view.bounds.height + (1.0 - fraction) * self.headerNode.titleNodeRawContainer.bounds.height) / previousTitleNode.view.bounds.height let titleScale = (fraction * previousTitleNode.view.bounds.height + (1.0 - fraction) * self.headerNode.titleNodeRawContainer.bounds.height) / previousTitleNode.view.bounds.height