mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 16:56:22 +02:00
refactor: simplify DocumentsTableShell and DocumentsSidebar components by removing unused column visibility state and optimizing document loading logic in useDocuments hook
This commit is contained in:
parent
b7ca656823
commit
889af57d3f
3 changed files with 248 additions and 227 deletions
|
|
@ -77,6 +77,7 @@ export function useDocuments(
|
|||
|
||||
const apiLoadedCountRef = useRef(0);
|
||||
const initialLoadDoneRef = useRef(false);
|
||||
const prevParamsRef = useRef<{ sortBy: string; sortOrder: string; typeFilterKey: string } | null>(null);
|
||||
// Snapshot of all doc IDs from Electric's first callback after initial load.
|
||||
// Anything appearing in subsequent callbacks NOT in this set is genuinely new.
|
||||
const electricBaselineIdsRef = useRef<Set<number> | null>(null);
|
||||
|
|
@ -156,8 +157,15 @@ export function useDocuments(
|
|||
|
||||
let cancelled = false;
|
||||
|
||||
const isRefresh = initialLoadDoneRef.current;
|
||||
if (!isRefresh) {
|
||||
const prev = prevParamsRef.current;
|
||||
const isSortOnlyChange =
|
||||
initialLoadDoneRef.current &&
|
||||
prev !== null &&
|
||||
prev.typeFilterKey === typeFilterKey &&
|
||||
(prev.sortBy !== sortBy || prev.sortOrder !== sortOrder);
|
||||
prevParamsRef.current = { sortBy, sortOrder, typeFilterKey };
|
||||
|
||||
if (!isSortOnlyChange) {
|
||||
setLoading(true);
|
||||
setDocuments([]);
|
||||
setTotal(0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue