From 1310256dcc34195208a2022baa3106705e5e14e8 Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Thu, 1 Apr 2021 14:49:31 +0530 Subject: [PATCH] fix: remove JSON.stringify when calculating storage as its not needed (#3373) --- src/excalidraw-app/data/localStorage.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/excalidraw-app/data/localStorage.ts b/src/excalidraw-app/data/localStorage.ts index 2920b47bfc..f4e2b4363c 100644 --- a/src/excalidraw-app/data/localStorage.ts +++ b/src/excalidraw-app/data/localStorage.ts @@ -101,7 +101,7 @@ export const importFromLocalStorage = () => { export const getElementsStorageSize = () => { try { const elements = localStorage.getItem(STORAGE_KEYS.LOCAL_STORAGE_ELEMENTS); - const elementsSize = elements ? JSON.stringify(elements).length : 0; + const elementsSize = elements?.length || 0; return elementsSize; } catch (error) { console.error(error); @@ -117,9 +117,9 @@ export const getTotalStorageSize = () => { APP_STORAGE_KEYS.LOCAL_STORAGE_LIBRARY, ); - const appStateSize = appState ? JSON.stringify(appState).length : 0; - const collabSize = collab ? JSON.stringify(collab).length : 0; - const librarySize = library ? JSON.stringify(library).length : 0; + const appStateSize = appState?.length || 0; + const collabSize = collab?.length || 0; + const librarySize = library?.length || 0; return appStateSize + collabSize + librarySize + getElementsStorageSize(); } catch (error) {