mirror of
https://github.com/ichmagmaus111/ghostgram.git
synced 2026-07-25 08:50:51 +02:00
Update Ghostgram features
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import SGSimpleSettings
|
||||
import Foundation
|
||||
import UIKit
|
||||
import Postbox
|
||||
@@ -339,6 +340,7 @@ final class ChatHistoryTransactionOpaqueState {
|
||||
}
|
||||
|
||||
private func extractAssociatedData(
|
||||
translationSettings: TranslationSettings,
|
||||
chatLocation: ChatLocation,
|
||||
view: MessageHistoryView,
|
||||
automaticDownloadNetworkType: MediaAutoDownloadNetworkType,
|
||||
@@ -421,7 +423,43 @@ private func extractAssociatedData(
|
||||
automaticDownloadPeerId = message.peerId
|
||||
}
|
||||
|
||||
return ChatMessageItemAssociatedData(automaticDownloadPeerType: automaticMediaDownloadPeerType, automaticDownloadPeerId: automaticDownloadPeerId, automaticDownloadNetworkType: automaticDownloadNetworkType, preferredStoryHighQuality: preferredStoryHighQuality, isRecentActions: false, subject: subject, contactsPeerIds: contactsPeerIds, channelDiscussionGroup: channelDiscussionGroup, animatedEmojiStickers: animatedEmojiStickers, additionalAnimatedEmojiStickers: additionalAnimatedEmojiStickers, currentlyPlayingMessageId: currentlyPlayingMessageId, isCopyProtectionEnabled: isCopyProtectionEnabled, availableReactions: availableReactions, availableMessageEffects: availableMessageEffects, savedMessageTags: savedMessageTags, defaultReaction: defaultReaction, areStarReactionsEnabled: areStarReactionsEnabled, isPremium: isPremium, accountPeer: accountPeer, alwaysDisplayTranscribeButton: alwaysDisplayTranscribeButton, topicAuthorId: topicAuthorId, hasBots: hasBots, translateToLanguage: translateToLanguage, maxReadStoryId: maxReadStoryId, recommendedChannels: recommendedChannels, audioTranscriptionTrial: audioTranscriptionTrial, chatThemes: chatThemes, deviceContactsNumbers: deviceContactsNumbers, isInline: isInline, showSensitiveContent: showSensitiveContent, isSuspiciousPeer: isSuspiciousPeer)
|
||||
return ChatMessageItemAssociatedData(
|
||||
automaticDownloadPeerType: automaticMediaDownloadPeerType,
|
||||
automaticDownloadPeerId: automaticDownloadPeerId,
|
||||
automaticDownloadNetworkType: automaticDownloadNetworkType,
|
||||
preferredStoryHighQuality: preferredStoryHighQuality,
|
||||
isRecentActions: false,
|
||||
subject: subject,
|
||||
contactsPeerIds: contactsPeerIds,
|
||||
channelDiscussionGroup: channelDiscussionGroup,
|
||||
animatedEmojiStickers: animatedEmojiStickers,
|
||||
additionalAnimatedEmojiStickers: additionalAnimatedEmojiStickers,
|
||||
forcedResourceStatus: nil,
|
||||
currentlyPlayingMessageId: currentlyPlayingMessageId,
|
||||
isCopyProtectionEnabled: isCopyProtectionEnabled,
|
||||
availableReactions: availableReactions,
|
||||
availableMessageEffects: availableMessageEffects,
|
||||
savedMessageTags: savedMessageTags,
|
||||
defaultReaction: defaultReaction,
|
||||
areStarReactionsEnabled: areStarReactionsEnabled,
|
||||
isPremium: isPremium,
|
||||
accountPeer: accountPeer,
|
||||
forceInlineReactions: false,
|
||||
alwaysDisplayTranscribeButton: alwaysDisplayTranscribeButton,
|
||||
topicAuthorId: topicAuthorId,
|
||||
hasBots: hasBots,
|
||||
translationSettings: translationSettings,
|
||||
translateToLanguage: translateToLanguage,
|
||||
maxReadStoryId: maxReadStoryId,
|
||||
recommendedChannels: recommendedChannels,
|
||||
audioTranscriptionTrial: audioTranscriptionTrial,
|
||||
chatThemes: chatThemes,
|
||||
deviceContactsNumbers: deviceContactsNumbers,
|
||||
isStandalone: false,
|
||||
isInline: isInline,
|
||||
showSensitiveContent: showSensitiveContent,
|
||||
isSuspiciousPeer: isSuspiciousPeer
|
||||
)
|
||||
}
|
||||
|
||||
private extension ChatHistoryLocationInput {
|
||||
@@ -791,6 +829,7 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
self.messageTransitionNode = messageTransitionNode
|
||||
self.mode = mode
|
||||
|
||||
if SGSimpleSettings.shared.disableSnapDeletionEffect { self.allowDustEffect = false }
|
||||
if let data = context.currentAppConfiguration.with({ $0 }).data {
|
||||
if let _ = data["ios_killswitch_disable_unread_alignment"] {
|
||||
self.enableUnreadAlignment = false
|
||||
@@ -1816,6 +1855,7 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
var measure_isFirstTime = true
|
||||
let messageViewQueue = Queue.mainQueue()
|
||||
let historyViewTransitionDisposable = (combineLatest(queue: messageViewQueue,
|
||||
self.context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.translationSettings]) |> take(1),
|
||||
historyViewUpdate |> debug_measureTimeToFirstEvent(label: "chatHistoryNode_historyViewUpdate"),
|
||||
self.chatPresentationDataPromise.get() |> debug_measureTimeToFirstEvent(label: "chatHistoryNode_chatPresentationData"),
|
||||
selectedMessages |> debug_measureTimeToFirstEvent(label: "chatHistoryNode_selectedMessages"),
|
||||
@@ -1841,7 +1881,7 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
chatThemes |> debug_measureTimeToFirstEvent(label: "chatHistoryNode_chatThemes"),
|
||||
deviceContactsNumbers |> debug_measureTimeToFirstEvent(label: "chatHistoryNode_deviceContactsNumbers"),
|
||||
contentSettings |> debug_measureTimeToFirstEvent(label: "chatHistoryNode_contentSettings")
|
||||
) |> debug_measureTimeToFirstEvent(label: "chatHistoryNode_firstChatHistoryTransition")).startStrict(next: { [weak self] update, chatPresentationData, selectedMessages, updatingMedia, networkType, preferredStoryHighQuality, animatedEmojiStickers, additionalAnimatedEmojiStickers, customChannelDiscussionReadState, customThreadOutgoingReadState, availableReactions, availableMessageEffects, savedMessageTags, defaultReaction, accountPeer, suggestAudioTranscription, promises, topicAuthorId, translationState, maxReadStoryId, recommendedChannels, audioTranscriptionTrial, chatThemes, deviceContactsNumbers, contentSettings in
|
||||
) |> debug_measureTimeToFirstEvent(label: "chatHistoryNode_firstChatHistoryTransition")).startStrict(next: { [weak self] sharedData, /* MARK: Swiftgram */ update, chatPresentationData, selectedMessages, updatingMedia, networkType, preferredStoryHighQuality, animatedEmojiStickers, additionalAnimatedEmojiStickers, customChannelDiscussionReadState, customThreadOutgoingReadState, availableReactions, availableMessageEffects, savedMessageTags, defaultReaction, accountPeer, suggestAudioTranscription, promises, topicAuthorId, translationState, maxReadStoryId, recommendedChannels, audioTranscriptionTrial, chatThemes, deviceContactsNumbers, contentSettings in
|
||||
let (historyAppearsCleared, pendingUnpinnedAllMessages, pendingRemovedMessages, currentlyPlayingMessageIdAndType, scrollToMessageId, chatHasBots, allAdMessages) = promises
|
||||
|
||||
if measure_isFirstTime {
|
||||
@@ -1852,6 +1892,13 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
#endif
|
||||
}
|
||||
|
||||
let translationSettings: TranslationSettings
|
||||
if let current = sharedData.entries[ApplicationSpecificSharedDataKeys.translationSettings]?.get(TranslationSettings.self) {
|
||||
translationSettings = current
|
||||
} else {
|
||||
translationSettings = TranslationSettings.defaultSettings
|
||||
}
|
||||
|
||||
func applyHole() {
|
||||
Queue.mainQueue().async {
|
||||
if let strongSelf = self {
|
||||
@@ -2056,23 +2103,24 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
}
|
||||
}
|
||||
}
|
||||
// GHOSTGRAM: Bypass copy protection if enabled in Misc settings
|
||||
if MiscSettingsManager.shared.shouldBypassCopyProtection {
|
||||
isCopyProtectionEnabled = false
|
||||
}
|
||||
let alwaysDisplayTranscribeButton = ChatMessageItemAssociatedData.DisplayTranscribeButton(
|
||||
canBeDisplayed: suggestAudioTranscription.0 < 2,
|
||||
displayForNotConsumed: suggestAudioTranscription.1,
|
||||
providedByGroupBoost: audioTranscriptionProvidedByBoost
|
||||
)
|
||||
|
||||
var translateToLanguage: (fromLang: String, toLang: String)?
|
||||
if let translationState, (isPremium || autoTranslate) && translationState.isEnabled {
|
||||
var languageCode = translationState.toLang ?? chatPresentationData.strings.baseLanguageCode
|
||||
|
||||
// MARK: Swiftgram
|
||||
// var translateToLanguage: (fromLang: String, toLang: String)?
|
||||
// if let translationState, (isPremium || autoTranslate) && translationState.isEnabled {
|
||||
var languageCode = translationState?.toLang ?? chatPresentationData.strings.baseLanguageCode
|
||||
let rawSuffix = "-raw"
|
||||
if languageCode.hasSuffix(rawSuffix) {
|
||||
languageCode = String(languageCode.dropLast(rawSuffix.count))
|
||||
}
|
||||
languageCode = normalizeTranslationLanguage(languageCode)
|
||||
var translateToLanguage: (fromLang: String, toLang: String)?
|
||||
let sgTranslationAvailable = SGSimpleSettings.shared.translationBackendEnum != .default
|
||||
if let translationState, (isPremium || autoTranslate || sgTranslationAvailable) && translationState.isEnabled {
|
||||
translateToLanguage = (normalizeTranslationLanguage(translationState.fromLang), normalizeTranslationLanguage(languageCode))
|
||||
}
|
||||
|
||||
@@ -2081,7 +2129,7 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
isSuspiciousPeer = true
|
||||
}
|
||||
|
||||
let associatedData = extractAssociatedData(chatLocation: chatLocation, view: view, automaticDownloadNetworkType: networkType, preferredStoryHighQuality: preferredStoryHighQuality, animatedEmojiStickers: animatedEmojiStickers, additionalAnimatedEmojiStickers: additionalAnimatedEmojiStickers, subject: subject, currentlyPlayingMessageId: currentlyPlayingMessageIdAndType?.0, isCopyProtectionEnabled: isCopyProtectionEnabled, availableReactions: availableReactions, availableMessageEffects: availableMessageEffects, savedMessageTags: savedMessageTags, defaultReaction: defaultReaction.0, areStarReactionsEnabled: defaultReaction.1, isPremium: isPremium, alwaysDisplayTranscribeButton: alwaysDisplayTranscribeButton, accountPeer: accountPeer, topicAuthorId: topicAuthorId, hasBots: chatHasBots, translateToLanguage: translateToLanguage?.toLang, maxReadStoryId: maxReadStoryId, recommendedChannels: recommendedChannels, audioTranscriptionTrial: audioTranscriptionTrial, chatThemes: chatThemes, deviceContactsNumbers: deviceContactsNumbers, isInline: !rotated, showSensitiveContent: contentSettings.ignoreContentRestrictionReasons.contains("sensitive"), isSuspiciousPeer: isSuspiciousPeer)
|
||||
let associatedData = extractAssociatedData(translationSettings: translationSettings, /* MARK: Swiftgram */ chatLocation: chatLocation, view: view, automaticDownloadNetworkType: networkType, preferredStoryHighQuality: preferredStoryHighQuality, animatedEmojiStickers: animatedEmojiStickers, additionalAnimatedEmojiStickers: additionalAnimatedEmojiStickers, subject: subject, currentlyPlayingMessageId: currentlyPlayingMessageIdAndType?.0, isCopyProtectionEnabled: isCopyProtectionEnabled, availableReactions: availableReactions, availableMessageEffects: availableMessageEffects, savedMessageTags: savedMessageTags, defaultReaction: defaultReaction.0, areStarReactionsEnabled: defaultReaction.1, isPremium: isPremium, alwaysDisplayTranscribeButton: alwaysDisplayTranscribeButton, accountPeer: accountPeer, topicAuthorId: topicAuthorId, hasBots: chatHasBots, translateToLanguage: translateToLanguage?.toLang, maxReadStoryId: maxReadStoryId, recommendedChannels: recommendedChannels, audioTranscriptionTrial: audioTranscriptionTrial, chatThemes: chatThemes, deviceContactsNumbers: deviceContactsNumbers, isInline: !rotated, showSensitiveContent: contentSettings.ignoreContentRestrictionReasons.contains("sensitive"), isSuspiciousPeer: isSuspiciousPeer)
|
||||
|
||||
var includeEmbeddedSavedChatInfo = false
|
||||
if case let .replyThread(message) = chatLocation, message.peerId == context.account.peerId, !rotated {
|
||||
@@ -2106,8 +2154,7 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
selectedMessages: selectedMessages,
|
||||
presentationData: chatPresentationData,
|
||||
historyAppearsCleared: historyAppearsCleared,
|
||||
// GHOSTGRAM: Keep view-once media visible if bypass is enabled
|
||||
skipViewOnceMedia: MiscSettingsManager.shared.shouldDisableViewOnceAutoDelete ? false : (mode != .bubbles),
|
||||
skipViewOnceMedia: mode != .bubbles,
|
||||
pendingUnpinnedAllMessages: pendingUnpinnedAllMessages,
|
||||
pendingRemovedMessages: pendingRemovedMessages,
|
||||
associatedData: associatedData,
|
||||
@@ -2115,9 +2162,8 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
customChannelDiscussionReadState: customChannelDiscussionReadState,
|
||||
customThreadOutgoingReadState: customThreadOutgoingReadState,
|
||||
cachedData: data.cachedData,
|
||||
// GHOSTGRAM: Block ads if enabled in Misc settings
|
||||
adMessage: MiscSettingsManager.shared.shouldBlockAds ? nil : allAdMessages.fixed,
|
||||
dynamicAdMessages: MiscSettingsManager.shared.shouldBlockAds ? [] : allAdMessages.opportunistic
|
||||
adMessage: allAdMessages.fixed,
|
||||
dynamicAdMessages: allAdMessages.opportunistic
|
||||
)
|
||||
let lastHeaderId = filteredEntries.last.flatMap { listMessageDateHeaderId(timestamp: $0.index.timestamp) } ?? 0
|
||||
let processedView = ChatHistoryView(originalView: view, filteredEntries: filteredEntries, associatedData: associatedData, lastHeaderId: lastHeaderId, id: id, locationInput: update.2, ignoreMessagesInTimestampRange: update.3, ignoreMessageIds: update.4)
|
||||
|
||||
Reference in New Issue
Block a user