Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings Sync: Set Modified Date on settings import #1616

Open
wants to merge 9 commits into
base: bjtitus/settings-sync/up-next-setting
Choose a base branch
from

Conversation

bjtitus
Copy link
Contributor

@bjtitus bjtitus commented Apr 12, 2024

Depends On #1615

Set the Modified Date on all imported settings to 1 second after the epoch date.

  • This ensures that imported settings are sent to the server (any settings without a date are not).
  • By defaulting to 1 second after, the setting is stored by the server. A default epoch date is effectively a "null" value and will not replace the default value.

To test

  • Change the return value of shouldEnableSyncedSettings in FeatureFlag.swift to false
  • Build and run
  • Log in to an account which hasn't used synced settings
  • Change a few settings
  • Enable the newSettingsStorage and settingsSync feature flags
  • Restart the app
  • Pull to refresh or tap "Refresh Now" in profile
  • Ensure changed settings remain
  • Delete the app
  • Change shouldEnableSyncedSettings in FeatureFlag.swift back to its original implementation or set to true
  • Build and run
  • Log in to the same account from above
  • Verify that the changed settings are the same as when changed above

Checklist

  • I have considered if this change warrants user-facing release notes and have added them to CHANGELOG.md if necessary.
  • I have considered adding unit tests for my changes.
  • I have updated (or requested that someone edit) the spreadsheet to reflect any new or changed analytics.

@bjtitus bjtitus added the settings Issues related to user or podcast settings label Apr 12, 2024
@bjtitus bjtitus added this to the 7.62 milestone Apr 12, 2024
@dangermattic
Copy link
Collaborator

dangermattic commented Apr 12, 2024

1 Warning
⚠️ This PR is assigned to the milestone 7.63. The due date for this milestone has already passed.
Please assign it to a milestone with a later deadline or check whether the release for this milestone has already been finished.

Generated by 🚫 Danger

This ensures it doesn't match the server value, which would end up overwriting it.
@bjtitus bjtitus marked this pull request as ready for review April 12, 2024 02:57
@bjtitus bjtitus requested a review from a team as a code owner April 12, 2024 02:57
@bjtitus bjtitus requested review from leandroalonso and removed request for a team April 12, 2024 02:57
@SergioEstevao SergioEstevao requested review from SergioEstevao and removed request for leandroalonso April 12, 2024 14:04
self.update(\.$autoPlayEnabled, value: UserDefaults.standard.bool(forKey: Constants.UserDefaults.autoplay))
self.update(\.$notifications, value: UserDefaults.standard.bool(forKey: Constants.UserDefaults.pushEnabled))
self.update(\.$appBadge, value: Int32(UserDefaults.standard.integer(forKey: Constants.UserDefaults.appBadge)))
let date = Date(timeIntervalSince1970: 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe Date.distantPast will be more clear here.

Copy link
Member

Choose a reason for hiding this comment

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

@SergioEstevao I don't think we can use that as per:

By defaulting to 1 second after, the setting is stored by the server. A default epoch date is effectively a "null" value and will not replace the default value.

This would probably result in the setting being discarded by the server.

Copy link
Contributor

Choose a reason for hiding this comment

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

So any reference date will be discarded is this what this means: A default epoch date ?

@@ -5,37 +5,38 @@ extension DataManager {
func importPodcastSettings() {
let podcasts = allPodcasts(includeUnsubscribed: true)

let date = Date(timeIntervalSince1970: 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above: Date.distantPast

@SergioEstevao SergioEstevao self-requested a review April 12, 2024 14:46
Copy link
Contributor

@SergioEstevao SergioEstevao left a comment

Choose a reason for hiding this comment

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

Working good, just a small comment about the way the date is set.

Copy link
Member

@leandroalonso leandroalonso left a comment

Choose a reason for hiding this comment

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

@bjtitus this is really not working for me. I'm gonna send you a video in a DM.

self.update(\.$autoPlayEnabled, value: UserDefaults.standard.bool(forKey: Constants.UserDefaults.autoplay))
self.update(\.$notifications, value: UserDefaults.standard.bool(forKey: Constants.UserDefaults.pushEnabled))
self.update(\.$appBadge, value: Int32(UserDefaults.standard.integer(forKey: Constants.UserDefaults.appBadge)))
let date = Date(timeIntervalSince1970: 1)

Choose a reason for hiding this comment

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

Just double checking if this could be changed to 1 millisecond or should we adjust on Android to 1 second?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll get this updated today. I still need to double check the comparisons to make sure the precision is working.

@@ -5,40 +5,42 @@ extension DataManager {
func importPodcastSettings() {
let podcasts = allPodcasts(includeUnsubscribed: true)

let date = Date(timeIntervalSince1970: 1)
Copy link

@MiSikora MiSikora Apr 15, 2024

Choose a reason for hiding this comment

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

Same as #1616 (comment)

Copy link
Member

@leandroalonso leandroalonso left a comment

Choose a reason for hiding this comment

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

@bjtitus the Up Next setting is now persisting correctly, but I still have issues with the Settings under Appearance.

@SergioEstevao SergioEstevao modified the milestones: 7.62, 7.63 Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
settings Issues related to user or podcast settings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants