diff options
| author | copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> | 2025-11-06 22:52:02 +0000 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2025-11-07 10:47:20 +0100 |
| commit | ee77f38cdb324cbcf12518490df77fc9e6b89282 (patch) | |
| tree | 407f64a434291e1e375e6a1ccb55f59fa886a1ef /src/frontend/app/data/StopDataProvider.ts | |
| parent | e51cdd89afc08274ca622e18b8127feca29e90a3 (diff) | |
Improve gallery scroll indicators and format code
Co-authored-by: arielcostas <94913521+arielcostas@users.noreply.github.com>
Diffstat (limited to 'src/frontend/app/data/StopDataProvider.ts')
| -rw-r--r-- | src/frontend/app/data/StopDataProvider.ts | 37 |
1 files changed, 29 insertions, 8 deletions
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<number, string>; + customNamesByRegion[region] = JSON.parse(rawCustom) as Record< + number, + string + >; } else { customNamesByRegion[region] = {}; } @@ -66,7 +69,10 @@ async function getStops(region: RegionId): Promise<Stop[]> { } // New: get single stop by id -async function getStopById(region: RegionId, stopId: number): Promise<Stop | undefined> { +async function getStopById( + region: RegionId, + stopId: number, +): Promise<Stop | undefined> { 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<Stop[]> { 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 { |
