@skyvexsoftware/stratos-sdk 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,12 +34,16 @@ async function fetchFlightEvents() {
34
34
  export function useFlightEvents(options) {
35
35
  const queryClient = useQueryClient();
36
36
  const { socket } = useSocket();
37
- const queryKey = flightEventsKeys.log(options?.flightId);
37
+ // Memoized so the effect below can list queryKey in its deps without
38
+ // reattaching socket listeners on every render.
39
+ const queryKey = useMemo(() => flightEventsKeys.log(options?.flightId), [options?.flightId]);
38
40
  const { data, isLoading } = useQuery({
39
41
  queryKey,
40
42
  queryFn: fetchFlightEvents,
41
43
  staleTime: Infinity,
42
- refetchOnWindowFocus: false,
44
+ // "always" (not true) because staleTime: Infinity would otherwise
45
+ // suppress the default focus refetch.
46
+ refetchOnWindowFocus: "always",
43
47
  refetchOnReconnect: false,
44
48
  });
45
49
  // Subscribe to Socket.io events and append new events to the cache
@@ -56,11 +60,18 @@ export function useFlightEvents(options) {
56
60
  };
57
61
  });
58
62
  };
63
+ // Refetch on (re)connect — broadcasts during a disconnect window
64
+ // are lost from the append-only cache, so we resync from the DB.
65
+ const handleConnect = () => {
66
+ void queryClient.invalidateQueries({ queryKey });
67
+ };
59
68
  socket.on(SOCKET_EVENTS.FLIGHT_EVENT, handleEvent);
69
+ socket.on("connect", handleConnect);
60
70
  return () => {
61
71
  socket.off(SOCKET_EVENTS.FLIGHT_EVENT, handleEvent);
72
+ socket.off("connect", handleConnect);
62
73
  };
63
- }, [socket, queryClient, options?.flightId]);
74
+ }, [socket, queryClient, queryKey]);
64
75
  // ── Comment Mutations ──────────────────────────────────────────────
65
76
  const addCommentMutation = useMutation({
66
77
  mutationFn: async (message) => {
@@ -68,7 +68,9 @@ class SocketManager {
68
68
  this.socket = io(STRATOS_APP_BASE, {
69
69
  transports: ["websocket", "polling"],
70
70
  reconnection: true,
71
- reconnectionAttempts: 5,
71
+ // Default Infinity — the shell is long-running and a user who
72
+ // alt-tabs for a minute should still find a live socket on return.
73
+ reconnectionAttempts: Infinity,
72
74
  reconnectionDelay: 1000,
73
75
  autoConnect: true,
74
76
  });
@@ -41,7 +41,10 @@ export function useTrackingSession() {
41
41
  queryKey: trackingSessionKeys.state,
42
42
  queryFn: fetchFlightManagerState,
43
43
  staleTime: Infinity,
44
- refetchOnWindowFocus: false,
44
+ // "always" (not true) because staleTime: Infinity would otherwise
45
+ // suppress the default focus refetch. Defensive against a socket
46
+ // that appears connected but stopped delivering broadcasts.
47
+ refetchOnWindowFocus: "always",
45
48
  refetchOnReconnect: false,
46
49
  });
47
50
  useEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyvexsoftware/stratos-sdk",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Plugin SDK for Stratos — types, hooks, and UI components",
5
5
  "author": {
6
6
  "name": "Skyvex Software Pty Ltd",