Skip to content

Commit 30e526a

Browse files
Signing back in: fixes issues with outdated podcast information (#1778)
2 parents 860c76e + fc07eb1 commit 30e526a

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

Modules/Server/Sources/PocketCastsServer/Public/ServerSettings.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ public class ServerSettings {
278278
UserDefaults.standard.removeObject(forKey: ServerConstants.UserDefaults.lastSyncTime)
279279
}
280280

281+
public class var lastSyncTime: Date? {
282+
UserDefaults.standard.object(forKey: ServerConstants.UserDefaults.lastSyncTime) as? Date
283+
}
284+
281285
// Push Token
282286
public class func pushToken() -> String? {
283287
UserDefaults.standard.string(forKey: ServerConstants.UserDefaults.pushToken)

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ public enum FeatureFlag: String, CaseIterable {
5454
/// This is to fix this: https://a8c.sentry.io/share/issue/39a6d2958b674ec3b7a4d9248b4b5ffa/
5555
case defaultPlayerFilterCallbackFix
5656

57+
/// When a user sign in, we always mark ALL podcasts as unsynced
58+
/// This recently caused issues, syncing changes that shouldn't have been synced
59+
/// When `true`, we only mark podcasts as unsynced if the user never signed in before
60+
case onlyMarkPodcastsUnsyncedForNewUsers
61+
5762
public var enabled: Bool {
5863
if let overriddenValue = FeatureFlagOverrideStore().overriddenValue(for: self) {
5964
return overriddenValue
@@ -100,6 +105,8 @@ public enum FeatureFlag: String, CaseIterable {
100105
true
101106
case .upNextOnTabBar:
102107
true
108+
case .onlyMarkPodcastsUnsyncedForNewUsers:
109+
true
103110
}
104111
}
105112

podcasts/AuthenticationHelper.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,12 @@ class AuthenticationHelper {
6464
ServerSettings.syncingV2Token = response.token
6565
ServerSettings.refreshToken = response.refreshToken
6666

67-
// we've signed in, set all our existing podcasts to be non synced
68-
DataManager.sharedManager.markAllPodcastsUnsynced()
67+
// we've signed in, set all our existing podcasts to
68+
// be non synced if the user never logged in before
69+
if (FeatureFlag.onlyMarkPodcastsUnsyncedForNewUsers.enabled && ServerSettings.lastSyncTime == nil)
70+
|| !FeatureFlag.onlyMarkPodcastsUnsyncedForNewUsers.enabled {
71+
DataManager.sharedManager.markAllPodcastsUnsynced()
72+
}
6973

7074
SyncManager.syncReason = .login
7175
ServerSettings.clearLastSyncTime()

podcasts/DeveloperMenu.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ struct DeveloperMenu: View {
3737
}
3838
}
3939

40+
Button("Clear all folder information") {
41+
DataManager.sharedManager.clearAllFolderInformation()
42+
}
43+
4044
Button("Force Reload Feature Flags") {
4145
FirebaseManager.refreshRemoteConfig(expirationDuration: 0) { _ in
4246
(UIApplication.shared.delegate as? AppDelegate)?.updateRemoteFeatureFlags()

podcasts/SyncSigninViewController.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,12 @@ class SyncSigninViewController: PCViewController, UITextFieldDelegate {
330330
ServerSettings.userId = userId
331331
ServerSettings.saveSyncingPassword(password)
332332

333-
// we've signed in, set all our existing podcasts to be non synced
334-
DataManager.sharedManager.markAllPodcastsUnsynced()
333+
// we've signed in, set all our existing podcasts to
334+
// be non synced if the user never logged in before
335+
if (FeatureFlag.onlyMarkPodcastsUnsyncedForNewUsers.enabled && ServerSettings.lastSyncTime == nil)
336+
|| !FeatureFlag.onlyMarkPodcastsUnsyncedForNewUsers.enabled {
337+
DataManager.sharedManager.markAllPodcastsUnsynced()
338+
}
335339

336340
SyncManager.syncReason = .login
337341
ServerSettings.clearLastSyncTime()

0 commit comments

Comments
 (0)