@adventurelabs/scout-core 1.0.94 → 1.0.95

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.
@@ -53,6 +53,7 @@ export function useScoutRealtimeConnectivity(scoutSupabase) {
53
53
  }
54
54
  break;
55
55
  }
56
+ console.log("[Connectivity] updating tracker connectivity in response to broadcast");
56
57
  dispatch(setActiveHerdGpsTrackersConnectivity(updatedConnectivity));
57
58
  }, [connectivity]);
58
59
  // Fetch initial connectivity data
@@ -95,9 +96,9 @@ export function useScoutRealtimeConnectivity(scoutSupabase) {
95
96
  }));
96
97
  dispatch(setActiveHerdGpsTrackersConnectivity(connectivityData));
97
98
  console.log(`[Connectivity] Loaded data for ${Object.keys(connectivityData).length} devices`);
98
- }, [activeHerdId]);
99
+ }, [activeHerdId, herdModules]);
99
100
  useEffect(() => {
100
- if (!scoutSupabase || !activeHerdId)
101
+ if (!scoutSupabase || !activeHerdId || herdModules.length == 0)
101
102
  return;
102
103
  // Clean up existing channels
103
104
  channels.current.forEach((channel) => scoutSupabase.removeChannel(channel));
@@ -121,5 +122,5 @@ export function useScoutRealtimeConnectivity(scoutSupabase) {
121
122
  channels.current.forEach((ch) => scoutSupabase.removeChannel(ch));
122
123
  channels.current = [];
123
124
  };
124
- }, [activeHerdId]);
125
+ }, [activeHerdId, herdModules]);
125
126
  }
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useCallback, useRef } from "react";
2
2
  import { useAppDispatch } from "../store/hooks";
3
- import { EnumScoutStateStatus, setActiveHerdId, setHerdModules, setStatus, setHerdModulesLoadingState, setHerdModulesLoadedInMs, setHerdModulesApiDuration, setUserApiDuration, setDataProcessingDuration, setLocalStorageDuration, setUser, setDataSource, setDataSourceInfo, } from "../store/scout";
3
+ import { EnumScoutStateStatus, setHerdModules, setStatus, setHerdModulesLoadingState, setHerdModulesLoadedInMs, setHerdModulesApiDuration, setUserApiDuration, setDataProcessingDuration, setLocalStorageDuration, setUser, setDataSource, setDataSourceInfo, } from "../store/scout";
4
4
  import { EnumHerdModulesLoadingState } from "../types/herd_module";
5
5
  import { server_load_herd_modules } from "../helpers/herds";
6
6
  import { server_get_user } from "../helpers/users";
@@ -275,32 +275,38 @@ export function useScoutRefresh(options = {}) {
275
275
  const dataProcessingDuration = Date.now() - dataProcessingStartTime;
276
276
  timingRefs.current.dataProcessingDuration = dataProcessingDuration;
277
277
  dispatch(setDataProcessingDuration(dataProcessingDuration));
278
- // Step 5: Handle localStorage operations
278
+ // // Step 5: Handle localStorage operations
279
279
  const localStorageStartTime = Date.now();
280
- try {
281
- // Check local storage for a last selected herd
282
- const lastSelectedHerd = localStorage.getItem("last_selected_herd");
283
- if (lastSelectedHerd) {
284
- const found_herd = compatible_new_herd_modules.find((hm) => hm.herd.id.toString() === lastSelectedHerd)?.herd;
285
- // If herd is found then set it
286
- if (found_herd) {
287
- dispatch(setActiveHerdId(found_herd.id.toString()));
288
- }
289
- }
290
- // If there is no last selected herd then select the first one
291
- else if (compatible_new_herd_modules.length > 0) {
292
- const firstHerdId = compatible_new_herd_modules[0].herd.id.toString();
293
- localStorage.setItem("last_selected_herd", firstHerdId);
294
- dispatch(setActiveHerdId(firstHerdId));
295
- }
296
- }
297
- catch (localStorageError) {
298
- console.warn("[useScoutRefresh] localStorage not available:", localStorageError);
299
- // Fallback: select first herd without localStorage
300
- if (compatible_new_herd_modules.length > 0) {
301
- dispatch(setActiveHerdId(compatible_new_herd_modules[0].herd.id.toString()));
302
- }
303
- }
280
+ // try {
281
+ // // Check local storage for a last selected herd
282
+ // const lastSelectedHerd = localStorage.getItem("last_selected_herd");
283
+ // if (lastSelectedHerd) {
284
+ // const found_herd = compatible_new_herd_modules.find(
285
+ // (hm) => hm.herd.id.toString() === lastSelectedHerd,
286
+ // )?.herd;
287
+ // // If herd is found then set it
288
+ // if (found_herd) {
289
+ // dispatch(setActiveHerdId(found_herd.id.toString()));
290
+ // }
291
+ // }
292
+ // // If there is no last selected herd then select the first one
293
+ // else if (compatible_new_herd_modules.length > 0) {
294
+ // const firstHerdId = compatible_new_herd_modules[0].herd.id.toString();
295
+ // localStorage.setItem("last_selected_herd", firstHerdId);
296
+ // dispatch(setActiveHerdId(firstHerdId));
297
+ // }
298
+ // } catch (localStorageError) {
299
+ // console.warn(
300
+ // "[useScoutRefresh] localStorage not available:",
301
+ // localStorageError,
302
+ // );
303
+ // // Fallback: select first herd without localStorage
304
+ // if (compatible_new_herd_modules.length > 0) {
305
+ // dispatch(
306
+ // setActiveHerdId(compatible_new_herd_modules[0].herd.id.toString()),
307
+ // );
308
+ // }
309
+ // }
304
310
  const localStorageDuration = Date.now() - localStorageStartTime;
305
311
  timingRefs.current.localStorageDuration = localStorageDuration;
306
312
  dispatch(setLocalStorageDuration(localStorageDuration));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adventurelabs/scout-core",
3
- "version": "1.0.94",
3
+ "version": "1.0.95",
4
4
  "description": "Core utilities and helpers for Adventure Labs Scout applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",