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
@ -540,7 +540,7 @@ export const actionChangeSharpness = register({
|
||||
appState,
|
||||
);
|
||||
const shouldUpdateForNonLinearElements = targetElements.length
|
||||
? targetElements.every((e) => !isLinearElement(e))
|
||||
? targetElements.every((el) => !isLinearElement(el))
|
||||
: !isLinearElementType(appState.elementType);
|
||||
const shouldUpdateForLinearElements = targetElements.length
|
||||
? targetElements.every(isLinearElement)
|
||||
|
@ -57,9 +57,9 @@ export const copyToClipboard = async (
|
||||
try {
|
||||
PREFER_APP_CLIPBOARD = false;
|
||||
await copyTextToSystemClipboard(json);
|
||||
} catch (err) {
|
||||
} catch (error) {
|
||||
PREFER_APP_CLIPBOARD = true;
|
||||
console.error(err);
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -561,8 +561,8 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
||||
history.clear();
|
||||
};
|
||||
|
||||
/** Completely resets scene & history.
|
||||
* Do not use for clear scene user action. */
|
||||
// Completely resets scene & history.
|
||||
// Do not use for clear scene user action.
|
||||
private resetScene = withBatchedUpdates(() => {
|
||||
this.scene.replaceAllElements([]);
|
||||
this.setState({
|
||||
@ -1467,9 +1467,9 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
||||
if (elements) {
|
||||
this.handleRemoteSceneUpdate(elements, { initFromSnapshot: true });
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
// log the error and move on. other peers will sync us the scene.
|
||||
console.error(e);
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -167,8 +167,7 @@ class Portal {
|
||||
const newElements = sceneElements
|
||||
.reduce((elements, element) => {
|
||||
// if the remote element references one that's currently
|
||||
// edited on local, skip it (it'll be added in the next
|
||||
// step)
|
||||
// edited on local, skip it (it'll be added in the next step)
|
||||
if (
|
||||
element.id === this.app.state.editingElement?.id ||
|
||||
element.id === this.app.state.resizingElement?.id ||
|
||||
|
@ -108,7 +108,8 @@ export const loadFromBlob = async (
|
||||
},
|
||||
localAppState,
|
||||
);
|
||||
} catch {
|
||||
} catch (error) {
|
||||
console.error(error.message);
|
||||
throw new Error(t("alerts.couldNotLoadInvalidFile"));
|
||||
}
|
||||
};
|
||||
|
@ -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([]);
|
||||
}
|
||||
});
|
||||
@ -84,9 +84,9 @@ export class Library {
|
||||
// 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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -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.
|
||||
}
|
||||
};
|
||||
|
||||
@ -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"
|
||||
? {
|
||||
|
@ -75,10 +75,9 @@ const registerValidSW = (swUrl: string, config?: Config) => {
|
||||
// but the previous service worker will still serve the older
|
||||
// content until all client tabs are closed.
|
||||
|
||||
// console.log(
|
||||
// "New content is available and will be used when all " +
|
||||
// "tabs for this page are closed.",
|
||||
// );
|
||||
console.info(
|
||||
"New content is available and will be used when all tabs for this page are closed.",
|
||||
);
|
||||
|
||||
// Execute callback
|
||||
if (config && config.onUpdate) {
|
||||
@ -89,7 +88,7 @@ const registerValidSW = (swUrl: string, config?: Config) => {
|
||||
// It's the perfect time to display a
|
||||
// "Content is cached for offline use." message.
|
||||
|
||||
// console.log("Content is cached for offline use.");
|
||||
console.info("Content is cached for offline use.");
|
||||
|
||||
// Execute callback
|
||||
if (config && config.onSuccess) {
|
||||
@ -128,10 +127,11 @@ const checkValidServiceWorker = (swUrl: string, config?: Config) => {
|
||||
registerValidSW(swUrl, config);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
// console.log(
|
||||
// "No internet connection found. App is running in offline mode.",
|
||||
// );
|
||||
.catch((error) => {
|
||||
console.info(
|
||||
"No internet connection found. App is running in offline mode.",
|
||||
error.message,
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -1594,8 +1594,7 @@ it(
|
||||
mouse.up(100, 100);
|
||||
|
||||
// Select first rectangle while keeping third one selected.
|
||||
// Third rectangle is selected because it was the last element
|
||||
// to be created.
|
||||
// Third rectangle is selected because it was the last element to be created.
|
||||
mouse.reset();
|
||||
Keyboard.withModifierKeys({ shift: true }, () => {
|
||||
mouse.click();
|
||||
@ -1616,8 +1615,7 @@ it(
|
||||
});
|
||||
expect(API.getSelectedElements().length).toBe(3);
|
||||
|
||||
// pointer down o first rectangle that is
|
||||
// part of the group
|
||||
// Pointer down o first rectangle that is part of the group
|
||||
mouse.reset();
|
||||
Keyboard.withModifierKeys({ shift: true }, () => {
|
||||
mouse.down();
|
||||
|
Loading…
x
Reference in New Issue
Block a user