Skip to content

Commit 4aeceb6

Browse files
committed
Add fix for stale replace removal
1 parent fb552fd commit 4aeceb6

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Modules/Server/Sources/PocketCastsServer/Public/Sync/UpNextSyncTask.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,13 @@ class UpNextSyncTask: ApiBaseTask {
132132
// save the server last modified so we can send it back next time. For legacy compatibility this is stored as a string
133133
UserDefaults.standard.set("\(response.serverModified)", forKey: ServerConstants.UserDefaults.upNextServerLastModified)
134134

135-
clearSyncedData(latestActionTime: latestActionTime)
135+
// For login syncs, clear all pending changes since we've applied server state
136+
// and any pending changes are stale. See: https://github.com/Automattic/pocket-casts-ios/issues/XXXX
137+
if SyncManager.syncReason == .login && FeatureFlag.clearPendingUpNextChangesOnLogin.enabled {
138+
clearSyncedData(latestActionTime: Int64.max)
139+
} else {
140+
clearSyncedData(latestActionTime: latestActionTime)
141+
}
136142
} catch {
137143
FileLog.shared.addMessage("UpNextSyncTask: Failed to decode server data")
138144
}

Modules/Utils/Sources/PocketCastsUtils/Feature Flags/FeatureFlag.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ public enum FeatureFlag: String, CaseIterable {
286286
/// Use WCSessionFileTransfer to send logs from watchOS to iPhone instead of sendMessage reply
287287
case watchLogFileTransfer
288288

289+
/// Clear all pending Up Next changes on login sync to prevent stale replace actions from being sent
290+
case clearPendingUpNextChangesOnLogin
291+
289292
public var enabled: Bool {
290293
if let overriddenValue = FeatureFlagOverrideStore().overriddenValue(for: self) {
291294
return overriddenValue
@@ -480,6 +483,8 @@ public enum FeatureFlag: String, CaseIterable {
480483
true
481484
case .watchLogFileTransfer:
482485
true
486+
case .clearPendingUpNextChangesOnLogin:
487+
false
483488
}
484489
}
485490

0 commit comments

Comments
 (0)