From 268100f02667327366c4c333f5558b61784b63f6 Mon Sep 17 00:00:00 2001 From: Jose Browne Date: Wed, 20 Nov 2024 16:45:09 -0400 Subject: [PATCH] Bug Fix: Fix blank card issue on grade Refreshing the entire list on every grade caused card IDs to change a few times while the card was navigating to the next index of the prev list cause it to fall out of sync sometimes --- src/app.tsx | 2 -- src/components/overlay/PracticeOverlay.tsx | 2 +- src/hooks/useBlockInfo.tsx | 4 ++-- src/queries.ts | 2 ++ 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app.tsx b/src/app.tsx index 21fa057..dc99a30 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -65,8 +65,6 @@ const App = () => { intervalMultiplier, intervalMultiplierType, }); - - refreshData(); } catch (error) { console.error('Error Saving Practice Data', error); } diff --git a/src/components/overlay/PracticeOverlay.tsx b/src/components/overlay/PracticeOverlay.tsx index 3308046..b72f0a3 100644 --- a/src/components/overlay/PracticeOverlay.tsx +++ b/src/components/overlay/PracticeOverlay.tsx @@ -127,7 +127,7 @@ const PracticeOverlay = ({ const isDueToday = dateUtils.daysBetween(nextDueDate, new Date()) === 0; const status = isNew ? 'new' : isDueToday ? 'dueToday' : hasNextDueDate ? 'pastDue' : null; - const { data: blockInfo } = useBlockInfo({ refUid: currentCardRefUid }); + const { blockInfo } = useBlockInfo({ refUid: currentCardRefUid }); const hasBlockChildren = !!blockInfo.children && !!blockInfo.children.length; const [showAnswers, setShowAnswers] = React.useState(false); const [hasCloze, setHasCloze] = React.useState(true); diff --git a/src/hooks/useBlockInfo.tsx b/src/hooks/useBlockInfo.tsx index b554f93..e933e86 100644 --- a/src/hooks/useBlockInfo.tsx +++ b/src/hooks/useBlockInfo.tsx @@ -10,14 +10,14 @@ const useBlockInfo = ({ refUid }) => { const fetch = async () => { const blockInfo = await fetchBlockInfo(refUid); - setBlockInfo(blockInfo); + setBlockInfo({ ...blockInfo, refUid }); }; fetch(); }, [refUid]); return { - data: blockInfo, + blockInfo, }; }; diff --git a/src/queries.ts b/src/queries.ts index 9e057ec..9b4c4d3 100644 --- a/src/queries.ts +++ b/src/queries.ts @@ -658,6 +658,8 @@ export interface BlockInfo { string: string; children: any[]; breadcrumbs: Breadcrumbs[]; + + refUid: string; } export interface Breadcrumbs { [index: number]: { uid: string; title: string };