Skip to content

Commit 1804635

Browse files
committed
Add navigator SSR guards
1 parent 6929b75 commit 1804635

10 files changed

Lines changed: 18 additions & 3 deletions

File tree

apps/web/app/(map)/components/Footer/Controls.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const SwitchVisibility = ({ checked, onCheckedChange }: { checked: boolean; onCh
7171
};
7272

7373
const onCenterOnLocation = () => {
74+
if (typeof window === "undefined") return;
7475
if (navigator.geolocation) {
7576
navigator.geolocation.getCurrentPosition(
7677
(pos) => {
@@ -127,7 +128,7 @@ const ButtonGroupControls = () => {
127128
></TooltipTrigger>
128129
<TooltipContent className="pr-1.5">
129130
<div className="flex items-center gap-2">
130-
Fullscreen <Kbd>{navigator.platform.startsWith("Mac") ? "⌃⌘F" : "F11"}</Kbd>
131+
Fullscreen <Kbd>F11</Kbd>
131132
</div>
132133
</TooltipContent>
133134
</Tooltip>

apps/web/app/bookings/components/BookingControls.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ const ButtonGroupMapControls = () => {
161161
></TooltipTrigger>
162162
<TooltipContent className="pr-1.5">
163163
<div className="flex items-center gap-2">
164-
Fullscreen <Kbd>{navigator.platform.startsWith("Mac") ? "⌃⌘F" : "F11"}</Kbd>
164+
Fullscreen <Kbd>F11</Kbd>
165165
</div>
166166
</TooltipContent>
167167
</Tooltip>

apps/web/app/data/components/Flights/ReplayControls.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ const ButtonGroupMapControls = () => {
173173
></TooltipTrigger>
174174
<TooltipContent className="pr-1.5">
175175
<div className="flex items-center gap-2">
176-
Fullscreen <Kbd>{navigator.platform.startsWith("Mac") ? "⌃⌘F" : "F11"}</Kbd>
176+
Fullscreen <Kbd>F11</Kbd>
177177
</div>
178178
</TooltipContent>
179179
</Tooltip>

apps/web/app/data/components/Flights/columns.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ function ShareButton({ flight }: { flight: Flight }) {
196196
const [shared, setShared] = useState(false);
197197

198198
const onShareClick = () => {
199+
if (typeof window === "undefined") return;
200+
199201
navigator.clipboard.writeText(`${window.location.origin}/data/flights/${flight.callsign}/${flight.id}`);
200202
toast.success("Replay Link Copied to Clipboard!");
201203
setShared(true);

apps/web/components/Map/Overlays.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ function ControllerOverlay({ controllers }: { controllers: ControllerShort[] | u
183183
if (!controllers || controllers.length === 0) return null;
184184

185185
const onCopy = (controller: ControllerShort) => {
186+
if (typeof window === "undefined") return;
187+
186188
const atis = controller?.atis?.join("\n") || "";
187189
navigator.clipboard.writeText(atis);
188190
setCopied(controller.callsign);

apps/web/components/Panel/Airport/AirportFooter.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export function AirportFooter({ icao, mapService }: { icao: string; mapService?:
2121
const [loading, setLoading] = useState(false);
2222

2323
const onShareClick = () => {
24+
if (typeof window === "undefined") return;
25+
2426
navigator.clipboard.writeText(`${window.location.origin}/airport/${icao}`);
2527
toast.success("Link Copied to Clipboard!");
2628
setShared(true);

apps/web/components/Panel/Pilot/PilotFooter.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export function PilotFooter({ pilot, mapService }: { pilot: PilotLong; mapServic
2020
};
2121

2222
const onShareClick = () => {
23+
if (typeof window === "undefined") return;
24+
2325
navigator.clipboard.writeText(window.location.href);
2426
toast.success("Link Copied to Clipboard!");
2527
setShared(true);

apps/web/components/Panel/Sector/SectorFooter.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export function SectorFooter({ callsign }: { callsign: string }) {
99
const [shared, setShared] = useState(false);
1010

1111
const onShareClick = () => {
12+
if (typeof window === "undefined") return;
13+
1214
navigator.clipboard.writeText(`${window.location.origin}/sector/${callsign}`);
1315
toast.success("Link Copied to Clipboard!");
1416
setShared(true);

apps/web/components/Panel/shared/ControllerInfo.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export default function ControllerInfo({
2727
const atis = controller.atis?.join("\n") || "No ATIS information available.";
2828

2929
const onCopyClick = () => {
30+
if (typeof window === "undefined") return;
31+
3032
navigator.clipboard.writeText(atis);
3133
toast.success("ATIS Copied to Clipboard!");
3234
setCopied(true);

apps/web/lib/map/MapService.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ export class MapService {
230230
}
231231

232232
public addEventListeners() {
233+
if (typeof window === "undefined") return;
234+
233235
this.map?.on("moveend", this.onMoveEnd);
234236

235237
const isTouch = "ontouchstart" in window || navigator.maxTouchPoints > 0;

0 commit comments

Comments
 (0)