Closed javoire closed 2 weeks ago
I think easiest and less intrusive is to just have an incremental schema version that only changes when the config schema changes (instead of every release version of the extension.. )
eg
var DEFAULT_CONFIG = {
schemaVersion: 1,
// inputs:
// these are the `name="something-checkbox"` etc,
// names need to be manually in sync...
extensionEnabled: true,
fontEnabled: true,
rulerEnabled: true,
rulerSize: 30,
fontChoice: 'opendyslexic'
};
only wipe storage if schema new version is higher
When a new version is published, whatever is stored in
chrome.storage
remains from the old version. It's a good practice to wipe the existing storage when a new version is published to avoid conflicts and bugs. At least if the new version changes the schema of the storage object, but to be safe it's best to always wipe it. That way no old config keys will remain to potentially cause issues, though low likelihood.Or check if the existing config object keys do not match the keys in the default config, and in that case wipe it. Could potentially be bug prone though