Protect toolbox data after IndexedDB startup failures
All checks were successful
Deploy Sokko G / deploy (push) Successful in 18s

This commit is contained in:
Shinuwa 2026-09-12 23:05:16 +02:00
parent b53c7c17c8
commit 09a2d4b71a
13 changed files with 242 additions and 5 deletions

View file

@ -0,0 +1,20 @@
// Rôle : expose les commandes du vrai stockage et des actions sous StrictMode pour tester leur verrouillage initial.
import { createElement, StrictMode, useLayoutEffect } from "react";
import { createRoot } from "react-dom/client";
import { flushSync } from "react-dom";
import { useIndexedToolboxes } from "../../website/src/features/toolboxes/storage/useIndexedToolboxes.js";
import { useToolboxActions } from "../../website/src/features/toolboxes/useToolboxActions.js";
export function mountStorageStartupProbe(element) {
const root = createRoot(element);
const api = { store: null, actions: null, notices: [] };
const notify = (message) => api.notices.push(message);
function Probe() {
const store = useIndexedToolboxes(notify);
const actions = useToolboxActions({ store, notify, setConfirmModal: notify });
useLayoutEffect(() => { api.store = store; api.actions = actions; });
return null;
}
flushSync(() => root.render(createElement(StrictMode, null, createElement(Probe))));
return { ...api, get store() { return api.store; }, get actions() { return api.actions; }, unmount: () => root.unmount() };
}