diff --git a/submodules/TelegramCore/Sources/State/MessageReactions.swift b/submodules/TelegramCore/Sources/State/MessageReactions.swift index e4425e7796..cde7906e09 100644 --- a/submodules/TelegramCore/Sources/State/MessageReactions.swift +++ b/submodules/TelegramCore/Sources/State/MessageReactions.swift @@ -433,7 +433,7 @@ public final class EngineMessageReactionListContext { self.reaction = reaction let initialState = EngineMessageReactionListContext.State(message: message, readStats: readStats, reaction: reaction) - self.state = InternalState(hasOutgoingReaction: initialState.hasOutgoingReaction, totalCount: initialState.totalCount, items: initialState.items, canLoadMore: true, nextOffset: nil) + self.state = InternalState(hasOutgoingReaction: initialState.hasOutgoingReaction, totalCount: initialState.totalCount, items: initialState.items, canLoadMore: initialState.canLoadMore, nextOffset: nil) if initialState.canLoadMore { self.loadMore() diff --git a/submodules/TelegramUI/Components/SendInviteLinkScreen/Sources/SendInviteLinkScreen.swift b/submodules/TelegramUI/Components/SendInviteLinkScreen/Sources/SendInviteLinkScreen.swift index f927cc10f3..4846a25d7b 100644 --- a/submodules/TelegramUI/Components/SendInviteLinkScreen/Sources/SendInviteLinkScreen.swift +++ b/submodules/TelegramUI/Components/SendInviteLinkScreen/Sources/SendInviteLinkScreen.swift @@ -512,14 +512,16 @@ private final class SendInviteLinkScreenComponent: Component { if self.selectedItems.isEmpty { controller.dismiss() } else if let link = component.link { + let selectedPeers = component.peers.filter { self.selectedItems.contains($0.id) } + let _ = enqueueMessagesToMultiplePeers(account: component.context.account, peerIds: Array(self.selectedItems), threadIds: [:], messages: [.message(text: link, attributes: [], inlineStickers: [:], mediaReference: nil, replyToMessageId: nil, localGroupingKey: nil, correlationId: nil, bubbleUpEmojiOrStickersets: [])]).start() let text: String - if component.peers.count == 1 { - text = environment.strings.Conversation_ShareLinkTooltip_Chat_One(component.peers[0].displayTitle(strings: environment.strings, displayOrder: .firstLast).replacingOccurrences(of: "*", with: "")).string - } else if component.peers.count == 2 { - text = environment.strings.Conversation_ShareLinkTooltip_TwoChats_One(component.peers[0].displayTitle(strings: environment.strings, displayOrder: .firstLast).replacingOccurrences(of: "*", with: ""), component.peers[1].displayTitle(strings: environment.strings, displayOrder: .firstLast).replacingOccurrences(of: "*", with: "")).string + if selectedPeers.count == 1 { + text = environment.strings.Conversation_ShareLinkTooltip_Chat_One(selectedPeers[0].displayTitle(strings: environment.strings, displayOrder: .firstLast).replacingOccurrences(of: "*", with: "")).string + } else if selectedPeers.count == 2 { + text = environment.strings.Conversation_ShareLinkTooltip_TwoChats_One(selectedPeers[0].displayTitle(strings: environment.strings, displayOrder: .firstLast).replacingOccurrences(of: "*", with: ""), selectedPeers[1].displayTitle(strings: environment.strings, displayOrder: .firstLast).replacingOccurrences(of: "*", with: "")).string } else { - text = environment.strings.Conversation_ShareLinkTooltip_ManyChats_One(component.peers[0].displayTitle(strings: environment.strings, displayOrder: .firstLast).replacingOccurrences(of: "*", with: ""), "\(component.peers.count - 1)").string + text = environment.strings.Conversation_ShareLinkTooltip_ManyChats_One(selectedPeers[0].displayTitle(strings: environment.strings, displayOrder: .firstLast).replacingOccurrences(of: "*", with: ""), "\(selectedPeers.count - 1)").string } let presentationData = component.context.sharedContext.currentPresentationData.with { $0 } diff --git a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageUsageScreen.swift b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageUsageScreen.swift index de20a66069..56ff2958d5 100644 --- a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageUsageScreen.swift +++ b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageUsageScreen.swift @@ -2258,7 +2258,7 @@ final class StorageUsageScreenComponent: Component { } let presentationData = component.context.sharedContext.currentPresentationData.with { $0 } - controller.present(UndoOverlayController(presentationData: presentationData, content: .succeed(text: presentationData.strings.ClearCache_Success("\(dataSizeString(size, formatting: DataSizeStringFormatting(presentationData: presentationData)))", stringForDeviceType()).string), elevatedLayout: false, action: { _ in return false }), in: .window(.root)) + controller.present(UndoOverlayController(presentationData: presentationData, content: .succeed(text: presentationData.strings.ClearCache_Success("\(dataSizeString(size, formatting: DataSizeStringFormatting(presentationData: presentationData)))", stringForDeviceType()).string), elevatedLayout: false, action: { _ in return false }), in: .current) } private func reloadStats(firstTime: Bool, completion: @escaping () -> Void) { diff --git a/submodules/TelegramUI/Sources/SharedAccountContext.swift b/submodules/TelegramUI/Sources/SharedAccountContext.swift index 53713a31bc..02e20a8706 100644 --- a/submodules/TelegramUI/Sources/SharedAccountContext.swift +++ b/submodules/TelegramUI/Sources/SharedAccountContext.swift @@ -637,6 +637,8 @@ public final class SharedAccountContextImpl: SharedAccountContext { if hadUpdates { self.activeAccountsValue!.accounts.sort(by: { $0.2 < $1.2 }) self.activeAccountsPromise.set(.single(self.activeAccountsValue!)) + + self.performAccountSettingsImportIfNecessary() } if self.activeAccountsValue!.primary == nil && self.activeAccountsValue!.currentAuth == nil { @@ -897,6 +899,37 @@ public final class SharedAccountContextImpl: SharedAccountContext { self.callStateDisposable?.dispose() } + private var didPerformAccountSettingsImport = false + private func performAccountSettingsImportIfNecessary() { + if self.didPerformAccountSettingsImport { + return + } + if let _ = UserDefaults.standard.value(forKey: "didPerformAccountSettingsImport") { + self.didPerformAccountSettingsImport = true + return + } + UserDefaults.standard.set(true as NSNumber, forKey: "didPerformAccountSettingsImport") + UserDefaults.standard.synchronize() + + if let primary = self.activeAccountsValue?.primary { + let _ = (primary.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: primary.account.peerId)) + |> deliverOnMainQueue).start(next: { [weak self] peer in + guard let self, case let .user(user) = peer else { + return + } + if user.isPremium { + let _ = updateMediaDownloadSettingsInteractively(accountManager: self.accountManager, { settings in + var settings = settings + settings.energyUsageSettings.loopEmoji = true + return settings + }).start() + } + }) + } + + self.didPerformAccountSettingsImport = true + } + private func updateAccountBackupData(account: Account) -> Signal { return accountBackupData(postbox: account.postbox) |> mapToSignal { backupData -> Signal in diff --git a/submodules/TelegramUIPreferences/Sources/MediaAutoDownloadSettings.swift b/submodules/TelegramUIPreferences/Sources/MediaAutoDownloadSettings.swift index 78aaf44095..f29c4f68d1 100644 --- a/submodules/TelegramUIPreferences/Sources/MediaAutoDownloadSettings.swift +++ b/submodules/TelegramUIPreferences/Sources/MediaAutoDownloadSettings.swift @@ -270,18 +270,24 @@ public struct EnergyUsageSettings: Codable, Equatable { case autodownloadInBackground } - public static var `default`: EnergyUsageSettings { + public static let `default`: EnergyUsageSettings = { + var length: Int = 4 + var cpuCount: UInt32 = 0 + sysctlbyname("hw.ncpu", &cpuCount, &length, nil, 0) + + let isCapable = cpuCount >= 4 + return EnergyUsageSettings( activationThreshold: 15, autoplayVideo: true, autoplayGif: true, loopStickers: true, - loopEmoji: true, - fullTranslucency: true, + loopEmoji: isCapable ? false : true, + fullTranslucency: isCapable ? false : true, extendBackgroundWork: true, autodownloadInBackground: true ) - } + }() public static var powerSavingDefault: EnergyUsageSettings { return EnergyUsageSettings(