Feature: ORS-Wochenlimit (20/Woche), Tages-Cache, Privilegien-Bypass, Datenschutz-Update — SW by-v480, APP_VER 457

This commit is contained in:
rene 2026-04-29 08:23:55 +02:00
parent ca8bb495b0
commit 7048499624
8 changed files with 121 additions and 14 deletions

View file

@ -375,12 +375,34 @@ window.Page_welcome = (() => {
const km = [2, 4, 6][dayIdx % 3];
const seed = dayIdx % 5;
// Tages-Cache prüfen — ORS nur einmal pro Tag anfragen
const today = new Date().toISOString().slice(0, 10); // 'YYYY-MM-DD'
const cacheKey = 'by_daily_route_' + today;
const cached = localStorage.getItem(cacheKey);
if (cached) {
try {
const result = JSON.parse(cached);
_applyRouteChip(result, km, seed);
return;
} catch {}
}
let result;
try {
result = await API.post('/routes/suggest', { lat: loc.lat, lon: loc.lon, distance_km: km, seed });
} catch { return; }
if (!result?.gps_track?.length) return;
// Ergebnis cachen und alte Einträge aufräumen
localStorage.setItem(cacheKey, JSON.stringify(result));
Object.keys(localStorage)
.filter(k => k.startsWith('by_daily_route_') && k !== cacheKey)
.forEach(k => localStorage.removeItem(k));
_applyRouteChip(result, km, seed);
}
function _applyRouteChip(result, km, seed) {
const chipsRow = _container.querySelector('#wc-chips-row');
if (!chipsRow) return;