mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-04-14 16:40:58 -04:00
fix: remove JSON.stringify when calculating storage as its not needed (#3373)
This commit is contained in:
parent
4ac1841d92
commit
1310256dcc
1 changed files with 4 additions and 4 deletions
|
@ -101,7 +101,7 @@ export const importFromLocalStorage = () => {
|
||||||
export const getElementsStorageSize = () => {
|
export const getElementsStorageSize = () => {
|
||||||
try {
|
try {
|
||||||
const elements = localStorage.getItem(STORAGE_KEYS.LOCAL_STORAGE_ELEMENTS);
|
const elements = localStorage.getItem(STORAGE_KEYS.LOCAL_STORAGE_ELEMENTS);
|
||||||
const elementsSize = elements ? JSON.stringify(elements).length : 0;
|
const elementsSize = elements?.length || 0;
|
||||||
return elementsSize;
|
return elementsSize;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
@ -117,9 +117,9 @@ export const getTotalStorageSize = () => {
|
||||||
APP_STORAGE_KEYS.LOCAL_STORAGE_LIBRARY,
|
APP_STORAGE_KEYS.LOCAL_STORAGE_LIBRARY,
|
||||||
);
|
);
|
||||||
|
|
||||||
const appStateSize = appState ? JSON.stringify(appState).length : 0;
|
const appStateSize = appState?.length || 0;
|
||||||
const collabSize = collab ? JSON.stringify(collab).length : 0;
|
const collabSize = collab?.length || 0;
|
||||||
const librarySize = library ? JSON.stringify(library).length : 0;
|
const librarySize = library?.length || 0;
|
||||||
|
|
||||||
return appStateSize + collabSize + librarySize + getElementsStorageSize();
|
return appStateSize + collabSize + librarySize + getElementsStorageSize();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue