mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-04 20:42:52 +00:00
fix: safari crashes with long opening hours change times
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
import type {nominatim_object} from 'opening_hours';
|
||||
import {from, Observable, map, expand, of, delay} from 'rxjs';
|
||||
import {lazy} from './rxjs/lazy';
|
||||
import {isAfter, subHours} from 'date-fns';
|
||||
import {differenceInMilliseconds, isAfter, subHours} from 'date-fns';
|
||||
|
||||
export const OPENING_HOURS_REFERENCE = {
|
||||
address: {
|
||||
@@ -54,7 +54,13 @@ export function fromOpeningHours(openingHours: string, soonThresholdHours = 1):
|
||||
const changesSoon = nextChange ? isAfter(now, subHours(nextChange, soonThresholdHours)) : false;
|
||||
|
||||
const changeTime = nextChange && !changesSoon ? subHours(nextChange, soonThresholdHours) : nextChange;
|
||||
return changeTime ? of(it).pipe(delay(changeTime)) : of();
|
||||
if (!changeTime) return of();
|
||||
|
||||
// Safari has issues with this. The value comes out to about 24 days
|
||||
const maxSafeValue = 0x7f_ff_ff_ff;
|
||||
const timeDifference = differenceInMilliseconds(changeTime, Date.now());
|
||||
|
||||
return of(it).pipe(delay(timeDifference >= maxSafeValue ? maxSafeValue : changeTime));
|
||||
}),
|
||||
map(it => {
|
||||
const now = new Date();
|
||||
|
||||
Reference in New Issue
Block a user