Przeglądaj źródła

define StateCache type

Yuki Takei 3 lat temu
rodzic
commit
1513ed5c80
1 zmienionych plików z 8 dodań i 3 usunięć
  1. 8 3
      packages/plugin-lsx/src/components/Lsx.tsx

+ 8 - 3
packages/plugin-lsx/src/components/Lsx.tsx

@@ -90,6 +90,13 @@ type Props = {
   forceToFetchData?: boolean,
 };
 
+type StateCache = {
+  isError: boolean,
+  errorMessage: string,
+  basisViewersCount?: number,
+  nodeTree?: PageNode[],
+}
+
 export const Lsx = ({
   prefix,
   num, depth, sort, reverse, filter,
@@ -114,7 +121,7 @@ export const Lsx = ({
 
   const retrieveDataFromCache = useCallback(() => {
     // get state object cache
-    const stateCache = tagCacheManager.getStateCache(lsxContext);
+    const stateCache = tagCacheManager.getStateCache(lsxContext) as StateCache | null;
 
     // instanciate PageNode
     if (stateCache != null && stateCache.nodeTree != null) {
@@ -188,7 +195,6 @@ export const Lsx = ({
       tagCacheManager.cacheState(lsxContext, {
         isError: false,
         errorMessage: '',
-        isCacheExists,
         basisViewersCount,
         nodeTree: newNodeTree,
       });
@@ -201,7 +207,6 @@ export const Lsx = ({
       tagCacheManager.cacheState(lsxContext, {
         isError: true,
         errorMessage: error.message,
-        isCacheExists,
       });
     }
     finally {