mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-05-21 18:20:41 +00:00
Temp
This commit is contained in:
@@ -22,14 +22,36 @@ build --strategy=SwiftCompile=worker
|
||||
|
||||
#common --registry=https://raw.githubusercontent.com/bazelbuild/bazel-central-registry/main/
|
||||
|
||||
# SourceKit BSP: Swift indexing features
|
||||
common --features=swift.index_while_building
|
||||
common --features=swift.use_global_index_store
|
||||
common --features=swift.use_global_module_cache
|
||||
common --features=oso_prefix_is_pwd
|
||||
# rules_swift flags migration
|
||||
# --swiftcopt and --host_swiftcopt are deprecated
|
||||
common --flag_alias=swiftcopt=@build_bazel_rules_swift//swift:copt
|
||||
common --flag_alias=host_swiftcopt=@build_bazel_rules_swift//swift:exec_copt
|
||||
#common --swiftcopt=-whole-module-optimization
|
||||
#common --host_swiftcopt=-whole-module-optimization
|
||||
|
||||
# SourceKit BSP: Index build config (used for background indexing)
|
||||
common --check_visibility=false
|
||||
|
||||
# All of the following are Debug/Index setup configs inspired by the default rules_xcodeproj template
|
||||
|
||||
common --verbose_failures
|
||||
common --cache_computed_file_digests=500000
|
||||
common --action_cache_store_output_metadata
|
||||
common --experimental_use_cpp_compile_action_args_params_file
|
||||
common --define=apple.experimental.tree_artifact_outputs=1
|
||||
common --features=apple.swizzle_absolute_xcttestsourcelocation
|
||||
common --features=oso_prefix_is_pwd
|
||||
common --features=relative_ast_path
|
||||
common --features=swift.cacheable_swiftmodules
|
||||
common --features=swift.index_while_building
|
||||
common --features=swift.use_global_module_cache
|
||||
common --features=swift.emit_swiftsourceinfo
|
||||
common --nolegacy_important_outputs
|
||||
build --noworker_sandboxing
|
||||
build --spawn_strategy=remote,worker,local
|
||||
|
||||
# Only for BSP builds
|
||||
common:index_build --experimental_convenience_symlinks=ignore
|
||||
common:index_build --bes_backend= --bes_results_url=
|
||||
common:index_build --show_result=0
|
||||
common:index_build --noshow_loading_progress
|
||||
common:index_build --noshow_progress
|
||||
@@ -37,3 +59,4 @@ common:index_build --noannounce_rc
|
||||
common:index_build --noshow_timestamps
|
||||
common:index_build --curses=no
|
||||
common:index_build --color=no
|
||||
|
||||
|
||||
Vendored
+3
-1
@@ -23,5 +23,7 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"swift.sourcekit-lsp.serverPath": "${workspaceFolder}/build-input/sourcekit-lsp"
|
||||
"swift.sourcekit-lsp.serverPath": "${workspaceFolder}/build-input/sourcekit-lsp",
|
||||
"sourcekit-bazel-bsp.rulesAppleName": "build_bazel_rules_apple",
|
||||
"cmake.sourceDirectory": "/Users/ali/build/telegram/telegram-ios/submodules/rlottie/rlottie/test"
|
||||
}
|
||||
|
||||
+2
-5
@@ -1,5 +1,7 @@
|
||||
load("@sourcekit_bazel_bsp//rules:setup_sourcekit_bsp.bzl", "setup_sourcekit_bsp")
|
||||
|
||||
exports_files(["versions.json"])
|
||||
|
||||
setup_sourcekit_bsp(
|
||||
name = "setup_sourcekit_bsp",
|
||||
bazel_wrapper = "./build-input/bazel-8.4.2-darwin-arm64",
|
||||
@@ -18,17 +20,12 @@ setup_sourcekit_bsp(
|
||||
"submodules/**/*.cpp",
|
||||
],
|
||||
aquery_flags = [
|
||||
"define=telegramVersion=12.5",
|
||||
"define=buildNumber=100000",
|
||||
],
|
||||
index_flags = [
|
||||
"config=index_build",
|
||||
"define=telegramVersion=12.5",
|
||||
"define=buildNumber=100000",
|
||||
],
|
||||
index_build_batch_size = 10,
|
||||
targets = [
|
||||
"//Telegram:Telegram",
|
||||
],
|
||||
merge_lsp_config = False,
|
||||
)
|
||||
|
||||
+17
-7
@@ -385,7 +385,8 @@ plist_fragment(
|
||||
"""
|
||||
<key>CFBundleVersion</key>
|
||||
<string>{buildNumber}</string>
|
||||
"""
|
||||
""",
|
||||
defaults = {"buildNumber": "1"},
|
||||
)
|
||||
|
||||
plist_fragment(
|
||||
@@ -574,14 +575,23 @@ plist_fragment(
|
||||
])
|
||||
)
|
||||
|
||||
plist_fragment(
|
||||
genrule(
|
||||
name = "VersionInfoPlist",
|
||||
extension = "plist",
|
||||
template =
|
||||
"""
|
||||
srcs = ["//:versions.json"],
|
||||
outs = ["VersionInfoPlist.plist"],
|
||||
cmd = """
|
||||
version=$$(python3 -c "import json; print(json.load(open('$(location //:versions.json)'))['app'])")
|
||||
cat > $@ <<PLIST
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>{telegramVersion}</string>
|
||||
"""
|
||||
<string>$$version</string>
|
||||
</dict>
|
||||
</plist>
|
||||
PLIST
|
||||
""",
|
||||
)
|
||||
|
||||
plist_fragment(
|
||||
|
||||
@@ -43,14 +43,23 @@ plist_fragment(
|
||||
"""
|
||||
)
|
||||
|
||||
plist_fragment(
|
||||
genrule(
|
||||
name = "VersionInfoPlist",
|
||||
extension = "plist",
|
||||
template =
|
||||
"""
|
||||
srcs = ["//:versions.json"],
|
||||
outs = ["VersionInfoPlist.plist"],
|
||||
cmd = """
|
||||
version=$$(python3 -c "import json; print(json.load(open('$(location //:versions.json)'))['app'])")
|
||||
cat > $@ <<PLIST
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>{telegramVersion}</string>
|
||||
"""
|
||||
<string>$$version</string>
|
||||
</dict>
|
||||
</plist>
|
||||
PLIST
|
||||
""",
|
||||
)
|
||||
|
||||
plist_fragment(
|
||||
|
||||
@@ -212,7 +212,6 @@ class BazelCommandLine:
|
||||
def get_define_arguments(self):
|
||||
return [
|
||||
'--define=buildNumber={}'.format(self.build_number),
|
||||
'--define=telegramVersion={}'.format(self.build_environment.app_version)
|
||||
]
|
||||
|
||||
def get_project_generation_arguments(self):
|
||||
|
||||
Submodule build-system/bazel-rules/rules_apple updated: 39cc252924...f6aef7db5b
@@ -18,6 +18,8 @@ def _plist_fragment(ctx):
|
||||
resolved_values = dict()
|
||||
for key in found_keys:
|
||||
value = ctx.var.get(key, None)
|
||||
if value == None:
|
||||
value = ctx.attr.defaults.get(key, None)
|
||||
if value == None:
|
||||
fail("Expected value for --define={} was not found".format(key))
|
||||
resolved_values[key] = value
|
||||
@@ -38,6 +40,7 @@ plist_fragment = rule(
|
||||
attrs = {
|
||||
"extension": attr.string(mandatory = True),
|
||||
"template": attr.string(mandatory = True),
|
||||
"defaults": attr.string_dict(),
|
||||
},
|
||||
outputs = {
|
||||
"out": "%{name}.%{extension}"
|
||||
|
||||
@@ -10,12 +10,9 @@ WORKSPACE_ROOT=$(pwd)
|
||||
BAZEL_CMD="./build-input/bazel-8.4.2-darwin-arm64"
|
||||
|
||||
export ADDITIONAL_FLAGS=()
|
||||
TELEGRAM_VERSION=$(python3 -c "import json; print(json.load(open('${WORKSPACE_ROOT}/versions.json'))['app'])")
|
||||
|
||||
ADDITIONAL_FLAGS+=("--keep_going")
|
||||
ADDITIONAL_FLAGS+=("--color=yes")
|
||||
ADDITIONAL_FLAGS+=("--define=telegramVersion=${TELEGRAM_VERSION}")
|
||||
ADDITIONAL_FLAGS+=("--define=buildNumber=100000")
|
||||
|
||||
if [ -n "${BAZEL_EXTRA_BUILD_FLAGS:-}" ]; then
|
||||
ADDITIONAL_FLAGS+=("${BAZEL_EXTRA_BUILD_FLAGS[@]}")
|
||||
|
||||
@@ -551,80 +551,94 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
}
|
||||
}
|
||||
|
||||
let networkArguments = NetworkInitializationArguments(apiId: apiId, apiHash: apiHash, languagesCategory: languagesCategory, appVersion: appVersion, voipMaxLayer: PresentationCallManagerImpl.voipMaxLayer, voipVersions: PresentationCallManagerImpl.voipVersions(includeExperimental: true, includeReference: false).map { version, supportsVideo -> CallSessionManagerImplementationVersion in
|
||||
CallSessionManagerImplementationVersion(version: version, supportsVideo: supportsVideo)
|
||||
}, appData: self.regularDeviceToken.get()
|
||||
|> map { token in
|
||||
let tokenEnvironment: String
|
||||
#if DEBUG
|
||||
tokenEnvironment = "sandbox"
|
||||
#else
|
||||
tokenEnvironment = "production"
|
||||
#endif
|
||||
|
||||
let data = buildConfig.bundleData(withAppToken: token, tokenType: "apns", tokenEnvironment: tokenEnvironment, signatureDict: signatureDict)
|
||||
if let data = data, let _ = String(data: data, encoding: .utf8) {
|
||||
} else {
|
||||
Logger.shared.log("data", "can't deserialize")
|
||||
}
|
||||
return data
|
||||
}, externalRequestVerificationStream: self.firebaseRequestVerificationSecretStream.get(), externalRecaptchaRequestVerification: { method, siteKey in
|
||||
return Signal { subscriber in
|
||||
let recaptchaClient: Promise<RecaptchaClient>
|
||||
if let current = self.recaptchaClientsBySiteKey[siteKey] {
|
||||
recaptchaClient = current
|
||||
} else {
|
||||
recaptchaClient = Promise<RecaptchaClient>()
|
||||
self.recaptchaClientsBySiteKey[siteKey] = recaptchaClient
|
||||
|
||||
Recaptcha.fetchClient(withSiteKey: siteKey) { client, error in
|
||||
Queue.mainQueue().async {
|
||||
guard let client else {
|
||||
Logger.shared.log("App \(self.episodeId)", "RecaptchaClient creation error: \(String(describing: error)).")
|
||||
return
|
||||
}
|
||||
recaptchaClient.set(.single(client))
|
||||
}
|
||||
}
|
||||
}
|
||||
let networkArguments = NetworkInitializationArguments(
|
||||
apiId: apiId,
|
||||
apiHash: apiHash,
|
||||
languagesCategory: languagesCategory,
|
||||
appVersion: appVersion,
|
||||
voipMaxLayer: PresentationCallManagerImpl.voipMaxLayer,
|
||||
voipVersions: PresentationCallManagerImpl.voipVersions(includeExperimental: true, includeReference: false).map { version, supportsVideo -> CallSessionManagerImplementationVersion in
|
||||
CallSessionManagerImplementationVersion(version: version, supportsVideo: supportsVideo)
|
||||
},
|
||||
appData: self.regularDeviceToken.get() |> map { token in
|
||||
let tokenEnvironment: String
|
||||
#if DEBUG
|
||||
tokenEnvironment = "sandbox"
|
||||
#else
|
||||
tokenEnvironment = "production"
|
||||
#endif
|
||||
|
||||
return (recaptchaClient.get()
|
||||
|> take(1)
|
||||
|> mapToSignal { recaptchaClient -> Signal<String?, NoError> in
|
||||
return Signal { subscriber in
|
||||
var recaptchaAction: RecaptchaAction?
|
||||
switch method {
|
||||
case "signup":
|
||||
recaptchaAction = RecaptchaAction.signup
|
||||
default:
|
||||
break
|
||||
}
|
||||
let data = buildConfig.bundleData(withAppToken: token, tokenType: "apns", tokenEnvironment: tokenEnvironment, signatureDict: signatureDict)
|
||||
if let data = data, let _ = String(data: data, encoding: .utf8) {
|
||||
} else {
|
||||
Logger.shared.log("data", "can't deserialize")
|
||||
}
|
||||
return data
|
||||
},
|
||||
externalRequestVerificationStream: self.firebaseRequestVerificationSecretStream.get(),
|
||||
externalRecaptchaRequestVerification: { method, siteKey in
|
||||
return Signal<String?, NoError> { subscriber in
|
||||
let recaptchaClient: Promise<RecaptchaClient>
|
||||
if let current = self.recaptchaClientsBySiteKey[siteKey] {
|
||||
recaptchaClient = current
|
||||
} else {
|
||||
recaptchaClient = Promise<RecaptchaClient>()
|
||||
self.recaptchaClientsBySiteKey[siteKey] = recaptchaClient
|
||||
|
||||
guard let recaptchaAction else {
|
||||
subscriber.putNext(nil)
|
||||
subscriber.putCompletion()
|
||||
|
||||
return EmptyDisposable
|
||||
}
|
||||
recaptchaClient.execute(withAction: recaptchaAction) { token, error in
|
||||
if let token {
|
||||
subscriber.putNext(token)
|
||||
Logger.shared.log("App \(self.episodeId)", "RecaptchaClient executed successfully")
|
||||
} else {
|
||||
subscriber.putNext(nil)
|
||||
Logger.shared.log("App \(self.episodeId)", "RecaptchaClient execute error: \(String(describing: error))")
|
||||
Recaptcha.fetchClient(withSiteKey: siteKey) { client, error in
|
||||
Queue.mainQueue().async {
|
||||
guard let client else {
|
||||
Logger.shared.log("App \(self.episodeId)", "RecaptchaClient creation error: \(String(describing: error)).")
|
||||
return
|
||||
}
|
||||
recaptchaClient.set(.single(client))
|
||||
}
|
||||
subscriber.putCompletion()
|
||||
}
|
||||
|
||||
return ActionDisposable {
|
||||
}
|
||||
}
|
||||
|> runOn(Queue.mainQueue())
|
||||
}).startStandalone(next: subscriber.putNext, error: subscriber.putError, completed: subscriber.putCompletion)
|
||||
}
|
||||
|> runOn(Queue.mainQueue())
|
||||
}, autolockDeadine: autolockDeadine, encryptionProvider: OpenSSLEncryptionProvider(), deviceModelName: nil, useBetaFeatures: !buildConfig.isAppStoreBuild, isICloudEnabled: buildConfig.isICloudEnabled)
|
||||
|
||||
return (recaptchaClient.get()
|
||||
|> take(1)
|
||||
|> mapToSignal { recaptchaClient -> Signal<String?, NoError> in
|
||||
return Signal { subscriber in
|
||||
var recaptchaAction: RecaptchaAction?
|
||||
switch method {
|
||||
case "signup":
|
||||
recaptchaAction = RecaptchaAction.signup
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
guard let recaptchaAction else {
|
||||
subscriber.putNext(nil)
|
||||
subscriber.putCompletion()
|
||||
|
||||
return EmptyDisposable
|
||||
}
|
||||
recaptchaClient.execute(withAction: recaptchaAction) { token, error in
|
||||
if let token {
|
||||
subscriber.putNext(token)
|
||||
Logger.shared.log("App \(self.episodeId)", "RecaptchaClient executed successfully")
|
||||
} else {
|
||||
subscriber.putNext(nil)
|
||||
Logger.shared.log("App \(self.episodeId)", "RecaptchaClient execute error: \(String(describing: error))")
|
||||
}
|
||||
subscriber.putCompletion()
|
||||
}
|
||||
|
||||
return ActionDisposable {
|
||||
}
|
||||
}
|
||||
|> runOn(Queue.mainQueue())
|
||||
}).startStandalone(next: subscriber.putNext, error: subscriber.putError, completed: subscriber.putCompletion)
|
||||
}
|
||||
|> runOn(Queue.mainQueue())
|
||||
},
|
||||
autolockDeadine: autolockDeadine,
|
||||
encryptionProvider: OpenSSLEncryptionProvider(),
|
||||
deviceModelName: nil,
|
||||
useBetaFeatures: !buildConfig.isAppStoreBuild,
|
||||
isICloudEnabled: buildConfig.isICloudEnabled
|
||||
)
|
||||
|
||||
guard let appGroupUrl = maybeAppGroupUrl else {
|
||||
self.mainWindow?.presentNative(UIAlertController(title: nil, message: "Error 2", preferredStyle: .alert))
|
||||
|
||||
@@ -433,6 +433,12 @@ func chatHistoryEntriesForView(
|
||||
var i = 0
|
||||
let unreadEntry: ChatHistoryEntry = .UnreadEntry(maxReadIndex, presentationData)
|
||||
for entry in entries {
|
||||
if case let .MessageGroupEntry(_, messages, _) = entry {
|
||||
if !messages.isEmpty && maxReadIndex >= messages[0].0.index {
|
||||
i += 1
|
||||
continue
|
||||
}
|
||||
}
|
||||
if entry > unreadEntry {
|
||||
if i != 0 {
|
||||
entries.insert(unreadEntry, at: i)
|
||||
|
||||
@@ -65,7 +65,7 @@ func chatHistoryViewForLocation(
|
||||
|
||||
let combinedInitialData = ChatHistoryCombinedInitialData(initialData: initialData, buttonKeyboardMessage: view.topTaggedMessages.first, cachedData: cachedData, cachedDataMessages: cachedDataMessages, readStateData: readStateData)
|
||||
|
||||
if view.isLoading {
|
||||
if view.isLoading || (view.entries.isEmpty && (view.holeEarlier || view.holeLater)) {
|
||||
return .Loading(initialData: combinedInitialData, type: .Generic(type: updateType))
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ func chatHistoryViewForLocation(
|
||||
if preloaded {
|
||||
return .HistoryView(view: view, type: .Generic(type: updateType), scrollPosition: nil, flashIndicators: false, originalScrollPosition: nil, initialData: combinedInitialData, id: location.id)
|
||||
} else {
|
||||
if view.isLoading {
|
||||
if view.isLoading || (view.entries.isEmpty && (view.holeEarlier || view.holeLater)) {
|
||||
return .Loading(initialData: combinedInitialData, type: .Generic(type: updateType))
|
||||
}
|
||||
var scrollPosition: ChatHistoryViewScrollPosition?
|
||||
@@ -311,7 +311,7 @@ func chatHistoryViewForLocation(
|
||||
|
||||
let combinedInitialData = ChatHistoryCombinedInitialData(initialData: initialData, buttonKeyboardMessage: view.topTaggedMessages.first, cachedData: cachedData, cachedDataMessages: cachedDataMessages, readStateData: readStateData)
|
||||
|
||||
if view.isLoading {
|
||||
if view.isLoading || (view.entries.isEmpty && (view.holeEarlier || view.holeLater)) {
|
||||
return ChatHistoryViewUpdate.Loading(initialData: combinedInitialData, type: .Generic(type: updateType))
|
||||
}
|
||||
|
||||
@@ -461,7 +461,7 @@ func fetchAndPreloadReplyThreadInfo(context: AccountContext, subject: ReplyThrea
|
||||
case .Loading:
|
||||
return nil
|
||||
case let .HistoryView(view, _, _, _, _, _, _):
|
||||
if view.isLoading {
|
||||
if view.isLoading || (view.entries.isEmpty && (view.holeEarlier || view.holeLater)) {
|
||||
return nil
|
||||
}
|
||||
return view.entries.isEmpty
|
||||
|
||||
@@ -50,6 +50,8 @@ private struct AccountTasks {
|
||||
}
|
||||
}
|
||||
|
||||
private let backgroundTaskSubmissionDelay: Double = 10.0
|
||||
|
||||
private struct PendingMediaUploadKey: Hashable {
|
||||
let accountId: AccountRecordId
|
||||
let messageId: MessageId
|
||||
@@ -99,7 +101,8 @@ public final class SharedWakeupManager {
|
||||
private var backgroundProcessingTaskId: String?
|
||||
private var backgroundProcessingTaskLaunched: Bool = false
|
||||
private var backgroundProcessingTaskCancellationRequestedByApp: Bool = false
|
||||
|
||||
private var pendingBackgroundProcessingTaskTimer: SwiftSignalKit.Timer?
|
||||
|
||||
private var pendingStoryUploadsByKey: [PendingStoryUploadKey: Float] = [:]
|
||||
private var pendingStoryUploadStatusesByKey: [PendingStoryUploadKey: PendingStoryUploadStatus] = [:]
|
||||
private var backgroundStoryProcessingTaskProgressByKey: [PendingStoryUploadKey: Float] = [:]
|
||||
@@ -107,7 +110,8 @@ public final class SharedWakeupManager {
|
||||
private var backgroundStoryProcessingTaskId: String?
|
||||
private var backgroundStoryProcessingTaskLaunched: Bool = false
|
||||
private var backgroundStoryProcessingTaskCancellationRequestedByApp: Bool = false
|
||||
|
||||
private var pendingBackgroundStoryProcessingTaskTimer: SwiftSignalKit.Timer?
|
||||
|
||||
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())
|
||||
|
||||
@@ -155,6 +159,10 @@ public final class SharedWakeupManager {
|
||||
}
|
||||
strongSelf.allowBackgroundTimeExtensionDeadlineTimer?.invalidate()
|
||||
strongSelf.allowBackgroundTimeExtensionDeadlineTimer = nil
|
||||
strongSelf.pendingBackgroundProcessingTaskTimer?.invalidate()
|
||||
strongSelf.pendingBackgroundProcessingTaskTimer = nil
|
||||
strongSelf.pendingBackgroundStoryProcessingTaskTimer?.invalidate()
|
||||
strongSelf.pendingBackgroundStoryProcessingTaskTimer = nil
|
||||
}
|
||||
strongSelf.updateBackgroundProcessingTaskStateFromPendingMediaUploads()
|
||||
strongSelf.updateBackgroundProcessingTaskStateFromPendingStoryUploads()
|
||||
@@ -356,6 +364,8 @@ public final class SharedWakeupManager {
|
||||
self.pendingStoryUploadsDisposable?.dispose()
|
||||
self.managedPausedInBackgroundPlayer?.dispose()
|
||||
self.keepIdleDisposable?.dispose()
|
||||
self.pendingBackgroundProcessingTaskTimer?.invalidate()
|
||||
self.pendingBackgroundStoryProcessingTaskTimer?.invalidate()
|
||||
if let (taskId, _, timer) = self.currentTask {
|
||||
timer.invalidate()
|
||||
self.endBackgroundTask(taskId)
|
||||
@@ -369,19 +379,30 @@ public final class SharedWakeupManager {
|
||||
|
||||
let shouldHaveTask = !self.pendingMediaUploadsByKey.isEmpty && !self.inForeground
|
||||
let hadTask = self.backgroundProcessingTaskId != nil
|
||||
|
||||
|
||||
if shouldHaveTask {
|
||||
if !hadTask {
|
||||
self.startBackgroundProcessingTaskIfNeeded()
|
||||
if !hadTask && self.pendingBackgroundProcessingTaskTimer == nil {
|
||||
let timer = SwiftSignalKit.Timer(timeout: backgroundTaskSubmissionDelay, repeat: false, completion: { [weak self] in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.pendingBackgroundProcessingTaskTimer = nil
|
||||
self.startBackgroundProcessingTaskIfNeeded()
|
||||
}, queue: .mainQueue())
|
||||
self.pendingBackgroundProcessingTaskTimer = timer
|
||||
timer.start()
|
||||
}
|
||||
} else {
|
||||
self.pendingBackgroundProcessingTaskTimer?.invalidate()
|
||||
self.pendingBackgroundProcessingTaskTimer = nil
|
||||
|
||||
if let backgroundProcessingTaskId = self.backgroundProcessingTaskId {
|
||||
if !self.backgroundProcessingTaskCancellationRequestedByApp {
|
||||
self.backgroundProcessingTaskCancellationRequestedByApp = true
|
||||
BGTaskScheduler.shared.cancel(taskRequestWithIdentifier: backgroundProcessingTaskId)
|
||||
Logger.shared.log("Wakeup", "Requested BG task cancellation by app: \(backgroundProcessingTaskId)")
|
||||
}
|
||||
|
||||
|
||||
if !self.backgroundProcessingTaskLaunched {
|
||||
self.backgroundProcessingTaskId = nil
|
||||
self.backgroundProcessingTaskProgressByKey = [:]
|
||||
@@ -399,19 +420,30 @@ public final class SharedWakeupManager {
|
||||
|
||||
let shouldHaveTask = !self.pendingStoryUploadStatusesByKey.isEmpty && !self.inForeground
|
||||
let hadTask = self.backgroundStoryProcessingTaskId != nil
|
||||
|
||||
|
||||
if shouldHaveTask {
|
||||
if !hadTask {
|
||||
self.startBackgroundStoryProcessingTaskIfNeeded()
|
||||
if !hadTask && self.pendingBackgroundStoryProcessingTaskTimer == nil {
|
||||
let timer = SwiftSignalKit.Timer(timeout: backgroundTaskSubmissionDelay, repeat: false, completion: { [weak self] in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.pendingBackgroundStoryProcessingTaskTimer = nil
|
||||
self.startBackgroundStoryProcessingTaskIfNeeded()
|
||||
}, queue: .mainQueue())
|
||||
self.pendingBackgroundStoryProcessingTaskTimer = timer
|
||||
timer.start()
|
||||
}
|
||||
} else {
|
||||
self.pendingBackgroundStoryProcessingTaskTimer?.invalidate()
|
||||
self.pendingBackgroundStoryProcessingTaskTimer = nil
|
||||
|
||||
if let backgroundStoryProcessingTaskId = self.backgroundStoryProcessingTaskId {
|
||||
if !self.backgroundStoryProcessingTaskCancellationRequestedByApp {
|
||||
self.backgroundStoryProcessingTaskCancellationRequestedByApp = true
|
||||
BGTaskScheduler.shared.cancel(taskRequestWithIdentifier: backgroundStoryProcessingTaskId)
|
||||
Logger.shared.log("Wakeup", "Requested story BG task cancellation by app: \(backgroundStoryProcessingTaskId)")
|
||||
}
|
||||
|
||||
|
||||
if !self.backgroundStoryProcessingTaskLaunched {
|
||||
self.backgroundStoryProcessingTaskId = nil
|
||||
self.backgroundStoryProcessingTaskProgressByKey = [:]
|
||||
|
||||
Reference in New Issue
Block a user