RED-6174 - added default values for environment variables in case they are not available

This commit is contained in:
Valentin Mihai 2023-03-09 14:57:29 +02:00
parent 59b04033cf
commit 4bd636887c

View File

@ -13,6 +13,10 @@ import dayjs from 'dayjs';
const INCLUDE_SEEN = false;
const AVAILABLE_NOTIFICATIONS_DAYS = 30;
const AVAILABLE_OLD_NOTIFICATIONS_MINUTES = 60;
const NOTIFICATIONS_THRESHOLD = 1000;
@Injectable({
providedIn: 'root',
})
@ -81,14 +85,17 @@ export class NotificationsService extends EntitiesService<INotification, Notific
}
const creationDate = dayjs(n.creationDate);
if (todayDate.diff(creationDate, 'day') <= this.#config.AVAILABLE_NOTIFICATIONS_DAYS) {
if (todayDate.diff(creationDate, 'day') <= (this.#config.AVAILABLE_NOTIFICATIONS_DAYS ?? AVAILABLE_NOTIFICATIONS_DAYS)) {
return true;
}
return todayDate.diff(readDate, 'minute') <= this.#config.AVAILABLE_OLD_NOTIFICATIONS_MINUTES;
return (
todayDate.diff(readDate, 'minute') <=
(this.#config.AVAILABLE_OLD_NOTIFICATIONS_MINUTES ?? AVAILABLE_OLD_NOTIFICATIONS_MINUTES)
);
});
return notifications.slice(0, this.#config.NOTIFICATIONS_THRESHOLD);
return notifications.slice(0, this.#config.NOTIFICATIONS_THRESHOLD ?? NOTIFICATIONS_THRESHOLD);
}
#loadNotificationsIfChanged(): Observable<Notification[]> {