Compare commits

...

2 Commits

Author SHA1 Message Date
Rainer Killinger
07e5c80223 docs: update changelogs for release
ci: publish release
2024-11-05 11:40:19 +01:00
Jovan Krunić
2ac840d845 fix: observable immediately returns false if scheduled beyond max delay
Closes #229
2024-11-04 18:04:48 +01:00
5 changed files with 15 additions and 8 deletions

View File

@@ -1,5 +0,0 @@
---
"@openstapps/app": minor
---
Use user facing changelogs in the about pages as the primary source, with the technical changes accessible through a sub menu.

View File

@@ -1,5 +1,11 @@
# @openstapps/app
## 3.3.4
### Minor Changes
- 8b581ef9: Use user facing changelogs in the about pages as the primary source, with the technical changes accessible through a sub menu.
## 3.3.3
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "@openstapps/app",
"description": "The generic app tailored to fulfill needs of German universities, written using Ionic Framework.",
"version": "3.3.3",
"version": "3.3.4",
"private": true,
"license": "GPL-3.0-only",
"author": "Karl-Philipp Wulfert <krlwlfrt@gmail.com>",

View File

@@ -1,6 +1,6 @@
import {Pipe, PipeTransform} from '@angular/core';
import {SCRange, isInRange, SCISO8601DateRange} from '@openstapps/core';
import {NormalizedInterval, differenceInMilliseconds, interval, isEqual} from 'date-fns';
import {NormalizedInterval, differenceInMilliseconds, interval} from 'date-fns';
import {EMPTY, Observable, SchedulerLike, asyncScheduler, concat, defer, map, of, timer} from 'rxjs';
@Pipe({
@@ -16,6 +16,8 @@ export class InRangePipe implements PipeTransform {
export const MIN_DATE = new Date(0);
export const MAX_DATE = new Date(1e15);
// Maximum safe delay for JavaScript timers (~24.8 days)
export const MAX_DELAY = 2 ** 31 - 1;
@Pipe({
name: 'rangeToDateInterval',
@@ -43,7 +45,7 @@ export function isWithinIntervalObservable(
return concat(
of(activate <= 0 && deactivate > 0),
activate <= 0 ? EMPTY : timer(value.start, scheduler).pipe(map(() => true)),
isEqual(value.end, MAX_DATE) || deactivate <= 0
differenceInMilliseconds(value.end, now) >= MAX_DELAY || deactivate <= 0
? EMPTY
: timer(value.end, scheduler).pipe(map(() => false)),
);

View File

@@ -1,6 +1,7 @@
import {TestScheduler} from 'rxjs/testing';
import {MAX_DATE, MIN_DATE, isWithinIntervalObservable} from './in-range.pipe';
import {interval} from 'date-fns';
import {MAX_DELAY} from './in-range.pipe';
/**
* Test macro
@@ -39,4 +40,7 @@ describe('isWithinIntervalObservable', () => {
test([500, 1000], '499ms ^', '499ms f t 499ms (f|)');
test([500, 1000], '^ 750ms !', 'f 499ms t');
// Long interval test case: emit `true` and then complete (EMPTY) because `end` is beyond the delay limit
test([500, 500 + MAX_DELAY + 2000], '1s ^', '1s (t|)');
});