Skip to content

Commit 5de4644

Browse files
Fix cell celebration: accurate count from DB, trigger on fallback path
- Celebration now refreshes stats from Supabase before displaying count - Added celebration to CAVE-unavailable fallback path (was only on CAVE success) - Both Cell Library Complete and lightbulb menu now trigger celebration Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0ed7c27 commit 5de4644

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/components/CellLibraryPanel.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ import nurroCelebrate3 from '../../static/nurro/nurro-celebrate3.png';
283283
import nurroExperiment from '../../static/nurro/nurro-experiment.png';
284284
const NURRO_IMAGES = [nurroSuccess, nurroTrophy, nurroCelebrate, nurroDance, nurroAtHome, nurroConfetti, nurroCelebrate2, nurroPopcorn, nurroCelebrate3, nurroExperiment];
285285
286-
function triggerCellCelebration() {
286+
async function triggerCellCelebration() {
287+
await backend.loadUserStats(); // refresh from DB for accurate count
287288
const statsStore = useUserStatsStore();
288289
const total = statsStore.stats.cellsSubmitted;
289290
const nurro = NURRO_IMAGES[Math.floor(Math.random() * NURRO_IMAGES.length)];

src/widgets/lightbulb_service.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,10 @@ export async function setCellComplete(
276276
statsStore.setStats({ cellsSubmitted: statsStore.stats.cellsSubmitted + 1 });
277277
statsStore.logDailyCellComplete();
278278
} catch { /* non-critical */ }
279-
// Celebration!
279+
// Celebration! Read fresh count from Supabase for accuracy
280280
try {
281281
const backend = useProofreadingBackendStore();
282+
await backend.loadUserStats(); // refresh from DB
282283
const statsStore = useUserStatsStore();
283284
const total = statsStore.stats.cellsSubmitted;
284285
const nurro = NURRO_IMAGES[Math.floor(Math.random() * NURRO_IMAGES.length)];
@@ -334,6 +335,20 @@ export async function setCellComplete(
334335
);
335336
}
336337
} catch { /* non-critical */ }
338+
// Celebration on complete (fallback path — CAVE was unavailable)
339+
if (complete) {
340+
try {
341+
const backend = useProofreadingBackendStore();
342+
await backend.loadUserStats();
343+
const statsStore = useUserStatsStore();
344+
const total = statsStore.stats.cellsSubmitted;
345+
const nurro = NURRO_IMAGES[Math.floor(Math.random() * NURRO_IMAGES.length)];
346+
backend.pendingCellCelebration = {
347+
totalCells: total,
348+
imageUrl: nurro,
349+
};
350+
} catch { /* non-critical */ }
351+
}
337352
return true;
338353
}
339354

0 commit comments

Comments
 (0)