Improve local backup permissions and change tracking
All checks were successful
Deploy Sokko G / deploy (push) Successful in 19s
All checks were successful
Deploy Sokko G / deploy (push) Successful in 19s
This commit is contained in:
parent
34e542be28
commit
ee823d2c37
13 changed files with 372 additions and 37 deletions
|
|
@ -25,6 +25,7 @@ import { applyModuleDataValue, removeModuleDataKeys } from "./optimisticModuleDa
|
|||
import { createPersistenceQueue } from "./persistenceQueue.js";
|
||||
import { createQuotaRefresh } from "./quotaRefresh.js";
|
||||
import { DEFERRED_MODULE_DATA, getDeferredModuleKeys, mergeLoadedModuleData, splitModuleData } from "./deferredModuleData.js";
|
||||
import { AUTO_BACKUP_DATA_CHANGED_EVENT } from "./autoBackup.js";
|
||||
|
||||
function normalizeToolboxes(toolboxes) {
|
||||
return compactToolboxesForStorage(toolboxes).map(normalizeToolbox).filter(Boolean);
|
||||
|
|
@ -102,10 +103,16 @@ export function useIndexedToolboxes(onError) {
|
|||
setLoadAttempt((attempt) => attempt + 1);
|
||||
}
|
||||
|
||||
function enqueue(apply, persist) {
|
||||
function enqueue(apply, persist, { marksBackupDirty = true } = {}) {
|
||||
if (!writableRef.current) return Promise.resolve(false);
|
||||
const result = queue.enqueue(apply, persist, reportStorageError);
|
||||
void result.then((success) => { if (success) refreshQuota(); });
|
||||
void result.then((success) => {
|
||||
if (!success) return;
|
||||
refreshQuota();
|
||||
if (marksBackupDirty && typeof window !== "undefined") {
|
||||
window.dispatchEvent(new window.Event(AUTO_BACKUP_DATA_CHANGED_EVENT));
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -209,7 +216,8 @@ export function useIndexedToolboxes(onError) {
|
|||
const toastPosition = position === "left" ? "left" : "right";
|
||||
enqueue(
|
||||
(current) => ({ ...current, toastPosition }),
|
||||
() => dbSetSetting("toastPosition", toastPosition)
|
||||
() => dbSetSetting("toastPosition", toastPosition),
|
||||
{ marksBackupDirty: false }
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue