Browse Source

Merge pull request #740 from weseek/imprv/reduce-the-call-of-localstorage

bollow the codes from https://github.com/crowi/crowi/pull/394/files
Yuki Takei 7 năm trước cách đây
mục cha
commit
233345c865
1 tập tin đã thay đổi với 3 bổ sung2 xóa
  1. 3 2
      src/client/js/util/Crowi.js

+ 3 - 2
src/client/js/util/Crowi.js

@@ -101,9 +101,10 @@ export default class Crowi {
     ];
 
     keys.forEach(key => {
-      if (this.localStorage[key]) {
+      const keyContent = this.localStorage[key];
+      if (keyContent) {
         try {
-          this[key] = JSON.parse(this.localStorage[key]);
+          this[key] = JSON.parse(keyContent);
         }
         catch (e) {
           this.localStorage.removeItem(key);