mirror of
https://github.com/jcreek/LivingDexTracker.git
synced 2026-11-10 11:55:56 +00:00
fix: repair defects surfaced by gating CI on lint and typecheck
`npm run check` reported 15 errors and `npm run lint` 20, all pre-existing, so
neither gate could pass. Fixing them turned up three real bugs:
- SignOut destructured `{ error }` off `.then(() => {})`, which resolves to
undefined, so every sign-out threw a TypeError - after the signed-out event had
already been emitted. Sign-out also left the user on the protected page they
were on, still showing its content; it now returns them to the home page and
re-runs the server loads.
- SignUp passed `redirectTo`, which is not a signUp option and was silently
ignored, so the confirmation link has always used Supabase's configured site
URL. Documented rather than changed, since pointing it elsewhere needs an
absolute allow-listed URL.
- The Pokédex page tracked totalRecordsCreated but never passed it to the box
view, so the "Processed N entries so far" progress message never rendered.
The rest is typing and dead code: cookie callback parameters in hooks.server.ts
and +layout.ts, the untyped supabase props, a query-builder type that made
PostgREST rows untyped downstream, an unused session destructure, and
`while (true)` paging loops rewritten as `for (;;)`.
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
import type { Pokedex } from '$lib/models/Pokedex';
|
||||
import type { PageData } from './$types';
|
||||
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
// Get pokédex from server load (guarded for transient undefined during navigation/HMR)
|
||||
@@ -38,7 +37,10 @@
|
||||
// Box view requires the full dataset for correct box numbering/placement.
|
||||
// If/when a paginated list view is introduced, this can be lowered and paired with UI controls.
|
||||
let itemsPerPage = 9999 as number;
|
||||
let totalPages = 0 as number;
|
||||
type CatchUpdateEvent = CustomEvent<{
|
||||
catchRecord: CatchRecord;
|
||||
source: 'toggle' | 'notes' | 'notes-blur';
|
||||
}>;
|
||||
let creatingRecords = false;
|
||||
let totalRecordsCreated = 0;
|
||||
let failedToLoad = false;
|
||||
@@ -128,7 +130,6 @@
|
||||
}, 250);
|
||||
}
|
||||
|
||||
|
||||
// Derive from pokedex config
|
||||
$: showOrigins = !!pokedex?.isOriginDex;
|
||||
$: showShiny = !!pokedex?.isShinyDex;
|
||||
@@ -190,8 +191,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function applyOptimisticCatchRecordUpdate(next: CatchRecord) {
|
||||
if (!combinedData) return;
|
||||
const idx = combinedData.findIndex((cd) => cd.pokedexEntry._id === next.pokemonId);
|
||||
@@ -212,7 +211,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function handleModalCatchUpdate(event: any) {
|
||||
async function handleModalCatchUpdate(event: CatchUpdateEvent) {
|
||||
await updateACatch(event);
|
||||
}
|
||||
|
||||
@@ -243,20 +242,16 @@
|
||||
return;
|
||||
}
|
||||
combinedData = fetchedData.combinedData;
|
||||
totalPages = fetchedData.totalPages || 0;
|
||||
// Always extract box numbers for box view
|
||||
if (combinedData) {
|
||||
boxNumbers = calculateBoxNumbers(combinedData.length);
|
||||
}
|
||||
}
|
||||
|
||||
async function updateACatch(event: any) {
|
||||
async function updateACatch(event: CatchUpdateEvent) {
|
||||
if (!pokedexId) return;
|
||||
ensureCatchWriteQueue();
|
||||
const { catchRecord, source } = event.detail as {
|
||||
catchRecord: CatchRecord;
|
||||
source: 'toggle' | 'notes' | 'notes-blur';
|
||||
};
|
||||
const { catchRecord, source } = event.detail;
|
||||
// Enforce mutual exclusivity (should be impossible to have both true).
|
||||
const sanitizedCatchRecord: CatchRecord = { ...catchRecord };
|
||||
if (sanitizedCatchRecord.caught) {
|
||||
@@ -464,7 +459,6 @@
|
||||
window.clearInterval(reconcileInterval);
|
||||
};
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@@ -599,7 +593,6 @@
|
||||
{#if pokedex.description}
|
||||
<p class="text-sm text-base-content/70 mt-3">{pokedex.description}</p>
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Right side: Actions -->
|
||||
@@ -637,6 +630,7 @@
|
||||
bind:combinedData
|
||||
bind:boxNumbers
|
||||
bind:creatingRecords
|
||||
{totalRecordsCreated}
|
||||
bind:failedToLoad
|
||||
{markBoxAsNotCaught}
|
||||
{markBoxAsCaught}
|
||||
|
||||
Reference in New Issue
Block a user