Prefer arrow functions and callbacks (#1210)

This commit is contained in:
Lipis
2020-05-20 16:21:37 +03:00
committed by GitHub
parent 33fe223b5d
commit c427aa3cce
64 changed files with 784 additions and 847 deletions

View File

@@ -7,7 +7,7 @@ const LOCAL_STORAGE_KEY = "excalidraw";
const LOCAL_STORAGE_KEY_STATE = "excalidraw-state";
const LOCAL_STORAGE_KEY_COLLAB = "excalidraw-collab";
export function saveUsernameToLocalStorage(username: string) {
export const saveUsernameToLocalStorage = (username: string) => {
try {
localStorage.setItem(
LOCAL_STORAGE_KEY_COLLAB,
@@ -17,9 +17,9 @@ export function saveUsernameToLocalStorage(username: string) {
// Unable to access window.localStorage
console.error(error);
}
}
};
export function restoreUsernameFromLocalStorage(): string | null {
export const restoreUsernameFromLocalStorage = (): string | null => {
try {
const data = localStorage.getItem(LOCAL_STORAGE_KEY_COLLAB);
if (data) {
@@ -31,12 +31,12 @@ export function restoreUsernameFromLocalStorage(): string | null {
}
return null;
}
};
export function saveToLocalStorage(
export const saveToLocalStorage = (
elements: readonly ExcalidrawElement[],
appState: AppState,
) {
) => {
try {
localStorage.setItem(
LOCAL_STORAGE_KEY,
@@ -50,9 +50,9 @@ export function saveToLocalStorage(
// Unable to access window.localStorage
console.error(error);
}
}
};
export function restoreFromLocalStorage() {
export const restoreFromLocalStorage = () => {
let savedElements = null;
let savedState = null;
@@ -86,4 +86,4 @@ export function restoreFromLocalStorage() {
}
return restore(elements, appState);
}
};