Browse Source

fix: wrong grid row count (#2973)

Daiki Nakashita 1 year ago
parent
commit
c12aa66b2a

+ 1 - 1
frontend/appflowy_tauri/src/appflowy_app/components/grid/Grid/Grid.tsx

@@ -40,7 +40,7 @@ export const Grid = ({ viewId }: { viewId: string }) => {
               <GridAddRow controller={controller} />
             </div>
 
-            <GridTableCount />
+            <GridTableCount rows={rows} />
           </div>
           {showGridRow && boardRowInfo && (
             <EditRow

+ 0 - 10
frontend/appflowy_tauri/src/appflowy_app/components/grid/GridTableCount/GridTableCount.hooks.ts

@@ -1,10 +0,0 @@
-import { useAppSelector } from '$app/stores/store';
-
-export const useGridTableCount = () => {
-  const { grid } = useAppSelector((state) => state);
-  const { rows } = grid;
-
-  return {
-    count: rows.length,
-  };
-};

+ 3 - 3
frontend/appflowy_tauri/src/appflowy_app/components/grid/GridTableCount/GridTableCount.tsx

@@ -1,7 +1,7 @@
-import { useGridTableCount } from './GridTableCount.hooks';
+import { RowInfo } from '@/appflowy_app/stores/effects/database/row/row_cache';
 
-export const GridTableCount = () => {
-  const { count } = useGridTableCount();
+export const GridTableCount = ({ rows }: { rows: readonly RowInfo[] }) => {
+  const count = rows.length;
   return (
     <span>
       Count : <span className='font-semibold'>{count}</span>