Increase the maximum number of URLs queued.
The number of URLs queued is restricted to ~60 because the queue is stored as a single item and is therefore is restricted to 8k. Instead store each URLs as a separate item with a name 'qi'+number and gather them into a single array when loading/storing.
This commit is contained in:
parent
792bd26d4f
commit
a668da05a1
|
@ -24,9 +24,17 @@ const defaultSettings: Settings = {
|
||||||
* Returns the user's settings.
|
* Returns the user's settings.
|
||||||
*/
|
*/
|
||||||
export async function getSettings(): Promise<Settings> {
|
export async function getSettings(): Promise<Settings> {
|
||||||
const syncSettings: any = await browser.storage.sync.get(defaultSettings);
|
const syncSettings: any = await browser.storage.sync.get();
|
||||||
|
|
||||||
const queue: QItem[] = syncSettings.queue;
|
// Append properties with a name matching 'qi'x to queue.
|
||||||
|
const queue: QItem[] = [];
|
||||||
|
if (syncSettings !== undefined) {
|
||||||
|
for (const prop in syncSettings) {
|
||||||
|
if (prop.startsWith('qi')) {
|
||||||
|
queue.push(syncSettings[prop]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize all the non-JSON values, as they are stringified when saved.
|
// Initialize all the non-JSON values, as they are stringified when saved.
|
||||||
for (const item of queue) {
|
for (const item of queue) {
|
||||||
|
@ -34,9 +42,10 @@ export async function getSettings(): Promise<Settings> {
|
||||||
}
|
}
|
||||||
|
|
||||||
const settings: Settings = {
|
const settings: Settings = {
|
||||||
latestVersion: syncSettings.latestVersion,
|
latestVersion: syncSettings.latestVersion ?? defaultSettings.latestVersion,
|
||||||
queue,
|
queue,
|
||||||
versionGotUpdated: syncSettings.versionGotUpdated
|
versionGotUpdated:
|
||||||
|
syncSettings.versionGotUpdated ?? defaultSettings.versionGotUpdated
|
||||||
};
|
};
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
|
@ -47,7 +56,15 @@ export async function getSettings(): Promise<Settings> {
|
||||||
* @param settings The settings to save.
|
* @param settings The settings to save.
|
||||||
*/
|
*/
|
||||||
export async function saveSettings(settings: Settings): Promise<Settings> {
|
export async function saveSettings(settings: Settings): Promise<Settings> {
|
||||||
await browser.storage.sync.set(settings);
|
const syncSettings: any = {
|
||||||
|
latestVersion: settings.latestVersion,
|
||||||
|
versionGotUpdated: settings.versionGotUpdated
|
||||||
|
};
|
||||||
|
for (const item of settings.queue) {
|
||||||
|
syncSettings['qi' + item.id.toString()] = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
await browser.storage.sync.set(syncSettings);
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +101,8 @@ export async function removeQItem(
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.queue.splice(index, 1);
|
settings.queue.splice(index, 1);
|
||||||
return saveSettings(settings);
|
await browser.storage.sync.remove('qi' + id.toString());
|
||||||
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue