Merge branch 'develop' into feature/rowy-706-table-upgrade

# Conflicts:
#	src/atoms/tableScope/table.ts
#	src/components/TableToolbar/LoadedRowsStatus.tsx
#	src/hooks/useFirestoreCollectionWithAtom.ts
This commit is contained in:
Sidney Alcantara
2022-11-22 17:37:04 +11:00
3 changed files with 10 additions and 5 deletions

View File

@@ -239,5 +239,8 @@ export type AuditChangeFunction = (
*/
export const auditChangeAtom = atom<AuditChangeFunction | undefined>(undefined);
/** Store total number of rows in firestore collection */
export const serverDocCountAtom = atom(0);
/**
* Store total number of rows in the table, respecting current filters.
* If `undefined`, the query hasnt loaded yet.
*/
export const serverDocCountAtom = atom<number | undefined>(undefined);

View File

@@ -69,8 +69,9 @@ function LoadedRowsStatus() {
<StatusText>
<SyncIcon style={{ transform: "rotate(45deg)" }} />
Loaded {!tableNextPage.available && "all "}
{tableRows.length} {tableNextPage.available && `of ${serverDocCount}`}{" "}
row{serverDocCount !== 1 && "s"}
{tableRows.length}
{serverDocCount !== undefined && ` of ${serverDocCount}`} row
{(serverDocCount ?? tableRows.length) !== 1 && "s"}
</StatusText>
</Tooltip>
);

View File

@@ -64,7 +64,7 @@ interface IUseFirestoreCollectionWithAtomOptions<T> {
/** Update this atom when were loading the next page, and if there is a next page available. Uses same scope as `dataScope`. */
nextPageAtom?: PrimitiveAtom<NextPageState>;
/** Set this atom's value to the number of docs in the collection on each new snapshot */
serverDocCountAtom?: PrimitiveAtom<number> | undefined;
serverDocCountAtom?: PrimitiveAtom<number | undefined>;
}
/**
@@ -235,6 +235,7 @@ export function useFirestoreCollectionWithAtom<T = TableRow>(
handleError,
nextPageAtom,
setNextPageAtom,
serverDocCountAtom,
setServerDocCountAtom,
]);