added ntfy

This commit is contained in:
PxlLoewe
2025-05-19 23:11:33 -07:00
parent 61e7caf6c8
commit 060810f1b0
11 changed files with 277 additions and 76 deletions

View File

@@ -1,6 +1,6 @@
import { create } from "zustand";
import { dispatchSocket } from "../../dispatch/socket";
import { ConnectedAircraft, Mission, Station } from "@repo/db";
import { ConnectedAircraft, Mission, Station, User } from "@repo/db";
import { pilotSocket } from "pilot/socket";
import { useDmeStore } from "_store/pilot/dmeStore";
@@ -19,6 +19,7 @@ interface ConnectionStore {
stationId: string,
logoffTime: string,
station: Station,
user: User,
) => Promise<void>;
disconnect: () => void;
}
@@ -29,12 +30,18 @@ export const usePilotConnectionStore = create<ConnectionStore>((set) => ({
selectedStation: null,
connectedAircraft: null,
activeMission: null,
connect: async (uid, stationId, logoffTime, station) =>
connect: async (uid, stationId, logoffTime, station, user) =>
new Promise((resolve) => {
set({ status: "connecting", message: "", selectedStation: station });
pilotSocket.auth = { uid };
pilotSocket.connect();
pilotSocket.once("connect", () => {
useDmeStore.getState().setPage({
page: "home",
station,
user,
});
pilotSocket.emit("connect-pilot", {
logoffTime,
stationId,

View File

@@ -43,6 +43,8 @@ interface MrtStore {
setLines: (lines: MrtStore["lines"]) => void;
}
let interval: NodeJS.Timeout | null = null;
export const useDmeStore = create<MrtStore>(
syncTabs(
(set) => ({
@@ -52,42 +54,52 @@ export const useDmeStore = create<MrtStore>(
},
lines: [
{
textLeft: "VAR.#",
textLeft: "",
},
{
textMid: "VAR . DME# No Data",
textSize: "2",
},
{
textLeft: "No Data",
textLeft: "",
},
],
setLines: (lines) => set({ lines }),
setPage: (pageData) => {
if (interval) clearInterval(interval);
switch (pageData.page) {
case "home": {
set({
page: "home",
lines: [
{ textMid: "" },
{
textMid: pageData.station.bosCallsign
? `VAR#.${pageData.station.bosCallsign}`
: "no Data",
style: { fontWeight: "bold" },
},
{ textMid: "" },
{
textMid: new Date().toLocaleDateString(),
},
{
textMid: new Date().toLocaleTimeString(),
style: { fontWeight: "bold" },
},
{ textMid: "" },
{
textMid: `${pageData.user.lastname} ${pageData.user.firstname}`,
},
{ textMid: "" },
],
});
const setHomePage = () =>
set({
page: "home",
lines: [
{ textMid: "" },
{
textMid: pageData.station.bosCallsign
? `VAR#.${pageData.station.bosCallsign}`
: "no Data",
style: { fontWeight: "bold" },
},
{ textMid: "" },
{
textMid: new Date().toLocaleDateString(),
},
{
textMid: new Date().toLocaleTimeString(),
style: { fontWeight: "bold" },
},
{ textMid: "" },
{
textMid: `${pageData.user.lastname} ${pageData.user.firstname}`,
},
{ textMid: "" },
],
});
setHomePage();
interval = setInterval(() => {
setHomePage();
}, 1000);
break;
}