diff --git a/source/settings/migrations.ts b/source/settings/migrations.ts index 9b55902..c47b6bc 100644 --- a/source/settings/migrations.ts +++ b/source/settings/migrations.ts @@ -37,7 +37,8 @@ export function serializeQueue(queue: Queue.Item[]): Record { for (const item of queue) { const key = `qi${item.id}`; - serialized[key] = item; + serialized[key] = {...item}; + serialized[key].added = item.added.toISOString(); } return serialized; diff --git a/source/settings/settings.ts b/source/settings/settings.ts index dd3f983..2f208cf 100644 --- a/source/settings/settings.ts +++ b/source/settings/settings.ts @@ -47,9 +47,14 @@ export class Settings { }; this.queue.push(item); - const sync: Record = {}; - sync[`qi${id}`] = item; - await browser.storage.sync.set(sync); + await browser.storage.sync.set({ + [`qi${id}`]: { + added: item.added.toISOString(), + id, + text, + url, + }, + }); } public newQueueItemId(): number { diff --git a/tests/snapshots/tests/migrations.test.ts.md b/tests/snapshots/tests/migrations.test.ts.md index 861c8f0..69c9ee7 100644 --- a/tests/snapshots/tests/migrations.test.ts.md +++ b/tests/snapshots/tests/migrations.test.ts.md @@ -32,7 +32,7 @@ Generated by [AVA](https://avajs.dev). { qi1: { - added: Date 2022-03-02 16:00:00 UTC {}, + added: '2022-03-02T16:00:00.000Z', id: 1, text: 'Sample', url: 'https://example.org', diff --git a/tests/snapshots/tests/migrations.test.ts.snap b/tests/snapshots/tests/migrations.test.ts.snap index 2131bf4..a673a36 100644 Binary files a/tests/snapshots/tests/migrations.test.ts.snap and b/tests/snapshots/tests/migrations.test.ts.snap differ