Skip to content

Commit

Permalink
- bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
overtake committed May 21, 2024
1 parent e7ebba9 commit d782a14
Show file tree
Hide file tree
Showing 48 changed files with 699 additions and 120 deletions.
8 changes: 4 additions & 4 deletions Telegram-Mac/AccountViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -631,15 +631,15 @@ private func accountInfoEntries(peerView:PeerView, context: AccountContext, acco
if !context.premiumIsBlocked {
entries.append(.premium(index: index, viewType: .singleItem))
index += 1

entries.append(.stars(index: index, viewType: .singleItem))
index += 1

entries.append(.business(index: index, viewType: .singleItem))
index += 1

entries.append(.giftPremium(index: index, viewType: .singleItem))
index += 1

entries.append(.stars(index: index, viewType: .singleItem))
index += 1


entries.append(.whiteSpace(index: index, height: 20))
index += 1
Expand Down
2 changes: 1 addition & 1 deletion Telegram-Mac/ApplicationContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ final class AuthorizedApplicationContext: NSObject, SplitViewDelegate {
#if DEBUG
self.context.window.set(handler: { _ -> KeyHandlerResult in

showModal(with: FactCheckController(context: context), for: context.window)
// showModal(with: FactCheckController(context: context), for: context.window)
// showModal(with: Star_PurschaseInApp(context: context, peerId: context.peerId), for: context.window)

// context.bindings.rootNavigation().push(HashtagSearchController(context, hashtag: "#test", peerId: context.peerId))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"filename" : "menu_verification.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 27 additions & 6 deletions Telegram-Mac/ChatController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1946,6 +1946,7 @@ class ChatController: EditableViewController<ChatControllerView>, Notifable, Tab
var presentation_genuie:TelegramPresentationTheme = theme
var bespoke_wallpaper: ThemeWallpaper?
var presentation_emoticon: String? = nil
var factCheck: Set<MessageId> = Set()

var answersAndOnline: ChatTitleCounters = .init()

Expand All @@ -1966,7 +1967,7 @@ class ChatController: EditableViewController<ChatControllerView>, Notifable, Tab
private let extendedMediaProcessingManager = ChatMessageVisibleThrottledProcessingManager()
private let seenLiveLocationProcessingManager = ChatMessageThrottledProcessingManager()
private let refreshMediaProcessingManager = ChatMessageThrottledProcessingManager()

private let factCheckProcessingManager = ChatMessageThrottledProcessingManager(submitInterval: 1.0)



Expand Down Expand Up @@ -3080,7 +3081,7 @@ class ChatController: EditableViewController<ChatControllerView>, Notifable, Tab
includeJoin = false
}

let entries = messageEntries(msgEntries, location: chatLocation, maxReadIndex: maxReadIndex, dayGrouping: customChatContents == nil, renderType: chatTheme.bubbled ? .bubble : .list, includeBottom: true, timeDifference: timeDifference, ranks: ranks, pollAnswersLoading: pollAnswersLoading, threadLoading: threadLoading, groupingPhotos: true, autoplayMedia: initialData.autoplayMedia, searchState: searchState, animatedEmojiStickers: bigEmojiEnabled ? animatedEmojiStickers : [:], topFixedMessages: topMessages, customChannelDiscussionReadState: customChannelDiscussionReadState, customThreadOutgoingReadState: customThreadOutgoingReadState, addRepliesHeader: peerId == repliesPeerId && view.earlierId == nil, updatingMedia: updatingMedia, adMessage: ads.fixed, dynamicAdMessages: ads.opportunistic, chatTheme: chatTheme, reactions: reactions, transribeState: uiState.transribe, topicCreatorId: uiState.topicCreatorId, mediaRevealed: uiState.mediaRevealed, translate: uiState.translate, storyState: uiState.storyState, peerStoryStats: view.peerStoryStats, cachedData: peerView?.cachedData, peer: peer, holeLater: view.holeLater, holeEarlier: view.holeEarlier, recommendedChannels: recommendedChannels, includeJoin: includeJoin, earlierId: view.earlierId, laterId: view.laterId, automaticDownload: initialData.autodownloadSettings, savedMessageTags: savedMessageTags, contentSettings: context.contentSettings, codeSyntaxData: uiState.codeSyntaxes, messageEffects: messageEffects).map { ChatWrappedEntry(appearance: AppearanceWrapperEntry(entry: $0, appearance: appearance), tag: view.tag) }
let entries = messageEntries(msgEntries, location: chatLocation, maxReadIndex: maxReadIndex, dayGrouping: customChatContents == nil, renderType: chatTheme.bubbled ? .bubble : .list, includeBottom: true, timeDifference: timeDifference, ranks: ranks, pollAnswersLoading: pollAnswersLoading, threadLoading: threadLoading, groupingPhotos: true, autoplayMedia: initialData.autoplayMedia, searchState: searchState, animatedEmojiStickers: bigEmojiEnabled ? animatedEmojiStickers : [:], topFixedMessages: topMessages, customChannelDiscussionReadState: customChannelDiscussionReadState, customThreadOutgoingReadState: customThreadOutgoingReadState, addRepliesHeader: peerId == repliesPeerId && view.earlierId == nil, updatingMedia: updatingMedia, adMessage: ads.fixed, dynamicAdMessages: ads.opportunistic, chatTheme: chatTheme, reactions: reactions, transribeState: uiState.transribe, topicCreatorId: uiState.topicCreatorId, mediaRevealed: uiState.mediaRevealed, translate: uiState.translate, storyState: uiState.storyState, peerStoryStats: view.peerStoryStats, cachedData: peerView?.cachedData, peer: peer, holeLater: view.holeLater, holeEarlier: view.holeEarlier, recommendedChannels: recommendedChannels, includeJoin: includeJoin, earlierId: view.earlierId, laterId: view.laterId, automaticDownload: initialData.autodownloadSettings, savedMessageTags: savedMessageTags, contentSettings: context.contentSettings, codeSyntaxData: uiState.codeSyntaxes, messageEffects: messageEffects, factCheckRevealed: uiState.factCheck).map { ChatWrappedEntry(appearance: AppearanceWrapperEntry(entry: $0, appearance: appearance), tag: view.tag) }
proccesedView = ChatHistoryView(originalView: view, filteredEntries: entries, theme: chatTheme)
}
} else {
Expand Down Expand Up @@ -4487,7 +4488,17 @@ class ChatController: EditableViewController<ChatControllerView>, Notifable, Tab

}


chatInteraction.revealFactCheck = { [weak self] messageId in
self?.updateState { current in
var current = current
if current.factCheck.contains(messageId) {
current.factCheck.remove(messageId)
} else {
current.factCheck.insert(messageId)
}
return current
}
}


chatInteraction.scrollToTheFirst = { [weak self] in
Expand Down Expand Up @@ -6574,7 +6585,7 @@ class ChatController: EditableViewController<ChatControllerView>, Notifable, Tab
var messageIdsWithRefreshStories: [MessageId] = []
var messageIdsWithLiveLocation: [MessageId] = []
var messageIdsWithInactiveExtendedMedia = Set<MessageId>()

var messageIdsToFactCheck: [MessageId] = []


var messagesToTranslate: [Message] = []
Expand All @@ -6599,13 +6610,15 @@ class ChatController: EditableViewController<ChatControllerView>, Notifable, Tab
var contentRequiredValidation = false
var mediaRequiredValidation = false
var storiesRequiredValidation = false

var factCheckRequired = false

for attribute in message.attributes {
if let _ = attribute as? ContentRequiresValidationMessageAttribute {
contentRequiredValidation = true
} else if let _ = attribute as? ReplyStoryAttribute {
storiesRequiredValidation = true
} else if let attribute = attribute as? FactCheckMessageAttribute, case .Pending = attribute.content {
factCheckRequired = true
}
}

Expand Down Expand Up @@ -6656,7 +6669,9 @@ class ChatController: EditableViewController<ChatControllerView>, Notifable, Tab
if storiesRequiredValidation {
messageIdsWithRefreshStories.append(message.id)
}

if factCheckRequired {
messageIdsToFactCheck.append(message.id)
}

if message.tags.contains(.unseenPersonalMessage) {
for attribute in message.attributes {
Expand Down Expand Up @@ -6766,6 +6781,9 @@ class ChatController: EditableViewController<ChatControllerView>, Notifable, Tab
if !messageIdsWithRefreshStories.isEmpty {
strongSelf.refreshStoriesProcessingManager.add(messageIdsWithRefreshStories)
}
if !messageIdsToFactCheck.isEmpty {
strongSelf.factCheckProcessingManager.add(messageIdsToFactCheck)
}

if !messageIdsWithUnseenPersonalMention.isEmpty {
strongSelf.messageMentionProcessingManager.add(messageIdsWithUnseenPersonalMention)
Expand Down Expand Up @@ -8579,6 +8597,9 @@ class ChatController: EditableViewController<ChatControllerView>, Notifable, Tab
self.messageProcessingManager.process = { messageIds in
context.account.viewTracker.updateViewCountForMessageIds(messageIds: messageIds.filter({$0.namespace == Namespaces.Message.Cloud}), clientId: clientId)
}
self.factCheckProcessingManager.process = { messageIds in
_ = context.engine.messages.getMessagesFactCheck(messageIds: Array(messageIds)).startStandalone()
}

self.unsupportedMessageProcessingManager.process = { messageIds in
let msgIds = messageIds.filter { $0.namespace == Namespaces.Message.Cloud }.map { MessageAndThreadId(messageId: $0, threadId: mode.threadId64) }
Expand Down
8 changes: 5 additions & 3 deletions Telegram-Mac/ChatHistoryEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ struct MessageEntryAdditionalData : Equatable {
let savedMessageTags: SavedMessageTags?
let codeSyntaxData: [CodeSyntaxKey : CodeSyntaxResult]
let messageEffect: AvailableMessageEffects.MessageEffect?
init(pollStateData: ChatPollStateData = ChatPollStateData(), highlightFoundText: HighlightFoundText? = nil, isThreadLoading: Bool = false, updatingMedia: ChatUpdatingMessageMedia? = nil, chatTheme: TelegramPresentationTheme? = nil, reactions: AvailableReactions? = nil, animatedEmojiStickers: [String: StickerPackItem] = [:], transribeState:TranscribeAudioState? = nil, eventLog: AdminLogEvent? = nil, isRevealed: Bool? = nil, translate: ChatLiveTranslateContext.State.Result? = nil, replyTranslate: ChatLiveTranslateContext.State.Result? = nil, storyReadMaxId: Int32? = nil, authorStoryStats: PeerStoryStats? = nil, cachedData: CachedDataEquatable? = nil, recommendedChannels: RecommendedChannels? = nil, automaticDownload: AutomaticMediaDownloadSettings = .defaultSettings, savedMessageTags: SavedMessageTags? = nil, codeSyntaxData: [CodeSyntaxKey : CodeSyntaxResult] = [:], messageEffect: AvailableMessageEffects.MessageEffect? = nil) {
let factCheckRevealed: Bool
init(pollStateData: ChatPollStateData = ChatPollStateData(), highlightFoundText: HighlightFoundText? = nil, isThreadLoading: Bool = false, updatingMedia: ChatUpdatingMessageMedia? = nil, chatTheme: TelegramPresentationTheme? = nil, reactions: AvailableReactions? = nil, animatedEmojiStickers: [String: StickerPackItem] = [:], transribeState:TranscribeAudioState? = nil, eventLog: AdminLogEvent? = nil, isRevealed: Bool? = nil, translate: ChatLiveTranslateContext.State.Result? = nil, replyTranslate: ChatLiveTranslateContext.State.Result? = nil, storyReadMaxId: Int32? = nil, authorStoryStats: PeerStoryStats? = nil, cachedData: CachedDataEquatable? = nil, recommendedChannels: RecommendedChannels? = nil, automaticDownload: AutomaticMediaDownloadSettings = .defaultSettings, savedMessageTags: SavedMessageTags? = nil, codeSyntaxData: [CodeSyntaxKey : CodeSyntaxResult] = [:], messageEffect: AvailableMessageEffects.MessageEffect? = nil, factCheckRevealed: Bool = false) {
self.pollStateData = pollStateData
self.highlightFoundText = highlightFoundText
self.isThreadLoading = isThreadLoading
Expand All @@ -170,6 +171,7 @@ struct MessageEntryAdditionalData : Equatable {
self.savedMessageTags = savedMessageTags
self.codeSyntaxData = codeSyntaxData
self.messageEffect = messageEffect
self.factCheckRevealed = factCheckRevealed
}
}

Expand Down Expand Up @@ -491,7 +493,7 @@ func <(lhs: ChatHistoryEntry, rhs: ChatHistoryEntry) -> Bool {
}


func messageEntries(_ messagesEntries: [MessageHistoryEntry], location: ChatLocation? = nil, maxReadIndex:MessageIndex? = nil, includeHoles: Bool = true, dayGrouping: Bool = false, renderType: ChatItemRenderType = .list, includeBottom:Bool = false, timeDifference: TimeInterval = 0, ranks:CachedChannelAdminRanks? = nil, pollAnswersLoading: [MessageId : ChatPollStateData] = [:], threadLoading: MessageId? = nil, groupingPhotos: Bool = false, autoplayMedia: AutoplayMediaPreferences? = nil, searchState: SearchMessagesResultState? = nil, animatedEmojiStickers: [String: StickerPackItem] = [:], topFixedMessages: [Message]? = nil, customChannelDiscussionReadState: MessageId? = nil, customThreadOutgoingReadState: MessageId? = nil, addRepliesHeader: Bool = false, addTopThreadInset: CGFloat? = nil, updatingMedia: [MessageId: ChatUpdatingMessageMedia] = [:], adMessage:Message? = nil, dynamicAdMessages: [Message] = [], chatTheme: TelegramPresentationTheme = theme, reactions: AvailableReactions? = nil, transribeState: [MessageId : TranscribeAudioState] = [:], topicCreatorId: PeerId? = nil, mediaRevealed: Set<MessageId> = Set(), translate: ChatLiveTranslateContext.State? = nil, storyState: PeerExpiringStoryListContext.State? = nil, peerStoryStats: [PeerId : PeerStoryStats] = [:], cachedData: CachedPeerData? = nil, peer: Peer? = nil, holeLater: Bool = false, holeEarlier: Bool = false, recommendedChannels: RecommendedChannels? = nil, includeJoin: Bool = false, earlierId: MessageIndex? = nil, laterId: MessageIndex? = nil, automaticDownload: AutomaticMediaDownloadSettings = .defaultSettings, savedMessageTags: SavedMessageTags? = nil, contentSettings: ContentSettings? = nil, codeSyntaxData: [CodeSyntaxKey : CodeSyntaxResult] = [:], messageEffects: AvailableMessageEffects? = nil) -> [ChatHistoryEntry] {
func messageEntries(_ messagesEntries: [MessageHistoryEntry], location: ChatLocation? = nil, maxReadIndex:MessageIndex? = nil, includeHoles: Bool = true, dayGrouping: Bool = false, renderType: ChatItemRenderType = .list, includeBottom:Bool = false, timeDifference: TimeInterval = 0, ranks:CachedChannelAdminRanks? = nil, pollAnswersLoading: [MessageId : ChatPollStateData] = [:], threadLoading: MessageId? = nil, groupingPhotos: Bool = false, autoplayMedia: AutoplayMediaPreferences? = nil, searchState: SearchMessagesResultState? = nil, animatedEmojiStickers: [String: StickerPackItem] = [:], topFixedMessages: [Message]? = nil, customChannelDiscussionReadState: MessageId? = nil, customThreadOutgoingReadState: MessageId? = nil, addRepliesHeader: Bool = false, addTopThreadInset: CGFloat? = nil, updatingMedia: [MessageId: ChatUpdatingMessageMedia] = [:], adMessage:Message? = nil, dynamicAdMessages: [Message] = [], chatTheme: TelegramPresentationTheme = theme, reactions: AvailableReactions? = nil, transribeState: [MessageId : TranscribeAudioState] = [:], topicCreatorId: PeerId? = nil, mediaRevealed: Set<MessageId> = Set(), translate: ChatLiveTranslateContext.State? = nil, storyState: PeerExpiringStoryListContext.State? = nil, peerStoryStats: [PeerId : PeerStoryStats] = [:], cachedData: CachedPeerData? = nil, peer: Peer? = nil, holeLater: Bool = false, holeEarlier: Bool = false, recommendedChannels: RecommendedChannels? = nil, includeJoin: Bool = false, earlierId: MessageIndex? = nil, laterId: MessageIndex? = nil, automaticDownload: AutomaticMediaDownloadSettings = .defaultSettings, savedMessageTags: SavedMessageTags? = nil, contentSettings: ContentSettings? = nil, codeSyntaxData: [CodeSyntaxKey : CodeSyntaxResult] = [:], messageEffects: AvailableMessageEffects? = nil, factCheckRevealed: Set<MessageId> = Set()) -> [ChatHistoryEntry] {
var entries: [ChatHistoryEntry] = []

var groupedPhotos:[ChatHistoryEntry] = []
Expand Down Expand Up @@ -920,7 +922,7 @@ func messageEntries(_ messagesEntries: [MessageHistoryEntry], location: ChatLoca

let messageEffect = messageEffects?.messageEffects.first(where: { $0.id == message.effectAttribute?.id })

additionalData = MessageEntryAdditionalData(pollStateData: pollData, highlightFoundText: highlightFoundText, isThreadLoading: threadLoading == message.id, updatingMedia: updatingMedia[message.id], chatTheme: chatTheme, reactions: reactions, animatedEmojiStickers: animatedEmojiStickers, transribeState: transribeState[message.id], isRevealed: mediaRevealed.contains(message.id), translate: messageTranslate, replyTranslate: replyTranslate, storyReadMaxId: storyState?.maxReadId, authorStoryStats: message.author.flatMap { peerStoryStats[$0.id] }, cachedData: .init(cachedData), automaticDownload: automaticDownload, savedMessageTags: savedMessageTags, codeSyntaxData: codeSyntaxData.filter { $0.key.messageId == message.id }, messageEffect: messageEffect)
additionalData = MessageEntryAdditionalData(pollStateData: pollData, highlightFoundText: highlightFoundText, isThreadLoading: threadLoading == message.id, updatingMedia: updatingMedia[message.id], chatTheme: chatTheme, reactions: reactions, animatedEmojiStickers: animatedEmojiStickers, transribeState: transribeState[message.id], isRevealed: mediaRevealed.contains(message.id), translate: messageTranslate, replyTranslate: replyTranslate, storyReadMaxId: storyState?.maxReadId, authorStoryStats: message.author.flatMap { peerStoryStats[$0.id] }, cachedData: .init(cachedData), automaticDownload: automaticDownload, savedMessageTags: savedMessageTags, codeSyntaxData: codeSyntaxData.filter { $0.key.messageId == message.id }, messageEffect: messageEffect, factCheckRevealed: factCheckRevealed.contains(message.id))
let data = ChatHistoryEntryData(entry.location, additionalData, autoplayMedia)


Expand Down
7 changes: 5 additions & 2 deletions Telegram-Mac/ChatInputView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ class ChatInputView: View, Notifable {


self.messageEffect = current
addSubview(current)
addSubview(current, positioned: .below, relativeTo: _ts)


if let fromRect = messageEffect.fromRect {
Expand Down Expand Up @@ -910,7 +910,7 @@ class ChatInputView: View, Notifable {


if let view = messageEffect {
transition.updateFrame(view: view, frame: NSMakeRect(size.width - actionsSize.width - view.frame.width, 0, view.frame.width, view.frame.height))
transition.updateFrame(view: view, frame: NSMakeRect(size.width - actionsSize.width - view.frame.width - 5, 0, view.frame.width, view.frame.height))
}

if let view = botMenuView {
Expand Down Expand Up @@ -1085,6 +1085,9 @@ class ChatInputView: View, Notifable {
if let sendAsView = self.sendAsView {
leftInset += sendAsView.frame.width
}
if let messageEffect {
leftInset += messageEffect.frame.width
}
let w = width - actionsView.size(chatInteraction.presentation).width - leftInset
let height = self.textView.height(for: w)
return (NSMakeSize(w, min(max(height, textView.min_height), textView.max_height)), height)
Expand Down
Loading

0 comments on commit d782a14

Please sign in to comment.