fix: Race conditions when adding many library items (#10013)

* Fix for race condition when adding many library items

* Remove unused import

* Replace any with LibraryItem type

* Fix comments on pr

* Fix build errors

* Fix hoisted variable

* new mime type

* duplicate before passing down to be sure

* lint

* fix tests

* Remove unused import

---------

Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
ericvannunen
2025-09-23 23:47:03 +02:00
committed by GitHub
parent f55ecb96cc
commit 06c5ea94d3
6 changed files with 147 additions and 75 deletions
+1
View File
@@ -192,6 +192,7 @@ const createLibraryUpdate = (
class Library {
/** latest libraryItems */
private currLibraryItems: LibraryItems = [];
/** snapshot of library items since last onLibraryChange call */
private prevLibraryItems = cloneLibraryItems(this.currLibraryItems);
+5
View File
@@ -6,6 +6,7 @@ import type { cleanAppStateForExport } from "../appState";
import type {
AppState,
BinaryFiles,
LibraryItem,
LibraryItems,
LibraryItems_anyVersion,
} from "../types";
@@ -59,3 +60,7 @@ export interface ImportedLibraryData extends Partial<ExportedLibraryData> {
/** @deprecated v1 */
library?: LibraryItems;
}
export type ExcalidrawLibraryIds = {
itemIds: LibraryItem["id"][];
};