Various fixes

This commit is contained in:
Ilya Laktyushin
2023-11-22 12:40:30 +04:00
parent ac7d53ea52
commit ab2e83fb66
2 changed files with 65 additions and 52 deletions

View File

@@ -732,6 +732,15 @@ public enum ChatControllerSubject: Equatable {
} }
} }
} }
public var isService: Bool {
switch self {
case .message:
return false
default:
return true
}
}
} }
public enum ChatControllerPresentationMode: Equatable { public enum ChatControllerPresentationMode: Equatable {

View File

@@ -54,58 +54,62 @@ func chatHistoryEntriesForView(
} }
var joinMessage: Message? var joinMessage: Message?
if case let .peer(peerId) = location, case let cachedData = cachedData as? CachedChannelData, let invitedOn = cachedData?.invitedOn { if (associatedData.subject?.isService ?? false) {
joinMessage = Message(
stableId: UInt32.max - 1000, } else {
stableVersion: 0, if case let .peer(peerId) = location, case let cachedData = cachedData as? CachedChannelData, let invitedOn = cachedData?.invitedOn {
id: MessageId(peerId: peerId, namespace: Namespaces.Message.Local, id: 0), joinMessage = Message(
globallyUniqueId: nil, stableId: UInt32.max - 1000,
groupingKey: nil, stableVersion: 0,
groupInfo: nil, id: MessageId(peerId: peerId, namespace: Namespaces.Message.Local, id: 0),
threadId: nil, globallyUniqueId: nil,
timestamp: invitedOn, groupingKey: nil,
flags: [.Incoming], groupInfo: nil,
tags: [], threadId: nil,
globalTags: [], timestamp: invitedOn,
localTags: [], flags: [.Incoming],
forwardInfo: nil, tags: [],
author: channelPeer, globalTags: [],
text: "", localTags: [],
attributes: [], forwardInfo: nil,
media: [TelegramMediaAction(action: .joinedByRequest)], author: channelPeer,
peers: SimpleDictionary<PeerId, Peer>(), text: "",
associatedMessages: SimpleDictionary<MessageId, Message>(), attributes: [],
associatedMessageIds: [], media: [TelegramMediaAction(action: .joinedByRequest)],
associatedMedia: [:], peers: SimpleDictionary<PeerId, Peer>(),
associatedThreadInfo: nil, associatedMessages: SimpleDictionary<MessageId, Message>(),
associatedStories: [:] associatedMessageIds: [],
) associatedMedia: [:],
} else if let peer = channelPeer as? TelegramChannel, case .broadcast = peer.info, case .member = peer.participationStatus { associatedThreadInfo: nil,
joinMessage = Message( associatedStories: [:]
stableId: UInt32.max - 1000, )
stableVersion: 0, } else if let peer = channelPeer as? TelegramChannel, case .broadcast = peer.info, case .member = peer.participationStatus {
id: MessageId(peerId: peer.id, namespace: Namespaces.Message.Local, id: 0), joinMessage = Message(
globallyUniqueId: nil, stableId: UInt32.max - 1000,
groupingKey: nil, stableVersion: 0,
groupInfo: nil, id: MessageId(peerId: peer.id, namespace: Namespaces.Message.Local, id: 0),
threadId: nil, globallyUniqueId: nil,
timestamp: peer.creationDate, groupingKey: nil,
flags: [.Incoming], groupInfo: nil,
tags: [], threadId: nil,
globalTags: [], timestamp: peer.creationDate,
localTags: [], flags: [.Incoming],
forwardInfo: nil, tags: [],
author: channelPeer, globalTags: [],
text: "", localTags: [],
attributes: [], forwardInfo: nil,
media: [TelegramMediaAction(action: .joinedChannel)], author: channelPeer,
peers: SimpleDictionary<PeerId, Peer>(), text: "",
associatedMessages: SimpleDictionary<MessageId, Message>(), attributes: [],
associatedMessageIds: [], media: [TelegramMediaAction(action: .joinedChannel)],
associatedMedia: [:], peers: SimpleDictionary<PeerId, Peer>(),
associatedThreadInfo: nil, associatedMessages: SimpleDictionary<MessageId, Message>(),
associatedStories: [:] associatedMessageIds: [],
) associatedMedia: [:],
associatedThreadInfo: nil,
associatedStories: [:]
)
}
} }
var existingGroupStableIds: [UInt32] = [] var existingGroupStableIds: [UInt32] = []