Keep errors, elements and comments consistent (#2340)

Co-authored-by: David Luzar <luzar.david@gmail.com>
This commit is contained in:
Lipis 2020-11-05 19:06:18 +02:00 committed by GitHub
parent 2a20c44338
commit 5d295415db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 96 additions and 98 deletions

View file

@ -108,7 +108,8 @@ export const loadFromBlob = async (
},
localAppState,
);
} catch {
} catch (error) {
console.error(error.message);
throw new Error(t("alerts.couldNotLoadInvalidFile"));
}
};

View file

@ -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 ||

View file

@ -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);
}
};
}

View file

@ -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"
? {