aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/RenderUtil.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/RenderUtil.ts')
-rw-r--r--src/lib/RenderUtil.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/lib/RenderUtil.ts b/src/lib/RenderUtil.ts
index c6963bc..bf360ab 100644
--- a/src/lib/RenderUtil.ts
+++ b/src/lib/RenderUtil.ts
@@ -83,3 +83,34 @@ export const stopTimeShouldRenderGlyph = (
(stopTime.mode === 'METRO' && stopTime.routeShortName.startsWith('S'))) &&
!stopTime.routeShortName.startsWith('FlixTrain');
export const blacklistedAgencyURLs = ['http://www.rta.ae'];
+
+export const getNotices = (
+ stopTime: StopTime,
+ delayMinutes: number,
+ isArrivals: boolean
+) => {
+ let notices = [] as [pictogram: string[], content: string][];
+ if (stopTime.cancelled)
+ notices.push([['Cancellation', 'Attention'], m.connection_cancelled()]);
+ if (delayMinutes < -0.5) {
+ notices.push([
+ ['Hint'],
+ m.connection_early({
+ minutes: -delayMinutes,
+ arrival: isArrivals.toString(),
+ }),
+ ]);
+ } else if (delayMinutes >= 1) {
+ notices.push([
+ delayMinutes >= 3
+ ? ['Delay', 'Attention']
+ : delayMinutes >= 2
+ ? ['Delay', 'Hint']
+ : ['Hint'],
+ m.connection_delayed({
+ minutes: delayMinutes.toFixed(0),
+ }),
+ ]);
+ }
+ return notices;
+};