From ee77f38cdb324cbcf12518490df77fc9e6b89282 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 6 Nov 2025 22:52:02 +0000 Subject: Improve gallery scroll indicators and format code Co-authored-by: arielcostas <94913521+arielcostas@users.noreply.github.com> --- src/frontend/app/data/StopDataProvider.ts | 37 ++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 8 deletions(-) (limited to 'src/frontend/app/data/StopDataProvider.ts') diff --git a/src/frontend/app/data/StopDataProvider.ts b/src/frontend/app/data/StopDataProvider.ts index 799dcb5..7725e15 100644 --- a/src/frontend/app/data/StopDataProvider.ts +++ b/src/frontend/app/data/StopDataProvider.ts @@ -47,7 +47,10 @@ async function initStops(region: RegionId) { // load custom names const rawCustom = localStorage.getItem(`customStopNames_${region}`); if (rawCustom) { - customNamesByRegion[region] = JSON.parse(rawCustom) as Record; + customNamesByRegion[region] = JSON.parse(rawCustom) as Record< + number, + string + >; } else { customNamesByRegion[region] = {}; } @@ -66,7 +69,10 @@ async function getStops(region: RegionId): Promise { } // New: get single stop by id -async function getStopById(region: RegionId, stopId: number): Promise { +async function getStopById( + region: RegionId, + stopId: number, +): Promise { await initStops(region); const stop = stopsMapByRegion[region]?.[stopId]; if (stop) { @@ -91,13 +97,19 @@ function setCustomName(region: RegionId, stopId: number, label: string) { customNamesByRegion[region] = {}; } customNamesByRegion[region][stopId] = label; - localStorage.setItem(`customStopNames_${region}`, JSON.stringify(customNamesByRegion[region])); + localStorage.setItem( + `customStopNames_${region}`, + JSON.stringify(customNamesByRegion[region]), + ); } function removeCustomName(region: RegionId, stopId: number) { if (customNamesByRegion[region]) { delete customNamesByRegion[region][stopId]; - localStorage.setItem(`customStopNames_${region}`, JSON.stringify(customNamesByRegion[region])); + localStorage.setItem( + `customStopNames_${region}`, + JSON.stringify(customNamesByRegion[region]), + ); } } @@ -115,7 +127,10 @@ function addFavourite(region: RegionId, stopId: number) { if (!favouriteStops.includes(stopId)) { favouriteStops.push(stopId); - localStorage.setItem(`favouriteStops_${region}`, JSON.stringify(favouriteStops)); + localStorage.setItem( + `favouriteStops_${region}`, + JSON.stringify(favouriteStops), + ); } } @@ -127,7 +142,10 @@ function removeFavourite(region: RegionId, stopId: number) { } const newFavouriteStops = favouriteStops.filter((id) => id !== stopId); - localStorage.setItem(`favouriteStops_${region}`, JSON.stringify(newFavouriteStops)); + localStorage.setItem( + `favouriteStops_${region}`, + JSON.stringify(newFavouriteStops), + ); } function isFavourite(region: RegionId, stopId: number): boolean { @@ -155,7 +173,10 @@ function pushRecent(region: RegionId, stopId: number) { recentStops.delete(val); } - localStorage.setItem(`recentStops_${region}`, JSON.stringify(Array.from(recentStops))); + localStorage.setItem( + `recentStops_${region}`, + JSON.stringify(Array.from(recentStops)), + ); } function getRecent(region: RegionId): number[] { @@ -179,7 +200,7 @@ async function loadStopsFromNetwork(region: RegionId): Promise { const regionConfig = getRegionConfig(region); const response = await fetch(regionConfig.stopsEndpoint); const stops = (await response.json()) as Stop[]; - return stops.map((stop) => ({ ...stop, favourite: false } as Stop)); + return stops.map((stop) => ({ ...stop, favourite: false }) as Stop); } export default { -- cgit v1.3