-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: add backup settings to app storage #2193
feat: add backup settings to app storage #2193
Conversation
This is draft from copilot workspace as a starter. Add a setting option to toggle backup of settings to app storage. * Add a new checkbox for "Backup settings to app storage" in `src/settings.ts`. * Update `src/utils.ts` to handle the backup toggle and sync the choice when enabled. * Modify `src/sw.ts` to include the backup settings during installation or update. * Add tests in `test/unit/settings.test.ts` to verify the backup toggle functionality and safety check for exceeding local storage. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/maxmilton/new-tab?shareId=XXXX-XXXX-XXXX-XXXX).
src/utils.ts
Outdated
@@ -51,3 +51,37 @@ | |||
|
|||
s.focus(); | |||
}; | |||
|
|||
// Add a new property `backup` to the `storage` object to store the backup setting | |||
export const storage: UserStorageData = await chrome.storage.local.get(); |
Check failure
Code scanning / CodeQL
Assignment to constant Error
declared
src/utils.ts
Outdated
storage.backup = storage.backup ?? false; | ||
|
||
// Update the `handleClick` function to include logic for syncing settings when backup is enabled | ||
export const handleClick = (event: MouseEvent): false | void => { |
Check failure
Code scanning / CodeQL
Assignment to constant Error
declared
test/unit/settings.test.ts
Outdated
|
||
test('displays warning and unchecks backup box if settings exceed local storage', async () => { | ||
expect.assertions(3); | ||
const spy = spyOn(chrome.storage.local, 'getBytesInUse').mockResolvedValue(6000000); // Mock value exceeding quota |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note test
* **src/settings.ts** - Add a new checkbox for "Backup settings to app storage" in the settings form - Update the `refs` interface to include the new checkbox - Add an `onchange` event handler to the new checkbox to update the backup setting in `chrome.storage.local` - Add a safety check to display a warning if settings exceed local storage and uncheck the box * **src/utils.ts** - Add a new property `backup` to the `storage` object to store the backup setting - Update the `handleClick` function to include logic for syncing settings when backup is enabled * **src/sw.ts** - Update the `onInstalled` listener to include the backup setting during installation or update * **test/unit/settings.test.ts** - Add tests to verify the backup toggle functionality in the settings page - Add tests to verify the safety check for exceeding local storage - Remove unused variable `spy`
✨✨ Here's an AI-assisted sketch of how you might approach this issue saved by @sheldonhull using Copilot Workspace v0.25 |
Closing in favor of #2208 Thank you for getting this started :) |
This is draft from copilot workspace as a starter for #2192
Add a setting option to toggle backup of settings to app storage.
Pending: testing disable of sync shouldn't remove the stored data, so you could retoggle it back on and it should restore based on whatever was last there.
This didn't work yet, but the initial sync seemed to be toggled without error.
Also this is local storage and pretty sure that's a nice backup for local but wouldn't sync remotely, so this is just a start.
For more details, open the Copilot Workspace session.