[WIP] Topics

This commit is contained in:
Ali
2022-10-23 19:34:10 +04:00
parent 8001d6b5f0
commit 79215dc012
15 changed files with 202 additions and 115 deletions

View File

@@ -32,6 +32,16 @@ public struct AdminLogEventsResult {
}
public enum AdminLogEventAction {
public struct ForumTopicInfo {
public var info: EngineMessageHistoryThread.Info
public var isClosed: Bool
public init(info: EngineMessageHistoryThread.Info, isClosed: Bool) {
self.info = info
self.isClosed = isClosed
}
}
case changeTitle(prev: String, new: String)
case changeAbout(prev: String, new: String)
case changeUsername(prev: String, new: String)
@@ -71,7 +81,7 @@ public enum AdminLogEventAction {
case changeUsernames(prev: [String], new: [String])
case createTopic(info: EngineMessageHistoryThread.Info)
case deleteTopic(info: EngineMessageHistoryThread.Info)
case editTopic(prevInfo: EngineMessageHistoryThread.Info, newInfo: EngineMessageHistoryThread.Info)
case editTopic(prevInfo: ForumTopicInfo, newInfo: ForumTopicInfo)
case pinTopic(prevInfo: EngineMessageHistoryThread.Info?, newInfo: EngineMessageHistoryThread.Info?)
case toggleForum(isForum: Bool)
}
@@ -289,20 +299,20 @@ func channelAdminLogEvents(postbox: Postbox, network: Network, peerId: PeerId, m
action = .deleteTopic(info: EngineMessageHistoryThread.Info(title: "", icon: nil, iconColor: 0))
}
case let .channelAdminLogEventActionEditTopic(prevTopic, newTopic):
let prevInfo: EngineMessageHistoryThread.Info
let prevInfo: AdminLogEventAction.ForumTopicInfo
switch prevTopic {
case let .forumTopic(_, _, _, title, iconColor, iconEmojiId, _, _, _, _, _, _, _, _, _):
prevInfo = EngineMessageHistoryThread.Info(title: title, icon: iconEmojiId, iconColor: iconColor)
case let .forumTopic(flags, _, _, title, iconColor, iconEmojiId, _, _, _, _, _, _, _, _, _):
prevInfo = AdminLogEventAction.ForumTopicInfo(info: EngineMessageHistoryThread.Info(title: title, icon: iconEmojiId, iconColor: iconColor), isClosed: (flags & (1 << 2)) != 0)
case .forumTopicDeleted:
prevInfo = EngineMessageHistoryThread.Info(title: "", icon: nil, iconColor: 0)
prevInfo = AdminLogEventAction.ForumTopicInfo(info: EngineMessageHistoryThread.Info(title: "", icon: nil, iconColor: 0), isClosed: false)
}
let newInfo: EngineMessageHistoryThread.Info
let newInfo: AdminLogEventAction.ForumTopicInfo
switch newTopic {
case let .forumTopic(_, _, _, title, iconColor, iconEmojiId, _, _, _, _, _, _, _, _, _):
newInfo = EngineMessageHistoryThread.Info(title: title, icon: iconEmojiId, iconColor: iconColor)
case let .forumTopic(flags, _, _, title, iconColor, iconEmojiId, _, _, _, _, _, _, _, _, _):
newInfo = AdminLogEventAction.ForumTopicInfo(info: EngineMessageHistoryThread.Info(title: title, icon: iconEmojiId, iconColor: iconColor), isClosed: (flags & (1 << 2)) != 0)
case .forumTopicDeleted:
newInfo = EngineMessageHistoryThread.Info(title: "", icon: nil, iconColor: 0)
newInfo = AdminLogEventAction.ForumTopicInfo(info: EngineMessageHistoryThread.Info(title: "", icon: nil, iconColor: 0), isClosed: false)
}
action = .editTopic(prevInfo: prevInfo, newInfo: newInfo)