mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-19 15:31:04 +02:00
Prefer arrow functions and callbacks (#1210)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user