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

[JS-951] fix: use ember-local-storage for both read & write FF #112

Merged
merged 2 commits into from
May 5, 2021

Conversation

romgere
Copy link
Contributor

@romgere romgere commented Apr 9, 2021

Fix

Use ember-local-storage for both read & write FF to prevent issue when ember-local-storage options differents from default (#112)

This fix #111

@@ -0,0 +1,6 @@
import Service from '@ember/service'
Copy link
Member

Choose a reason for hiding this comment

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

Am I right saying that you created this Service, with only 1 property, just to make it easier to mock it during tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, the purpose of this property is to be read from instance-initializers/load-feature-controls.js & keeping consistency between read & write on local-storage....

In other words, I didn't find the way to properly take into account the ember-local-storage settings in instance-initializers when reading from local-storage without using this service...

Comment on lines +11 to 19
let { content: featureControls } = controlStorageService.get('featuresLS')
if (featureControls) {
Object.keys(featureControls).forEach(flag => {
if (features.get("flags").includes(flag)) {
featureControls[flag] ? features.enable(flag) : features.disable(flag)
}
})

}
Copy link
Member

@MrChocolatine MrChocolatine May 5, 2021

Choose a reason for hiding this comment

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

Simple suggestion not necessary of course 👍🏻 .

  • Without if

  • Direct access to flags value with Object.entries()
    But I admit it is less supported than Object.keys.

Suggested change
let { content: featureControls } = controlStorageService.get('featuresLS')
if (featureControls) {
Object.keys(featureControls).forEach(flag => {
if (features.get("flags").includes(flag)) {
featureControls[flag] ? features.enable(flag) : features.disable(flag)
}
})
}
let featureControls = controlStorageService.get('featuresLS').content ?? {}
Object.entries(featureControls).forEach(([ flag, flagValue ]) => {
if (features.flags.includes(flag)) {
flagValue ? features.enable(flag) : features.disable(flag)
}
})

@romgere romgere merged commit f215da7 into master May 5, 2021
@romgere romgere deleted the fix/js-951 branch May 5, 2021 13:49
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.

[JS-951] ember-local-storage config is not correctly handle when not default
2 participants