fix(vwb): bibliothèque ne s'écrase plus au chargement
Some checks failed
security-audit / Bandit (scan statique) (push) Successful in 13s
security-audit / pip-audit (CVE dépendances) (push) Successful in 11s
security-audit / Scan secrets (grep) (push) Successful in 9s
tests / Lint (ruff + black) (push) Successful in 16s
tests / Tests unitaires (sans GPU) (push) Failing after 16s
tests / Tests sécurité (critique) (push) Has been skipped
Some checks failed
security-audit / Bandit (scan statique) (push) Successful in 13s
security-audit / pip-audit (CVE dépendances) (push) Successful in 11s
security-audit / Scan secrets (grep) (push) Successful in 9s
tests / Lint (ruff + black) (push) Successful in 16s
tests / Tests unitaires (sans GPU) (push) Failing after 16s
tests / Tests sécurité (critique) (push) Has been skipped
Le useEffect(saveLibrary) se déclenchait avec library=[] avant que loadLibraryAsync ait fini → écrasait le fichier serveur avec un tableau vide. Ajout d'un flag libraryLoaded pour ne sauvegarder qu'après le chargement initial. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -64,6 +64,7 @@ export default function CapturePanel({
|
||||
const [previewScale, setPreviewScale] = useState({ x: 1, y: 1 });
|
||||
|
||||
const isDebugMode = executionMode === 'debug';
|
||||
const [libraryLoaded, setLibraryLoaded] = useState(false);
|
||||
|
||||
// Charger la bibliotheque depuis le backend (prioritaire), fallback localStorage.
|
||||
useEffect(() => {
|
||||
@@ -77,13 +78,16 @@ export default function CapturePanel({
|
||||
: item.timestamp,
|
||||
}))
|
||||
);
|
||||
setLibraryLoaded(true);
|
||||
});
|
||||
}, []);
|
||||
|
||||
// Sauvegarder la bibliotheque (localStorage + backend)
|
||||
// Sauvegarder la bibliotheque SEULEMENT après le chargement initial
|
||||
useEffect(() => {
|
||||
saveLibrary(library);
|
||||
}, [library]);
|
||||
if (libraryLoaded) {
|
||||
saveLibrary(library);
|
||||
}
|
||||
}, [library, libraryLoaded]);
|
||||
|
||||
// Ajouter capture a la bibliotheque (thumbnail compresse JPEG 320x240)
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user