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

Display different copy in alerts when a flag is enabled in a newer version #633

Merged
merged 3 commits into from
Jan 25, 2024

Conversation

SabrinaTardio
Copy link
Contributor

@SabrinaTardio SabrinaTardio commented Jan 24, 2024

Please review the release process for BrowserServicesKit here.

Required:

Task/Issue URL: https://app.asana.com/0/72649045549333/1206310394453442/f
iOS PR: duckduckgo/iOS#2374
macOS PR: duckduckgo/macos-browser#2114
What kind of version bump will this require?: Major/Minor/Patch

Description: Shows a different copy in alerts when a sync flag is enabled in a newer version and the user needs to update the app

Steps to test this PR:

  1. in the PrivacyConfig file increase the min version for the sync feature and each subfeature one at a time.
  2. In both sync the enabled and disabled sync setting version (if visible) check that the right alert is shown (asking user to upgrade)
  3. Disable completely the flags one at a time, and check and go to the sync settings and check the alert is the generic sync is unavailable one

<!—
Before submitting a PR, please ensure you have tested the combinations you expect the reviewer to test, then delete configurations you know do not need explicit testing.

Using a simulator where a physical device is unavailable is acceptable.
—>

OS Testing:

  • iOS 14
  • iOS 15
  • iOS 16
  • macOS 10.15
  • macOS 11
  • macOS 12

Internal references:

Software Engineering Expectations
Technical Design Template

@SabrinaTardio SabrinaTardio self-assigned this Jan 24, 2024
@SabrinaTardio SabrinaTardio requested a review from ayoy January 24, 2024 13:23
@SabrinaTardio SabrinaTardio marked this pull request as ready for review January 24, 2024 13:24
Copy link
Contributor

@ayoy ayoy left a comment

Choose a reason for hiding this comment

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

LGTM! I left a few comments that could improve readability, but I'm only strong on the public private(set) thingy, otherwise it's solid and you can decide to address remaining comments or not. Will have a look at client PRs now. Thanks @SabrinaTardio!

@@ -24,6 +24,7 @@ import Foundation
*/
public struct SyncFeatureFlags: OptionSet {
public let rawValue: Int
public var unavailableReason: PrivacyConfigurationFeatureDisabledReason?
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be a public private(set) var, so that it can't be modified from outside.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! def should have done that

@@ -68,20 +69,39 @@ public struct SyncFeatureFlags: OptionSet {
// MARK: -

init(privacyConfig: PrivacyConfiguration) {
guard privacyConfig.isEnabled(featureKey: .sync) else {
var offFlag: SyncSubfeature?
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't calling it disabledSubfeature make it more clear?

Comment on lines 25 to 27
public struct SyncFeatureFlags: OptionSet {
public let rawValue: Int
public var unavailableReason: PrivacyConfigurationFeatureDisabledReason?
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this approach a lot. I didn't think about it initially because I'm having this mindset that OptionSet is basically an enum so we shouldn't be adding other fields to it, besides the raw value. But since enums have associated values, why not add an extra field to an OptionSet struct if it's needed. It looks like an equivalent of an enum's associated value.

Good job! 👏

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 know what you mean lol… initially it didn’t come to me intuitively to do that… and then I thought… why not! we do it for enum too ahahah

Comment on lines 97 to 104
if let offFlag {
let state = privacyConfig.stateFor(offFlag)
switch state {
case .enabled:
break
case .disabled(let reason):
unavailableReason = reason
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This was a bit confusing to me at the beginning and I had to follow the code closely to understand it better. Could we rewrite it as follows?

Suggested change
if let offFlag {
let state = privacyConfig.stateFor(offFlag)
switch state {
case .enabled:
break
case .disabled(let reason):
unavailableReason = reason
}
if let offFlag, case .disabled(let reason) = privacyConfig.stateFor(offFlag) {
unavailableReason = reason
}

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 personally find this less readable because is condensed but I’ll change it… cause it's probably just me 😄

@SabrinaTardio SabrinaTardio merged commit 826d7d9 into main Jan 25, 2024
5 checks passed
@SabrinaTardio SabrinaTardio deleted the sabrina/sync-flag-min-version branch January 25, 2024 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants