From 73dfa5f60d73a301d23496d0a48bc7dcba11ca23 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Tue, 24 Feb 2026 18:00:55 +0100 Subject: [PATCH] Fix build --- .../Telegram-iOS/en.lproj/Localizable.strings | 9 ++++ .../TelegramUI/Sources/AppDelegate.swift | 2 + .../Sources/SharedWakeupManager.swift | 52 +++++++------------ 3 files changed, 31 insertions(+), 32 deletions(-) diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 9801752150..8f9b5cb365 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -15922,3 +15922,12 @@ Error: %8$@"; "EditRank.AddTag" = "Add Tag"; "EditRank.EditTag" = "Edit Tag"; "EditRank.RemoveTag" = "Remove Tag"; + +"BackgroundTasks.UploadingStories_1" = "Uploading Story"; +"BackgroundTasks.UploadingStories_any" = "Uploading %d Stories"; +"BackgroundTasks.StoryOpenAppToContinue" = "Open app to continue"; +"BackgroundTasks.StorySubtitle" = "Running..."; + +"BackgroundTasks.UploadingMedia_1" = "Sending Message"; +"BackgroundTasks.UploadingMedia_any" = "Sending %d Messages"; +"BackgroundTasks.MediaSubtitle" = "Running..."; diff --git a/submodules/TelegramUI/Sources/AppDelegate.swift b/submodules/TelegramUI/Sources/AppDelegate.swift index 3cff2fa6ac..068f80f757 100644 --- a/submodules/TelegramUI/Sources/AppDelegate.swift +++ b/submodules/TelegramUI/Sources/AppDelegate.swift @@ -1171,6 +1171,8 @@ private func extractAccountManagerState(records: AccountRecordsView map { ($0.0?.account, $0.1.map { ($0.0, $0.1.account) }) }, liveLocationPolling: liveLocationPolling, watchTasks: .single(nil), inForeground: applicationBindings.applicationInForeground, hasActiveAudioSession: self.hasActiveAudioSession.get(), notificationManager: notificationManager, mediaManager: sharedContext.mediaManager, callManager: sharedContext.callManager, accountUserInterfaceInUse: { id in return sharedContext.accountUserInterfaceInUse(id) + }, presentationData: { + return sharedContext.currentPresentationData.with({ $0 }) }) let sharedApplicationContext = SharedApplicationContext(sharedContext: sharedContext, notificationManager: notificationManager, wakeupManager: wakeupManager) sharedApplicationContext.sharedContext.mediaManager.overlayMediaManager.attachOverlayMediaController(sharedApplicationContext.overlayMediaController) diff --git a/submodules/TelegramUI/Sources/SharedWakeupManager.swift b/submodules/TelegramUI/Sources/SharedWakeupManager.swift index a155bff6ee..dfb839298f 100644 --- a/submodules/TelegramUI/Sources/SharedWakeupManager.swift +++ b/submodules/TelegramUI/Sources/SharedWakeupManager.swift @@ -9,6 +9,7 @@ import TelegramCallsUI import AccountContext import UniversalMediaPlayer import TelegramAudio +import TelegramPresentationData private struct AccountTasks { let stateSynchronization: Bool @@ -66,6 +67,7 @@ public final class SharedWakeupManager { private let acquireIdleExtension: () -> Disposable? private var enableBackgroundTasks: Bool = false + private let presentationData: () -> PresentationData? private var inForeground: Bool = false private var hasActiveAudioSession: Bool = false @@ -106,13 +108,14 @@ public final class SharedWakeupManager { private var backgroundStoryProcessingTaskLaunched: Bool = false private var backgroundStoryProcessingTaskCancellationRequestedByApp: Bool = false - public init(beginBackgroundTask: @escaping (String, @escaping () -> Void) -> UIBackgroundTaskIdentifier?, endBackgroundTask: @escaping (UIBackgroundTaskIdentifier) -> Void, backgroundTimeRemaining: @escaping () -> Double, acquireIdleExtension: @escaping () -> Disposable?, activeAccounts: Signal<(primary: Account?, accounts: [(AccountRecordId, Account)]), NoError>, liveLocationPolling: Signal, watchTasks: Signal, inForeground: Signal, hasActiveAudioSession: Signal, notificationManager: SharedNotificationManager?, mediaManager: MediaManager, callManager: PresentationCallManager?, accountUserInterfaceInUse: @escaping (AccountRecordId) -> Signal) { + public init(beginBackgroundTask: @escaping (String, @escaping () -> Void) -> UIBackgroundTaskIdentifier?, endBackgroundTask: @escaping (UIBackgroundTaskIdentifier) -> Void, backgroundTimeRemaining: @escaping () -> Double, acquireIdleExtension: @escaping () -> Disposable?, activeAccounts: Signal<(primary: Account?, accounts: [(AccountRecordId, Account)]), NoError>, liveLocationPolling: Signal, watchTasks: Signal, inForeground: Signal, hasActiveAudioSession: Signal, notificationManager: SharedNotificationManager?, mediaManager: MediaManager, callManager: PresentationCallManager?, accountUserInterfaceInUse: @escaping (AccountRecordId) -> Signal, presentationData: @escaping () -> PresentationData?) { assert(Queue.mainQueue().isCurrent()) self.beginBackgroundTask = beginBackgroundTask self.endBackgroundTask = endBackgroundTask self.backgroundTimeRemaining = backgroundTimeRemaining self.acquireIdleExtension = acquireIdleExtension + self.presentationData = presentationData self.accountSettingsDisposable = (activeAccounts |> mapToSignal { activeAccounts -> Signal in @@ -495,6 +498,9 @@ public final class SharedWakeupManager { guard self.backgroundProcessingTaskId == nil else { return } + guard let presentationData = self.presentationData() else { + return + } let baseAppBundleId = Bundle.main.bundleIdentifier! let uploadTaskId = "\(baseAppBundleId).upload.message\(self.nextBackgroundProcessingTaskId)" @@ -629,14 +635,9 @@ public final class SharedWakeupManager { task.progress.totalUnitCount = totalUnitCount task.progress.completedUnitCount = completedUnitCount - let title: String - if self.pendingMediaUploadsByKey.count == 1 { - title = "Uploading 1 Item" - } else { - title = "Uploading \(self.pendingMediaUploadsByKey.count) Items" - } + let title: String = presentationData.strings.BackgroundTasks_UploadingMedia(Int32(self.pendingMediaUploadsByKey.count)) if task.title != title { - task.updateTitle(title, subtitle: "Running...") + task.updateTitle(title, subtitle: presentationData.strings.BackgroundTasks_MediaSubtitle) } try await Task.sleep(for: .seconds(1.0)) @@ -644,17 +645,12 @@ public final class SharedWakeupManager { } }) - let title: String - if self.pendingMediaUploadsByKey.count == 1 { - title = "Uploading 1 Item" - } else { - title = "Uploading \(self.pendingMediaUploadsByKey.count) Items" - } + let title: String = presentationData.strings.BackgroundTasks_UploadingMedia(Int32(self.pendingMediaUploadsByKey.count)) let request = BGContinuedProcessingTaskRequest( identifier: uploadTaskId, title: title, - subtitle: "Running..." + subtitle: presentationData.strings.BackgroundTasks_MediaSubtitle ) request.strategy = .fail @@ -678,6 +674,9 @@ public final class SharedWakeupManager { guard self.backgroundStoryProcessingTaskId == nil else { return } + guard let presentationData = self.presentationData() else { + return + } let baseAppBundleId = Bundle.main.bundleIdentifier! let uploadTaskId = "\(baseAppBundleId).upload.story\(self.nextBackgroundStoryProcessingTaskId)" @@ -814,18 +813,12 @@ public final class SharedWakeupManager { task.progress.totalUnitCount = totalUnitCount task.progress.completedUnitCount = completedUnitCount - //TODO:localize - let title: String - if self.pendingStoryUploadsByKey.count == 1 { - title = "Uploading 1 Story" - } else { - title = "Uploading \(self.pendingStoryUploadsByKey.count) Stories" - } + let title: String = presentationData.strings.BackgroundTasks_UploadingStories(Int32(self.pendingStoryUploadsByKey.count)) let subtitle: String if self.pendingStoryUploadStatusesByKey.values.contains(where: { $0.phase == .processing }) { - subtitle = "Open the app to continue" + subtitle = presentationData.strings.BackgroundTasks_StoryOpenAppToContinue } else { - subtitle = "Running..." + subtitle = presentationData.strings.BackgroundTasks_StorySubtitle } if currentDisplayedTitle != title || currentDisplayedSubtitle != subtitle { task.updateTitle(title, subtitle: subtitle) @@ -838,17 +831,12 @@ public final class SharedWakeupManager { } }) - let title: String - if self.pendingStoryUploadsByKey.count == 1 { - title = "Uploading 1 Story" - } else { - title = "Uploading \(self.pendingStoryUploadsByKey.count) Stories" - } + let title: String = presentationData.strings.BackgroundTasks_UploadingStories(Int32(self.pendingStoryUploadsByKey.count)) let subtitle: String if self.pendingStoryUploadStatusesByKey.values.contains(where: { $0.phase == .processing }) { - subtitle = "Open the app to continue" + subtitle = presentationData.strings.BackgroundTasks_StoryOpenAppToContinue } else { - subtitle = "Running..." + subtitle = presentationData.strings.BackgroundTasks_StorySubtitle } let request = BGContinuedProcessingTaskRequest(