feat(useFeatures): add persist option#388
Open
johnleider wants to merge 2 commits into
Open
Conversation
Setting persist: true saves the set of enabled feature flags to storage and reconciles them against the registered flags on load, so a user's feature toggles survive a page reload. Wires the existing createPluginContext persist/restore hooks; the selected flag ids round-trip through storage keyed by the plugin namespace.
Drops the hand-rolled devmode persistence (manual localStorage read in
zero.ts and duplicate watch+storage.set in AppBar and AppSettingsSheet) in
favor of createFeaturesPlugin({ persist: true }).
|
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
persistoption tocreateFeaturesPlugin, closing the gap that leftuseFeaturesas the only user-state plugin without persistence (useTheme,useRtl,useReducedMotion,useLocalealready have it).feat(useFeatures)
createFeaturesPlugin({ persist: true })saves the set of enabled feature flags to storage and reconciles them against the registered flags on load, so a user's toggles survive a reload. Implemented via the existingcreatePluginContextpersist/restore hooks; the selected flag ids round-trip through storage keyed by the plugin namespace (v0:features).docs cleanup (the payoff)
The docs app was hand-rolling devmode persistence in two places — a manual
localStorageread inzero.tsand a duplicatedwatch(() => devmode.isSelected.value, …) → storage.set('devmode')in bothAppBar.vueandAppSettingsSheet.vue. All of it is removed in favor ofpersist: true.Verified end-to-end on the docs app: toggling devmode writes
v0:features, and a reload restores the selection (the devmode-gated/healthnav link reappears).Note: the storage key moves from the old
v0:devmodeboolean tov0:features(an id array), so an existing devmode toggle resets once on first load after upgrade.