mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Keep errors, elements and comments consistent (#2340)
Co-authored-by: David Luzar <luzar.david@gmail.com>
This commit is contained in:
parent
2a20c44338
commit
5d295415db
22 changed files with 96 additions and 98 deletions
|
@ -108,7 +108,8 @@ export const loadFromBlob = async (
|
|||
},
|
||||
localAppState,
|
||||
);
|
||||
} catch {
|
||||
} catch (error) {
|
||||
console.error(error.message);
|
||||
throw new Error(t("alerts.couldNotLoadInvalidFile"));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -86,7 +86,7 @@ export const isSavedToFirebase = (
|
|||
return firebaseSceneVersionCache.get(portal.socket) === sceneVersion;
|
||||
}
|
||||
// if no room exists, consider the room saved so that we don't unnecessarily
|
||||
// prevent unload (there's nothing we could do at that point anyway)
|
||||
// prevent unload (there's nothing we could do at that point anyway)
|
||||
return true;
|
||||
};
|
||||
|
||||
|
@ -97,7 +97,7 @@ export async function saveToFirebase(
|
|||
const { roomID, roomKey, socket } = portal;
|
||||
if (
|
||||
// if no room exists, consider the room saved because there's nothing we can
|
||||
// do at this point
|
||||
// do at this point
|
||||
!roomID ||
|
||||
!roomKey ||
|
||||
!socket ||
|
||||
|
|
|
@ -31,7 +31,7 @@ export class Library {
|
|||
}
|
||||
|
||||
// detect z-index difference by checking the excalidraw elements
|
||||
// are in order
|
||||
// are in order
|
||||
return libraryItem.every((libItemExcalidrawItem, idx) => {
|
||||
return (
|
||||
libItemExcalidrawItem.id === targetLibraryItem[idx].id &&
|
||||
|
@ -69,8 +69,8 @@ export class Library {
|
|||
Library.libraryCache = JSON.parse(JSON.stringify(items));
|
||||
|
||||
resolve(items);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
resolve([]);
|
||||
}
|
||||
});
|
||||
|
@ -81,12 +81,12 @@ export class Library {
|
|||
try {
|
||||
const serializedItems = JSON.stringify(items);
|
||||
// cache optimistically so that consumers have access to the latest
|
||||
// immediately
|
||||
// immediately
|
||||
Library.libraryCache = JSON.parse(serializedItems);
|
||||
localStorage.setItem(STORAGE_KEYS.LOCAL_STORAGE_LIBRARY, serializedItems);
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
Library.libraryCache = prevLibraryItems;
|
||||
console.error(e);
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ const restoreElementWithProperties = <T extends ExcalidrawElement>(
|
|||
const base: Pick<T, keyof ExcalidrawElement> = {
|
||||
type: element.type,
|
||||
// all elements must have version > 0 so getSceneVersion() will pick up
|
||||
// newly added elements
|
||||
// newly added elements
|
||||
version: element.version || 1,
|
||||
versionNonce: element.versionNonce ?? 0,
|
||||
isDeleted: element.isDeleted ?? false,
|
||||
|
@ -112,9 +112,9 @@ const restoreElement = (
|
|||
case "diamond":
|
||||
return restoreElementWithProperties(element, {});
|
||||
|
||||
// don't use default case so as to catch a missing an element type case
|
||||
// (we also don't want to throw, but instead return void so we
|
||||
// filter out these unsupported elements from the restored array)
|
||||
// Don't use default case so as to catch a missing an element type case.
|
||||
// We also don't want to throw, but instead return void so we filter
|
||||
// out these unsupported elements from the restored array.
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -123,7 +123,7 @@ export const restoreElements = (
|
|||
): ExcalidrawElement[] => {
|
||||
return (elements || []).reduce((elements, element) => {
|
||||
// filtering out selection, which is legacy, no longer kept in elements,
|
||||
// and causing issues if retained
|
||||
// and causing issues if retained
|
||||
if (element.type !== "selection" && !isInvisiblySmallElement(element)) {
|
||||
const migratedElement = restoreElement(element);
|
||||
if (migratedElement) {
|
||||
|
@ -161,7 +161,7 @@ const restoreAppState = (
|
|||
...nextAppState,
|
||||
offsetLeft: appState.offsetLeft || 0,
|
||||
offsetTop: appState.offsetTop || 0,
|
||||
/* Migrates from previous version where appState.zoom was a number */
|
||||
// Migrates from previous version where appState.zoom was a number
|
||||
zoom:
|
||||
typeof appState.zoom === "number"
|
||||
? {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue