-
Notifications
You must be signed in to change notification settings - Fork 110
Open
Labels
refactorCode improvement without changing behaviorCode improvement without changing behavior
Description
Description
We plan to migrate MYNT from localStorage to the browser Storage API (browser.storage.local / chrome.storage.sync) for better reliability and optional cross-device sync support on Chrome.
This issue tracks the migration plan and key considerations.
Proposed changes
- Use
browser.storage.local/chrome.storage.syncinstead oflocalStorage - Keep using
localStoragefor quotes and IndexedDB for wallpapers due to Chrome sync storage limits
Things to take care of
1. Migration of existing users’ data
- Detect existing settings stored in
localStorage - Migrate them to the new Storage API
- Clear
localStorageafter successful migration - Ensure no user data loss during update
2. Chrome vs Firefox handling
- Use
chrome.storage.syncon Chrome (if available) - Fallback to
browser/chrome.storage.localon Firefox - Firefox will remain local-only (no sync support)
3. Chrome storage.sync limits
- Respect Chrome sync quotas
- Sync only lightweight settings
- Continue storing wallpapers and quotes locally
4. Offline support
- Extension must work fully offline
storage.syncwrites locally first- Sync happens later when the browser is online
- Code must not assume internet availability
5. Async handling
chrome.storage.*APIs are asynchronous- UI must wait for settings before rendering
- Avoid race conditions on startup
6. Centralized storage wrapper
Use a single wrapper everywhere in the codebase, for example:
const Storage = {
get: (keys) => {
if (chrome.storage?.sync) return chrome.storage.sync.get(keys);
return chrome.storage.local.get(keys);
},
set: (obj) => {
if (chrome.storage?.sync) return chrome.storage.sync.set(obj);
return chrome.storage.local.set(obj);
}
};7. Initial sync timing
- Chrome sync is not instant on fresh installs
- Load default UI first
- Update UI when synced settings arrive using
storage.onChanged
8. Backup and restore compatibility
- Old backups (localStorage-based) must continue to work
- New backups should be created from the Storage API
- Restore logic must support both formats
9. Required permission
Add to manifest.json:
"permissions": ["storage"]10. Avoid double-saving
-
Do not save the same data in:
localStoragechrome.storage.localchrome.storage.sync
-
After migration, maintain a single source of truth
Note
AI generated description (Errors are there)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
refactorCode improvement without changing behaviorCode improvement without changing behavior