Indicate that a topic is closed in View as messages

This commit is contained in:
Isaac
2023-11-24 01:38:48 +04:00
parent b631780d00
commit 3aaa0ad17b
4 changed files with 22 additions and 3 deletions

View File

@@ -646,11 +646,13 @@ public final class Message {
public let title: String
public let icon: Int64?
public let iconColor: Int32
public let isClosed: Bool
public init(title: String, icon: Int64?, iconColor: Int32) {
public init(title: String, icon: Int64?, iconColor: Int32, isClosed: Bool) {
self.title = title
self.icon = icon
self.iconColor = iconColor
self.isClosed = isClosed
}
public static func ==(lhs: AssociatedThreadInfo, rhs: AssociatedThreadInfo) -> Bool {
@@ -666,6 +668,9 @@ public final class Message {
if lhs.iconColor != rhs.iconColor {
return false
}
if lhs.isClosed != rhs.isClosed {
return false
}
return true
}
}

View File

@@ -152,7 +152,7 @@ public let telegramPostboxSeedConfiguration: SeedConfiguration = {
guard let data = entry.get(MessageHistoryThreadData.self) else {
return nil
}
return Message.AssociatedThreadInfo(title: data.info.title, icon: data.info.icon, iconColor: data.info.iconColor)
return Message.AssociatedThreadInfo(title: data.info.title, icon: data.info.icon, iconColor: data.info.iconColor, isClosed: data.isClosed)
},
decodeAutoremoveTimeout: { cachedData in
if let cachedData = cachedData as? CachedUserData {

View File

@@ -197,6 +197,15 @@ func inputPanelForChatPresentationIntefaceState(_ chatPresentationInterfaceState
return (panel, nil)
}
}
} else if let replyMessage = chatPresentationInterfaceState.replyMessage, let threadInfo = replyMessage.associatedThreadInfo, threadInfo.isClosed {
if let currentPanel = (currentPanel as? ChatRestrictedInputPanelNode) ?? (currentSecondaryPanel as? ChatRestrictedInputPanelNode) {
return (currentPanel, nil)
} else {
let panel = ChatRestrictedInputPanelNode()
panel.context = context
panel.interfaceInteraction = interfaceInteraction
return (panel, nil)
}
}
}

View File

@@ -50,7 +50,12 @@ final class ChatRestrictedInputPanelNode: ChatInputPanelNode {
iconImage = PresentationResourcesChat.chatPanelLockIcon(interfaceState.theme)
self.textNode.attributedText = NSAttributedString(string: interfaceState.strings.Chat_PanelTopicClosedText, font: Font.regular(15.0), textColor: interfaceState.theme.chat.inputPanel.secondaryTextColor)
} else if let channel = interfaceState.renderedPeer?.peer as? TelegramChannel, channel.flags.contains(.isForum), case .peer = interfaceState.chatLocation {
self.textNode.attributedText = NSAttributedString(string: interfaceState.strings.Chat_PanelForumModeReplyText, font: Font.regular(15.0), textColor: interfaceState.theme.chat.inputPanel.secondaryTextColor)
if let replyMessage = interfaceState.replyMessage, let threadInfo = replyMessage.associatedThreadInfo {
//TODO:localize
self.textNode.attributedText = NSAttributedString(string: "Topic \"\(threadInfo.title)\" is closed", font: Font.regular(15.0), textColor: interfaceState.theme.chat.inputPanel.secondaryTextColor)
} else {
self.textNode.attributedText = NSAttributedString(string: interfaceState.strings.Chat_PanelForumModeReplyText, font: Font.regular(15.0), textColor: interfaceState.theme.chat.inputPanel.secondaryTextColor)
}
} else if let (untilDate, personal) = bannedPermission {
if personal && untilDate != 0 && untilDate != Int32.max {
self.textNode.attributedText = NSAttributedString(string: interfaceState.strings.Conversation_RestrictedTextTimed(stringForFullDate(timestamp: untilDate, strings: interfaceState.strings, dateTimeFormat: interfaceState.dateTimeFormat)).string, font: Font.regular(13.0), textColor: interfaceState.theme.chat.inputPanel.secondaryTextColor)