Fix dates not being serialized properly in Chromium.

This commit is contained in:
Bauke 2022-03-20 19:21:52 +01:00
parent 62f2188070
commit bf8712dbf6
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
4 changed files with 11 additions and 5 deletions

View File

@ -37,7 +37,8 @@ export function serializeQueue(queue: Queue.Item[]): Record<string, any> {
for (const item of queue) { for (const item of queue) {
const key = `qi${item.id}`; const key = `qi${item.id}`;
serialized[key] = item; serialized[key] = {...item};
serialized[key].added = item.added.toISOString();
} }
return serialized; return serialized;

View File

@ -47,9 +47,14 @@ export class Settings {
}; };
this.queue.push(item); this.queue.push(item);
const sync: Record<string, Queue.Item> = {}; await browser.storage.sync.set({
sync[`qi${id}`] = item; [`qi${id}`]: {
await browser.storage.sync.set(sync); added: item.added.toISOString(),
id,
text,
url,
},
});
} }
public newQueueItemId(): number { public newQueueItemId(): number {

View File

@ -32,7 +32,7 @@ Generated by [AVA](https://avajs.dev).
{ {
qi1: { qi1: {
added: Date 2022-03-02 16:00:00 UTC {}, added: '2022-03-02T16:00:00.000Z',
id: 1, id: 1,
text: 'Sample', text: 'Sample',
url: 'https://example.org', url: 'https://example.org',