Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 24 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions src/types/flight.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
export interface FR24Flight {
flight?: {
time?: {
scheduled?: {
departure?: number;
arrival?: number;
};
};
identification?: {
number?: {
default?: string;
};
};
airline?: {
name?: string;
};
airport?: {
origin?: {
name?: string;
code?: {
iata?: string;
};
};
destination?: {
name?: string;
code?: {
iata?: string;
};
};
};
};
}

export interface PinnedFlightItem {
flightNumber: string;
ts: number;
}

export interface WearFlightPayload {
flightNumber: string;
dest: string;
time: string;
isCheckinOpen: boolean;
isGateOpen: boolean;
}
5 changes: 3 additions & 2 deletions src/utils/autoNotifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as Notifications from 'expo-notifications';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { getAirlineOps } from './airlineOps';
import { fetchAirportScheduleRaw } from './fr24api';
import { FR24Flight } from '../types/flight';

const NOTIF_IDS_KEY = 'aerostaff_notif_ids_v1';
const LAST_SCHEDULE_KEY = 'aerostaff_notif_last_schedule';
Expand Down Expand Up @@ -52,13 +53,13 @@ export async function autoScheduleNotifications(): Promise<number> {
const { departures: allDepartures, arrivals: allArrivals } = await fetchAirportScheduleRaw();

// Filter departures during shift
const shiftDepartures = allDepartures.filter((item: any) => {
const shiftDepartures = allDepartures.filter((item: FR24Flight) => {
const ts = item.flight?.time?.scheduled?.departure;
return ts && ts >= shiftStart && ts <= shiftEnd;
});

// Filter arrivals during shift (inbound aircraft that become our departures)
const shiftArrivals = allArrivals.filter((item: any) => {
const shiftArrivals = allArrivals.filter((item: FR24Flight) => {
const ts = item.flight?.time?.scheduled?.arrival;
return ts && ts >= shiftStart && ts <= shiftEnd;
});
Expand Down
Loading