mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-14 00:01:03 +00:00
2c3b20bb57
PAD-03 portages and locks on planned tours and recorded tracks, PAD-07 paddle time with portage and lock stops, PAD-08 wind forecast for the start, PAD-05A regional obstacle import from Geofabrik extracts with admin endpoints and a monthly refresh, PAD-05B first cut of the obstacle layer on Leaflet, GL and 3D. Work in progress: checklist (PAD-06), check bench (PAD-09), admin UI, translations and tests follow.
24 lines
909 B
TypeScript
24 lines
909 B
TypeScript
import type { WindForecastResponse } from '@trek/shared';
|
|
import { windApi } from '../api/wind';
|
|
import { isEffectivelyOffline } from '../sync/networkMode';
|
|
|
|
/** Thrown instead of asking while the app is offline, so the view can say so rather than show a failure. */
|
|
export class WindOfflineError extends Error {
|
|
constructor() {
|
|
super('Wind forecast needs a connection');
|
|
this.name = 'WindOfflineError';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* PAD-08: the wind forecast, online only on purpose. A forecast kept on the
|
|
* device would be read later as the current one; it is asked again every time
|
|
* and never cached here, and offline nothing is asked at all.
|
|
*/
|
|
export const windRepo = {
|
|
async forecast(lat: number, lng: number, date: string, signal?: AbortSignal): Promise<WindForecastResponse> {
|
|
if (isEffectivelyOffline()) throw new WindOfflineError();
|
|
return windApi.forecast(lat, lng, date, signal);
|
|
},
|
|
};
|