Fix build

This commit is contained in:
Isaac 2026-02-24 18:00:55 +01:00
parent 4f513faa82
commit 73dfa5f60d
3 changed files with 31 additions and 32 deletions

View file

@ -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...";

View file

@ -1171,6 +1171,8 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
return applicationBindings.pushIdleTimerExtension()
}, activeAccounts: sharedContext.activeAccountContexts |> 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)

View file

@ -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<AccountRecordId?, NoError>, watchTasks: Signal<AccountRecordId?, NoError>, inForeground: Signal<Bool, NoError>, hasActiveAudioSession: Signal<Bool, NoError>, notificationManager: SharedNotificationManager?, mediaManager: MediaManager, callManager: PresentationCallManager?, accountUserInterfaceInUse: @escaping (AccountRecordId) -> Signal<Bool, NoError>) {
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<AccountRecordId?, NoError>, watchTasks: Signal<AccountRecordId?, NoError>, inForeground: Signal<Bool, NoError>, hasActiveAudioSession: Signal<Bool, NoError>, notificationManager: SharedNotificationManager?, mediaManager: MediaManager, callManager: PresentationCallManager?, accountUserInterfaceInUse: @escaping (AccountRecordId) -> Signal<Bool, NoError>, 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<Bool, NoError> 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(