Yuki Takei 9 lat temu
rodzic
commit
736620b4bc

+ 38 - 0
packages/growi-plugin-lsx/src/resource/js/util/LsxCacheHelper.js

@@ -1,22 +1,60 @@
 export class LsxCacheHelper {
 export class LsxCacheHelper {
 
 
+  /**
+   * @private
+   */
   static retrieveFromSessionStorage() {
   static retrieveFromSessionStorage() {
     return JSON.parse(sessionStorage.getItem('lsx-cache')) || {};
     return JSON.parse(sessionStorage.getItem('lsx-cache')) || {};
   }
   }
 
 
+  /**
+   * stringify and save obj
+   *
+   * @static
+   * @param {any} cacheObj
+   *
+   * @memberOf LsxCacheHelper
+   */
   static saveToSessionStorage(cacheObj) {
   static saveToSessionStorage(cacheObj) {
     sessionStorage.setItem('lsx-cache', JSON.stringify(cacheObj));
     sessionStorage.setItem('lsx-cache', JSON.stringify(cacheObj));
   }
   }
 
 
+  /**
+   * generate cache key for storing to storage
+   *
+   * @static
+   * @param {any} lsxContext
+   * @returns
+   *
+   * @memberOf LsxCacheHelper
+   */
   static generateCacheKeyFromContext(lsxContext) {
   static generateCacheKeyFromContext(lsxContext) {
     return `${lsxContext.fromPagePath}__${lsxContext.lsxArgs}`;
     return `${lsxContext.fromPagePath}__${lsxContext.lsxArgs}`;
   }
   }
 
 
+  /**
+   *
+   *
+   * @static
+   * @param {any} key
+   * @returns
+   *
+   * @memberOf LsxCacheHelper
+   */
   static getStateCache(key) {
   static getStateCache(key) {
     let cacheObj = LsxCacheHelper.retrieveFromSessionStorage();
     let cacheObj = LsxCacheHelper.retrieveFromSessionStorage();
     return cacheObj[key];
     return cacheObj[key];
   }
   }
 
 
+  /**
+   * store state object of React Component with specified key
+   *
+   * @static
+   * @param {any} key
+   * @param {any} lsxState state object of React Component
+   *
+   * @memberOf LsxCacheHelper
+   */
   static cacheState(key, lsxState) {
   static cacheState(key, lsxState) {
     let cacheObj = LsxCacheHelper.retrieveFromSessionStorage();
     let cacheObj = LsxCacheHelper.retrieveFromSessionStorage();
     cacheObj[key] = lsxState;
     cacheObj[key] = lsxState;