mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Reaction improvements
This commit is contained in:
parent
7c7626f6cc
commit
b1a998b6cd
@ -7201,3 +7201,26 @@ Sorry for the inconvenience.";
|
|||||||
"AccessDenied.QrCamera" = "Telegram needs access to your camera to scan QR codes.\n\nPlease go to Settings > Privacy > Camera and set Telegram to ON.";
|
"AccessDenied.QrCamera" = "Telegram needs access to your camera to scan QR codes.\n\nPlease go to Settings > Privacy > Camera and set Telegram to ON.";
|
||||||
|
|
||||||
"Share.ShareToInstagramStories" = "Share to Instagram Stories";
|
"Share.ShareToInstagramStories" = "Share to Instagram Stories";
|
||||||
|
|
||||||
|
"PeerInfo.AllowedReactions.Title" = "Reactions";
|
||||||
|
"PeerInfo.AllowedReactions.AllowAllText" = "Allow Reactions";
|
||||||
|
"PeerInfo.AllowedReactions.AllowAllGroupInfo" = "Allow subscribers to react to group messages.";
|
||||||
|
"PeerInfo.AllowedReactions.AllowAllChannelInfo" = "Allow subscribers to react to channel posts.";
|
||||||
|
"PeerInfo.AllowedReactions.ReactionListHeader" = "AVAILABLE REACTIONS";
|
||||||
|
|
||||||
|
"PeerInfo.Reactions" = "Reactions";
|
||||||
|
"PeerInfo.ReactionsDisabled" = "Disabled";
|
||||||
|
|
||||||
|
"Settings.QuickReactionSetup.NavigationTitle" = "Quick Reaction";
|
||||||
|
"Settings.QuickReactionSetup.Title" = "Quick Reaction";
|
||||||
|
"Settings.QuickReactionSetup.DemoHeader" = "DOUBLE TAP ON MESSAGE TO REACT";
|
||||||
|
"Settings.QuickReactionSetup.DemoInfo" = "You can double tap on message for a quick reaction.";
|
||||||
|
"Settings.QuickReactionSetup.ReactionListHeader" = "QUICK REACTION";
|
||||||
|
"Settings.QuickReactionSetup.DemoMessageAuthor" = "Dino";
|
||||||
|
"Settings.QuickReactionSetup.DemoMessageText" = "I hope you're enjoying your day as much as I am.";
|
||||||
|
|
||||||
|
"Chat.ContextReactionCount_1" = "1 reaction";
|
||||||
|
"Chat.ContextReactionCount_any" = "%@ reactions";
|
||||||
|
"Chat.OutgoingContextReactionCount_1" = "1 reacted";
|
||||||
|
"Chat.OutgoingContextReactionCount_any" = "%@ reacted";
|
||||||
|
"Chat.OutgoingContextMixedReactionCount" = "%1$@/%2$@ reacted";
|
||||||
|
@ -150,16 +150,23 @@ private struct PeerAllowedReactionListControllerState: Equatable {
|
|||||||
private func peerAllowedReactionListControllerEntries(
|
private func peerAllowedReactionListControllerEntries(
|
||||||
presentationData: PresentationData,
|
presentationData: PresentationData,
|
||||||
availableReactions: AvailableReactions?,
|
availableReactions: AvailableReactions?,
|
||||||
|
peer: Peer?,
|
||||||
cachedData: CachedPeerData?,
|
cachedData: CachedPeerData?,
|
||||||
state: PeerAllowedReactionListControllerState
|
state: PeerAllowedReactionListControllerState
|
||||||
) -> [PeerAllowedReactionListControllerEntry] {
|
) -> [PeerAllowedReactionListControllerEntry] {
|
||||||
var entries: [PeerAllowedReactionListControllerEntry] = []
|
var entries: [PeerAllowedReactionListControllerEntry] = []
|
||||||
|
|
||||||
if let availableReactions = availableReactions, let allowedReactions = state.updatedAllowedReactions {
|
if let availableReactions = availableReactions, let allowedReactions = state.updatedAllowedReactions {
|
||||||
entries.append(.allowAll(text: "Allow Reactions", isEnabled: !allowedReactions.isEmpty))
|
entries.append(.allowAll(text: presentationData.strings.PeerInfo_AllowedReactions_AllowAllText, isEnabled: !allowedReactions.isEmpty))
|
||||||
entries.append(.allowAllInfo("Allow subscribers to reacts to channel posts."))
|
let allInfoText: String
|
||||||
|
if let peer = peer as? TelegramChannel, case .broadcast = peer.info {
|
||||||
|
allInfoText = presentationData.strings.PeerInfo_AllowedReactions_AllowAllChannelInfo
|
||||||
|
} else {
|
||||||
|
allInfoText = presentationData.strings.PeerInfo_AllowedReactions_AllowAllGroupInfo
|
||||||
|
}
|
||||||
|
entries.append(.allowAllInfo(allInfoText))
|
||||||
|
|
||||||
entries.append(.itemsHeader("AVAILABLE REACTIONS"))
|
entries.append(.itemsHeader(presentationData.strings.PeerInfo_AllowedReactions_ReactionListHeader))
|
||||||
var index = 0
|
var index = 0
|
||||||
for availableReaction in availableReactions.reactions {
|
for availableReaction in availableReactions.reactions {
|
||||||
if !availableReaction.isEnabled {
|
if !availableReaction.isEnabled {
|
||||||
@ -262,12 +269,12 @@ public func peerAllowedReactionListController(
|
|||||||
)
|
)
|
||||||
|> deliverOnMainQueue
|
|> deliverOnMainQueue
|
||||||
|> map { presentationData, state, availableReactions, peerView -> (ItemListControllerState, (ItemListNodeState, Any)) in
|
|> map { presentationData, state, availableReactions, peerView -> (ItemListControllerState, (ItemListNodeState, Any)) in
|
||||||
//TODO:localize
|
let title: String = presentationData.strings.PeerInfo_AllowedReactions_Title
|
||||||
let title: String = "Reactions"
|
|
||||||
|
|
||||||
let entries = peerAllowedReactionListControllerEntries(
|
let entries = peerAllowedReactionListControllerEntries(
|
||||||
presentationData: presentationData,
|
presentationData: presentationData,
|
||||||
availableReactions: availableReactions,
|
availableReactions: availableReactions,
|
||||||
|
peer: peerView.peers[peerId],
|
||||||
cachedData: peerView.cachedData,
|
cachedData: peerView.cachedData,
|
||||||
state: state
|
state: state
|
||||||
)
|
)
|
||||||
|
@ -177,8 +177,7 @@ private func quickReactionSetupControllerEntries(
|
|||||||
var entries: [QuickReactionSetupControllerEntry] = []
|
var entries: [QuickReactionSetupControllerEntry] = []
|
||||||
|
|
||||||
if let availableReactions = availableReactions {
|
if let availableReactions = availableReactions {
|
||||||
//TODO:localize
|
entries.append(.demoHeader(presentationData.strings.Settings_QuickReactionSetup_DemoHeader))
|
||||||
entries.append(.demoHeader("DOUBLE TAP ON MESSAGE TO REACT"))
|
|
||||||
entries.append(.demoMessage(
|
entries.append(.demoMessage(
|
||||||
wallpaper: presentationData.chatWallpaper,
|
wallpaper: presentationData.chatWallpaper,
|
||||||
fontSize: presentationData.chatFontSize,
|
fontSize: presentationData.chatFontSize,
|
||||||
@ -188,9 +187,9 @@ private func quickReactionSetupControllerEntries(
|
|||||||
availableReactions: availableReactions,
|
availableReactions: availableReactions,
|
||||||
reaction: reactionSettings.quickReaction
|
reaction: reactionSettings.quickReaction
|
||||||
))
|
))
|
||||||
entries.append(.demoDescription("You can double tap on message for a quick reaction."))
|
entries.append(.demoDescription(presentationData.strings.Settings_QuickReactionSetup_DemoInfo))
|
||||||
|
|
||||||
entries.append(.itemsHeader("QUICK REACTION"))
|
entries.append(.itemsHeader(presentationData.strings.Settings_QuickReactionSetup_ReactionListHeader))
|
||||||
var index = 0
|
var index = 0
|
||||||
for availableReaction in availableReactions.reactions {
|
for availableReaction in availableReactions.reactions {
|
||||||
if !availableReaction.isEnabled {
|
if !availableReaction.isEnabled {
|
||||||
@ -298,8 +297,7 @@ public func quickReactionSetupController(
|
|||||||
)
|
)
|
||||||
|> deliverOnMainQueue
|
|> deliverOnMainQueue
|
||||||
|> map { presentationData, _, availableReactions, settings, images -> (ItemListControllerState, (ItemListNodeState, Any)) in
|
|> map { presentationData, _, availableReactions, settings, images -> (ItemListControllerState, (ItemListNodeState, Any)) in
|
||||||
//TODO:localize
|
let title: String = presentationData.strings.Settings_QuickReactionSetup_Title
|
||||||
let title: String = "Quick Reaction"
|
|
||||||
|
|
||||||
let entries = quickReactionSetupControllerEntries(
|
let entries = quickReactionSetupControllerEntries(
|
||||||
presentationData: presentationData,
|
presentationData: presentationData,
|
||||||
|
@ -197,15 +197,13 @@ class ReactionChatPreviewItemNode: ListViewItemNode {
|
|||||||
let messages = SimpleDictionary<MessageId, Message>()
|
let messages = SimpleDictionary<MessageId, Message>()
|
||||||
|
|
||||||
peers[chatPeerId] = TelegramGroup(id: chatPeerId, title: "Chat", photo: [], participantCount: 1, role: .member, membership: .Member, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 1, version: 1)
|
peers[chatPeerId] = TelegramGroup(id: chatPeerId, title: "Chat", photo: [], participantCount: 1, role: .member, membership: .Member, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 1, version: 1)
|
||||||
//TODO:localize
|
peers[userPeerId] = TelegramUser(id: userPeerId, accessHash: nil, firstName: item.strings.Settings_QuickReactionSetup_DemoMessageAuthor, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||||
peers[userPeerId] = TelegramUser(id: userPeerId, accessHash: nil, firstName: "Dino", lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
|
||||||
|
|
||||||
//TODO:localize
|
let messageText = item.strings.Settings_QuickReactionSetup_DemoMessageText
|
||||||
let messageText = "I hope you're enjoying your day as much as I am."
|
|
||||||
|
|
||||||
var attributes: [MessageAttribute] = []
|
var attributes: [MessageAttribute] = []
|
||||||
if let reaction = item.reaction {
|
if let reaction = item.reaction {
|
||||||
attributes.append(ReactionsMessageAttribute(reactions: [MessageReaction(value: reaction, count: 1, isSelected: true)], recentPeers: []))
|
attributes.append(ReactionsMessageAttribute(canViewList: false, reactions: [MessageReaction(value: reaction, count: 1, isSelected: true)], recentPeers: []))
|
||||||
}
|
}
|
||||||
|
|
||||||
let messageItem = item.context.sharedContext.makeChatMessagePreviewItem(context: item.context, messages: [Message(stableId: 1, stableVersion: 0, id: MessageId(peerId: chatPeerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peers[userPeerId], text: messageText, attributes: attributes, media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [])], theme: item.theme, strings: item.strings, wallpaper: item.wallpaper, fontSize: item.fontSize, chatBubbleCorners: item.chatBubbleCorners, dateTimeFormat: item.dateTimeFormat, nameOrder: item.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: currentBackgroundNode, availableReactions: item.availableReactions)
|
let messageItem = item.context.sharedContext.makeChatMessagePreviewItem(context: item.context, messages: [Message(stableId: 1, stableVersion: 0, id: MessageId(peerId: chatPeerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peers[userPeerId], text: messageText, attributes: attributes, media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [])], theme: item.theme, strings: item.strings, wallpaper: item.wallpaper, fontSize: item.fontSize, chatBubbleCorners: item.chatBubbleCorners, dateTimeFormat: item.dateTimeFormat, nameOrder: item.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: currentBackgroundNode, availableReactions: item.availableReactions)
|
||||||
|
@ -543,8 +543,7 @@ private func installedStickerPacksControllerEntries(presentationData: Presentati
|
|||||||
}
|
}
|
||||||
entries.append(.masks(presentationData.theme, presentationData.strings.MaskStickerSettings_Title))
|
entries.append(.masks(presentationData.theme, presentationData.strings.MaskStickerSettings_Title))
|
||||||
|
|
||||||
//TODO:localize
|
entries.append(.quickReaction(presentationData.strings.Settings_QuickReactionSetup_NavigationTitle, quickReactionImage))
|
||||||
entries.append(.quickReaction("Quick Reaction", quickReactionImage))
|
|
||||||
|
|
||||||
entries.append(.animatedStickers(presentationData.theme, presentationData.strings.StickerPacksSettings_AnimatedStickers, stickerSettings.loopAnimatedStickers))
|
entries.append(.animatedStickers(presentationData.theme, presentationData.strings.StickerPacksSettings_AnimatedStickers, stickerSettings.loopAnimatedStickers))
|
||||||
entries.append(.animatedStickersInfo(presentationData.theme, presentationData.strings.StickerPacksSettings_AnimatedStickersInfo))
|
entries.append(.animatedStickersInfo(presentationData.theme, presentationData.strings.StickerPacksSettings_AnimatedStickersInfo))
|
||||||
|
@ -7,6 +7,7 @@ extension ReactionsMessageAttribute {
|
|||||||
switch reactions {
|
switch reactions {
|
||||||
case let .messageReactions(flags, results, recentReactions):
|
case let .messageReactions(flags, results, recentReactions):
|
||||||
let min = (flags & (1 << 0)) != 0
|
let min = (flags & (1 << 0)) != 0
|
||||||
|
let canViewList = (flags & (1 << 2)) != 0
|
||||||
var reactions = results.map { result -> MessageReaction in
|
var reactions = results.map { result -> MessageReaction in
|
||||||
switch result {
|
switch result {
|
||||||
case let .reactionCount(flags, reaction, count):
|
case let .reactionCount(flags, reaction, count):
|
||||||
@ -41,7 +42,7 @@ extension ReactionsMessageAttribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ReactionsMessageAttribute(reactions: reactions, recentPeers: parsedRecentReactions)
|
return ReactionsMessageAttribute(canViewList: canViewList, reactions: reactions, recentPeers: parsedRecentReactions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,7 +117,7 @@ public func mergedMessageReactions(attributes: [MessageAttribute]) -> ReactionsM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !reactions.isEmpty {
|
if !reactions.isEmpty {
|
||||||
return ReactionsMessageAttribute(reactions: reactions, recentPeers: recentPeers)
|
return ReactionsMessageAttribute(canViewList: current?.canViewList ?? false, reactions: reactions, recentPeers: recentPeers)
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -130,7 +131,8 @@ public func mergedMessageReactions(attributes: [MessageAttribute]) -> ReactionsM
|
|||||||
extension ReactionsMessageAttribute {
|
extension ReactionsMessageAttribute {
|
||||||
convenience init(apiReactions: Api.MessageReactions) {
|
convenience init(apiReactions: Api.MessageReactions) {
|
||||||
switch apiReactions {
|
switch apiReactions {
|
||||||
case let .messageReactions(_, results, recentReactions):
|
case let .messageReactions(flags, results, recentReactions):
|
||||||
|
let canViewList = (flags & (1 << 2)) != 0
|
||||||
let parsedRecentReactions: [ReactionsMessageAttribute.RecentPeer]
|
let parsedRecentReactions: [ReactionsMessageAttribute.RecentPeer]
|
||||||
if let recentReactions = recentReactions {
|
if let recentReactions = recentReactions {
|
||||||
parsedRecentReactions = recentReactions.map { recentReaction -> ReactionsMessageAttribute.RecentPeer in
|
parsedRecentReactions = recentReactions.map { recentReaction -> ReactionsMessageAttribute.RecentPeer in
|
||||||
@ -144,6 +146,7 @@ extension ReactionsMessageAttribute {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.init(
|
self.init(
|
||||||
|
canViewList: canViewList,
|
||||||
reactions: results.map { result in
|
reactions: results.map { result in
|
||||||
switch result {
|
switch result {
|
||||||
case let .reactionCount(flags, reaction, count):
|
case let .reactionCount(flags, reaction, count):
|
||||||
|
@ -51,6 +51,7 @@ public final class ReactionsMessageAttribute: Equatable, MessageAttribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public let canViewList: Bool
|
||||||
public let reactions: [MessageReaction]
|
public let reactions: [MessageReaction]
|
||||||
public let recentPeers: [RecentPeer]
|
public let recentPeers: [RecentPeer]
|
||||||
|
|
||||||
@ -58,22 +59,28 @@ public final class ReactionsMessageAttribute: Equatable, MessageAttribute {
|
|||||||
return self.recentPeers.map(\.peerId)
|
return self.recentPeers.map(\.peerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(reactions: [MessageReaction], recentPeers: [RecentPeer]) {
|
public init(canViewList: Bool, reactions: [MessageReaction], recentPeers: [RecentPeer]) {
|
||||||
|
self.canViewList = canViewList
|
||||||
self.reactions = reactions
|
self.reactions = reactions
|
||||||
self.recentPeers = recentPeers
|
self.recentPeers = recentPeers
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init(decoder: PostboxDecoder) {
|
required public init(decoder: PostboxDecoder) {
|
||||||
|
self.canViewList = decoder.decodeBoolForKey("vl", orElse: true)
|
||||||
self.reactions = decoder.decodeObjectArrayWithDecoderForKey("r")
|
self.reactions = decoder.decodeObjectArrayWithDecoderForKey("r")
|
||||||
self.recentPeers = decoder.decodeObjectArrayWithDecoderForKey("rp")
|
self.recentPeers = decoder.decodeObjectArrayWithDecoderForKey("rp")
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(_ encoder: PostboxEncoder) {
|
public func encode(_ encoder: PostboxEncoder) {
|
||||||
|
encoder.encodeBool(self.canViewList, forKey: "vl")
|
||||||
encoder.encodeObjectArray(self.reactions, forKey: "r")
|
encoder.encodeObjectArray(self.reactions, forKey: "r")
|
||||||
encoder.encodeObjectArray(self.recentPeers, forKey: "rp")
|
encoder.encodeObjectArray(self.recentPeers, forKey: "rp")
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func ==(lhs: ReactionsMessageAttribute, rhs: ReactionsMessageAttribute) -> Bool {
|
public static func ==(lhs: ReactionsMessageAttribute, rhs: ReactionsMessageAttribute) -> Bool {
|
||||||
|
if lhs.canViewList != rhs.canViewList {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if lhs.reactions != rhs.reactions {
|
if lhs.reactions != rhs.reactions {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -1978,13 +1978,7 @@ private final class ChatReadReportContextItemNode: ASDisplayNode, ContextMenuCus
|
|||||||
if let currentStats = self.currentStats {
|
if let currentStats = self.currentStats {
|
||||||
if currentStats.peers.isEmpty {
|
if currentStats.peers.isEmpty {
|
||||||
if reactionCount != 0 {
|
if reactionCount != 0 {
|
||||||
//TODO:localize
|
let text: String = self.presentationData.strings.Chat_ContextReactionCount(Int32(reactionCount))
|
||||||
let text: String
|
|
||||||
if reactionCount == 1 {
|
|
||||||
text = "1 reaction"
|
|
||||||
} else {
|
|
||||||
text = "\(reactionCount) reactions"
|
|
||||||
}
|
|
||||||
self.textNode.attributedText = NSAttributedString(string: text, font: textFont, textColor: self.presentationData.theme.contextMenu.primaryColor)
|
self.textNode.attributedText = NSAttributedString(string: text, font: textFont, textColor: self.presentationData.theme.contextMenu.primaryColor)
|
||||||
} else {
|
} else {
|
||||||
var text = self.presentationData.strings.Conversation_ContextMenuNoViews
|
var text = self.presentationData.strings.Conversation_ContextMenuNoViews
|
||||||
@ -2002,29 +1996,18 @@ private final class ChatReadReportContextItemNode: ASDisplayNode, ContextMenuCus
|
|||||||
}
|
}
|
||||||
} else if currentStats.peers.count == 1 {
|
} else if currentStats.peers.count == 1 {
|
||||||
if reactionCount != 0 {
|
if reactionCount != 0 {
|
||||||
//TODO:localize
|
let text: String = self.presentationData.strings.Chat_OutgoingContextReactionCount(Int32(reactionCount))
|
||||||
let text: String
|
|
||||||
if reactionCount == 1 {
|
|
||||||
text = "1 reacted"
|
|
||||||
} else {
|
|
||||||
text = "\(reactionCount) reacted"
|
|
||||||
}
|
|
||||||
self.textNode.attributedText = NSAttributedString(string: text, font: textFont, textColor: self.presentationData.theme.contextMenu.primaryColor)
|
self.textNode.attributedText = NSAttributedString(string: text, font: textFont, textColor: self.presentationData.theme.contextMenu.primaryColor)
|
||||||
} else {
|
} else {
|
||||||
self.textNode.attributedText = NSAttributedString(string: currentStats.peers[0].displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder), font: textFont, textColor: self.presentationData.theme.contextMenu.primaryColor)
|
self.textNode.attributedText = NSAttributedString(string: currentStats.peers[0].displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder), font: textFont, textColor: self.presentationData.theme.contextMenu.primaryColor)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if reactionCount != 0 {
|
if reactionCount != 0 {
|
||||||
//TODO:localize
|
|
||||||
let text: String
|
let text: String
|
||||||
if reactionCount >= currentStats.peers.count {
|
if reactionCount >= currentStats.peers.count {
|
||||||
if reactionCount == 1 {
|
text = self.presentationData.strings.Chat_OutgoingContextReactionCount(Int32(reactionCount))
|
||||||
text = "1 reacted"
|
|
||||||
} else {
|
} else {
|
||||||
text = "\(reactionCount) reacted"
|
text = self.presentationData.strings.Chat_OutgoingContextMixedReactionCount("\(reactionCount)", "\(currentStats.peers.count)").string
|
||||||
}
|
|
||||||
} else {
|
|
||||||
text = "\(reactionCount)/\(currentStats.peers.count) reacted"
|
|
||||||
}
|
}
|
||||||
self.textNode.attributedText = NSAttributedString(string: text, font: textFont, textColor: self.presentationData.theme.contextMenu.primaryColor)
|
self.textNode.attributedText = NSAttributedString(string: text, font: textFont, textColor: self.presentationData.theme.contextMenu.primaryColor)
|
||||||
} else {
|
} else {
|
||||||
|
@ -1111,9 +1111,9 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
|
|
||||||
let reactions: ReactionsMessageAttribute
|
let reactions: ReactionsMessageAttribute
|
||||||
if shouldDisplayInlineDateReactions(message: item.message) {
|
if shouldDisplayInlineDateReactions(message: item.message) {
|
||||||
reactions = ReactionsMessageAttribute(reactions: [], recentPeers: [])
|
reactions = ReactionsMessageAttribute(canViewList: false, reactions: [], recentPeers: [])
|
||||||
} else {
|
} else {
|
||||||
reactions = mergedMessageReactions(attributes: item.message.attributes) ?? ReactionsMessageAttribute(reactions: [], recentPeers: [])
|
reactions = mergedMessageReactions(attributes: item.message.attributes) ?? ReactionsMessageAttribute(canViewList: false, reactions: [], recentPeers: [])
|
||||||
}
|
}
|
||||||
var reactionButtonsFinalize: ((CGFloat) -> (CGSize, (_ animation: ListViewItemUpdateAnimation) -> ChatMessageReactionButtonsNode))?
|
var reactionButtonsFinalize: ((CGFloat) -> (CGSize, (_ animation: ListViewItemUpdateAnimation) -> ChatMessageReactionButtonsNode))?
|
||||||
if !reactions.reactions.isEmpty {
|
if !reactions.reactions.isEmpty {
|
||||||
|
@ -1435,9 +1435,9 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
|||||||
|
|
||||||
let bubbleReactions: ReactionsMessageAttribute
|
let bubbleReactions: ReactionsMessageAttribute
|
||||||
if needReactions {
|
if needReactions {
|
||||||
bubbleReactions = mergedMessageReactions(attributes: item.message.attributes) ?? ReactionsMessageAttribute(reactions: [], recentPeers: [])
|
bubbleReactions = mergedMessageReactions(attributes: item.message.attributes) ?? ReactionsMessageAttribute(canViewList: false, reactions: [], recentPeers: [])
|
||||||
} else {
|
} else {
|
||||||
bubbleReactions = ReactionsMessageAttribute(reactions: [], recentPeers: [])
|
bubbleReactions = ReactionsMessageAttribute(canViewList: false, reactions: [], recentPeers: [])
|
||||||
}
|
}
|
||||||
if !bubbleReactions.reactions.isEmpty {
|
if !bubbleReactions.reactions.isEmpty {
|
||||||
bottomNodeMergeStatus = .Both
|
bottomNodeMergeStatus = .Both
|
||||||
|
@ -549,9 +549,9 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
|
|||||||
|
|
||||||
let reactions: ReactionsMessageAttribute
|
let reactions: ReactionsMessageAttribute
|
||||||
if shouldDisplayInlineDateReactions(message: item.message) {
|
if shouldDisplayInlineDateReactions(message: item.message) {
|
||||||
reactions = ReactionsMessageAttribute(reactions: [], recentPeers: [])
|
reactions = ReactionsMessageAttribute(canViewList: false, reactions: [], recentPeers: [])
|
||||||
} else {
|
} else {
|
||||||
reactions = mergedMessageReactions(attributes: item.message.attributes) ?? ReactionsMessageAttribute(reactions: [], recentPeers: [])
|
reactions = mergedMessageReactions(attributes: item.message.attributes) ?? ReactionsMessageAttribute(canViewList: false, reactions: [], recentPeers: [])
|
||||||
}
|
}
|
||||||
|
|
||||||
var reactionButtonsFinalize: ((CGFloat) -> (CGSize, (_ animation: ListViewItemUpdateAnimation) -> ChatMessageReactionButtonsNode))?
|
var reactionButtonsFinalize: ((CGFloat) -> (CGSize, (_ animation: ListViewItemUpdateAnimation) -> ChatMessageReactionButtonsNode))?
|
||||||
|
@ -14,6 +14,20 @@ import AccountContext
|
|||||||
import WallpaperBackgroundNode
|
import WallpaperBackgroundNode
|
||||||
|
|
||||||
func canViewMessageReactionList(message: Message) -> Bool {
|
func canViewMessageReactionList(message: Message) -> Bool {
|
||||||
|
var found = false
|
||||||
|
for attribute in message.attributes {
|
||||||
|
if let attribute = attribute as? ReactionsMessageAttribute {
|
||||||
|
if !attribute.canViewList {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
found = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !found {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
if let peer = message.peers[message.id.peerId] {
|
if let peer = message.peers[message.id.peerId] {
|
||||||
if let channel = peer as? TelegramChannel {
|
if let channel = peer as? TelegramChannel {
|
||||||
if case .broadcast = channel.info {
|
if case .broadcast = channel.info {
|
||||||
@ -487,7 +501,7 @@ final class ChatMessageReactionsFooterContentNode: ChatMessageBubbleContentNode
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (contentProperties, nil, CGFloat.greatestFiniteMagnitude, { constrainedSize, position in
|
return (contentProperties, nil, CGFloat.greatestFiniteMagnitude, { constrainedSize, position in
|
||||||
let reactionsAttribute = mergedMessageReactions(attributes: item.message.attributes) ?? ReactionsMessageAttribute(reactions: [], recentPeers: [])
|
let reactionsAttribute = mergedMessageReactions(attributes: item.message.attributes) ?? ReactionsMessageAttribute(canViewList: false, reactions: [], recentPeers: [])
|
||||||
let buttonsUpdate = buttonsNode.prepareUpdate(
|
let buttonsUpdate = buttonsNode.prepareUpdate(
|
||||||
context: item.context,
|
context: item.context,
|
||||||
presentationData: item.presentationData,
|
presentationData: item.presentationData,
|
||||||
|
@ -655,9 +655,9 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
|
|||||||
|
|
||||||
let reactions: ReactionsMessageAttribute
|
let reactions: ReactionsMessageAttribute
|
||||||
if shouldDisplayInlineDateReactions(message: item.message) {
|
if shouldDisplayInlineDateReactions(message: item.message) {
|
||||||
reactions = ReactionsMessageAttribute(reactions: [], recentPeers: [])
|
reactions = ReactionsMessageAttribute(canViewList: false, reactions: [], recentPeers: [])
|
||||||
} else {
|
} else {
|
||||||
reactions = mergedMessageReactions(attributes: item.message.attributes) ?? ReactionsMessageAttribute(reactions: [], recentPeers: [])
|
reactions = mergedMessageReactions(attributes: item.message.attributes) ?? ReactionsMessageAttribute(canViewList: false, reactions: [], recentPeers: [])
|
||||||
}
|
}
|
||||||
|
|
||||||
var reactionButtonsFinalize: ((CGFloat) -> (CGSize, (_ animation: ListViewItemUpdateAnimation) -> ChatMessageReactionButtonsNode))?
|
var reactionButtonsFinalize: ((CGFloat) -> (CGSize, (_ animation: ListViewItemUpdateAnimation) -> ChatMessageReactionButtonsNode))?
|
||||||
|
@ -1181,18 +1181,17 @@ private func editingItems(data: PeerInfoScreenData?, context: AccountContext, pr
|
|||||||
}
|
}
|
||||||
|
|
||||||
if isCreator || (channel.adminRights?.rights.contains(.canChangeInfo) == true) {
|
if isCreator || (channel.adminRights?.rights.contains(.canChangeInfo) == true) {
|
||||||
//TODO:localize
|
|
||||||
let label: String
|
let label: String
|
||||||
if let cachedData = data.cachedData as? CachedChannelData, let allowedReactions = cachedData.allowedReactions {
|
if let cachedData = data.cachedData as? CachedChannelData, let allowedReactions = cachedData.allowedReactions {
|
||||||
if allowedReactions.isEmpty {
|
if allowedReactions.isEmpty {
|
||||||
label = "Disabled"
|
label = presentationData.strings.PeerInfo_ReactionsDisabled
|
||||||
} else {
|
} else {
|
||||||
label = "\(allowedReactions.count)"
|
label = "\(allowedReactions.count)"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
label = ""
|
label = ""
|
||||||
}
|
}
|
||||||
items[.peerSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemReactions, label: .text(label), text: "Reactions", icon: UIImage(bundleImageName: "Settings/Menu/Reactions"), action: {
|
items[.peerSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemReactions, label: .text(label), text: presentationData.strings.PeerInfo_Reactions, icon: UIImage(bundleImageName: "Settings/Menu/Reactions"), action: {
|
||||||
interaction.editingOpenReactionsSetup()
|
interaction.editingOpenReactionsSetup()
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@ -1306,18 +1305,17 @@ private func editingItems(data: PeerInfoScreenData?, context: AccountContext, pr
|
|||||||
}
|
}
|
||||||
|
|
||||||
if isCreator || (channel.adminRights?.rights.contains(.canChangeInfo) == true) {
|
if isCreator || (channel.adminRights?.rights.contains(.canChangeInfo) == true) {
|
||||||
//TODO:localize
|
|
||||||
let label: String
|
let label: String
|
||||||
if let cachedData = data.cachedData as? CachedChannelData, let allowedReactions = cachedData.allowedReactions {
|
if let cachedData = data.cachedData as? CachedChannelData, let allowedReactions = cachedData.allowedReactions {
|
||||||
if allowedReactions.isEmpty {
|
if allowedReactions.isEmpty {
|
||||||
label = "Disabled"
|
label = presentationData.strings.PeerInfo_ReactionsDisabled
|
||||||
} else {
|
} else {
|
||||||
label = "\(allowedReactions.count)"
|
label = "\(allowedReactions.count)"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
label = ""
|
label = ""
|
||||||
}
|
}
|
||||||
items[.peerPublicSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemReactions, label: .text(label), text: "Reactions", icon: UIImage(bundleImageName: "Settings/Menu/Reactions"), action: {
|
items[.peerPublicSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemReactions, label: .text(label), text: presentationData.strings.PeerInfo_Reactions, icon: UIImage(bundleImageName: "Settings/Menu/Reactions"), action: {
|
||||||
interaction.editingOpenReactionsSetup()
|
interaction.editingOpenReactionsSetup()
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@ -1329,18 +1327,17 @@ private func editingItems(data: PeerInfoScreenData?, context: AccountContext, pr
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if isCreator || (channel.adminRights?.rights.contains(.canChangeInfo) == true) {
|
if isCreator || (channel.adminRights?.rights.contains(.canChangeInfo) == true) {
|
||||||
//TODO:localize
|
|
||||||
let label: String
|
let label: String
|
||||||
if let cachedData = data.cachedData as? CachedChannelData, let allowedReactions = cachedData.allowedReactions {
|
if let cachedData = data.cachedData as? CachedChannelData, let allowedReactions = cachedData.allowedReactions {
|
||||||
if allowedReactions.isEmpty {
|
if allowedReactions.isEmpty {
|
||||||
label = "Disabled"
|
label = presentationData.strings.PeerInfo_ReactionsDisabled
|
||||||
} else {
|
} else {
|
||||||
label = "\(allowedReactions.count)"
|
label = "\(allowedReactions.count)"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
label = ""
|
label = ""
|
||||||
}
|
}
|
||||||
items[.peerPublicSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemReactions, label: .text(label), text: "Reactions", icon: UIImage(bundleImageName: "Settings/Menu/Reactions"), action: {
|
items[.peerPublicSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemReactions, label: .text(label), text: presentationData.strings.PeerInfo_Reactions, icon: UIImage(bundleImageName: "Settings/Menu/Reactions"), action: {
|
||||||
interaction.editingOpenReactionsSetup()
|
interaction.editingOpenReactionsSetup()
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@ -1440,18 +1437,17 @@ private func editingItems(data: PeerInfoScreenData?, context: AccountContext, pr
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
do {
|
do {
|
||||||
//TODO:localize
|
|
||||||
let label: String
|
let label: String
|
||||||
if let cachedData = data.cachedData as? CachedGroupData, let allowedReactions = cachedData.allowedReactions {
|
if let cachedData = data.cachedData as? CachedGroupData, let allowedReactions = cachedData.allowedReactions {
|
||||||
if allowedReactions.isEmpty {
|
if allowedReactions.isEmpty {
|
||||||
label = "Disabled"
|
label = presentationData.strings.PeerInfo_ReactionsDisabled
|
||||||
} else {
|
} else {
|
||||||
label = "\(allowedReactions.count)"
|
label = "\(allowedReactions.count)"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
label = ""
|
label = ""
|
||||||
}
|
}
|
||||||
items[.peerSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemReactions, label: .text(label), text: "Reactions", icon: UIImage(bundleImageName: "Settings/Menu/Reactions"), action: {
|
items[.peerSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemReactions, label: .text(label), text: presentationData.strings.PeerInfo_Reactions, icon: UIImage(bundleImageName: "Settings/Menu/Reactions"), action: {
|
||||||
interaction.editingOpenReactionsSetup()
|
interaction.editingOpenReactionsSetup()
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user