Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ public class ServerSettings {
UserDefaults.standard.removeObject(forKey: ServerConstants.UserDefaults.lastSyncTime)
}

public class var lastSyncTime: Date? {
UserDefaults.standard.object(forKey: ServerConstants.UserDefaults.lastSyncTime) as? Date
}

// Push Token
public class func pushToken() -> String? {
UserDefaults.standard.string(forKey: ServerConstants.UserDefaults.pushToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public enum FeatureFlag: String, CaseIterable {
/// This is to fix this: https://a8c.sentry.io/share/issue/39a6d2958b674ec3b7a4d9248b4b5ffa/
case defaultPlayerFilterCallbackFix

/// When a user sign in, we always mark ALL podcasts as unsynced
/// This recently caused issues, syncing changes that shouldn't have been synced
/// When `true`, we only mark podcasts as unsynced if the user never signed in before
case onlyMarkPodcastsUnsyncedForNewUsers

public var enabled: Bool {
if let overriddenValue = FeatureFlagOverrideStore().overriddenValue(for: self) {
return overriddenValue
Expand Down Expand Up @@ -100,6 +105,8 @@ public enum FeatureFlag: String, CaseIterable {
true
case .upNextOnTabBar:
true
case .onlyMarkPodcastsUnsyncedForNewUsers:
true
}
}

Expand Down
8 changes: 6 additions & 2 deletions podcasts/AuthenticationHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,12 @@ class AuthenticationHelper {
ServerSettings.syncingV2Token = response.token
ServerSettings.refreshToken = response.refreshToken

// we've signed in, set all our existing podcasts to be non synced
DataManager.sharedManager.markAllPodcastsUnsynced()
// we've signed in, set all our existing podcasts to
// be non synced if the user never logged in before
if (FeatureFlag.onlyMarkPodcastsUnsyncedForNewUsers.enabled && ServerSettings.lastSyncTime == nil)
|| !FeatureFlag.onlyMarkPodcastsUnsyncedForNewUsers.enabled {
DataManager.sharedManager.markAllPodcastsUnsynced()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@geekygecko Before merging this I'd like to double-check with you as I might be missing any user case.

The app will only mark all podcasts as unsynced if the user has never logged in to any account in this device.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they have just signed in, the last sync should be nil already. 🤔
If they signed out for six months and subscribed to many podcasts, then signed in again, won't that mean those new podcasts won't appear on their other devices?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't that mean those new podcasts won't appear on their other devices?

Based on my tests it syncs just fine (as per the PR description)

}

SyncManager.syncReason = .login
ServerSettings.clearLastSyncTime()
Expand Down
4 changes: 4 additions & 0 deletions podcasts/DeveloperMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ struct DeveloperMenu: View {
}
}

Button("Clear all folder information") {
DataManager.sharedManager.clearAllFolderInformation()
}

Button("Force Reload Feature Flags") {
FirebaseManager.refreshRemoteConfig(expirationDuration: 0) { _ in
(UIApplication.shared.delegate as? AppDelegate)?.updateRemoteFeatureFlags()
Expand Down
8 changes: 6 additions & 2 deletions podcasts/SyncSigninViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,12 @@ class SyncSigninViewController: PCViewController, UITextFieldDelegate {
ServerSettings.userId = userId
ServerSettings.saveSyncingPassword(password)

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

SyncManager.syncReason = .login
ServerSettings.clearLastSyncTime()
Expand Down