@adventurelabs/scout-core 2.0.1 → 2.0.2
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.
- package/dist/helpers/cache.d.ts +25 -17
- package/dist/helpers/cache.js +225 -221
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/useScoutRealtimeOperatingContexts.d.ts +5 -3
- package/dist/hooks/useScoutRealtimeOperatingContexts.js +8 -0
- package/dist/hooks/useScoutRefresh.d.ts +3 -2
- package/dist/hooks/useScoutRefresh.js +160 -123
- package/dist/providers/ScoutRefreshProvider.js +39 -17
- package/dist/store/scout.d.ts +1 -3
- package/dist/store/scout.js +9 -14
- package/package.json +1 -1
package/dist/store/scout.js
CHANGED
|
@@ -24,17 +24,16 @@ const initialState = {
|
|
|
24
24
|
active_herd_id: null,
|
|
25
25
|
active_device_id: null,
|
|
26
26
|
user: null,
|
|
27
|
-
// Initialize data source tracking
|
|
28
27
|
data_source: EnumDataSource.UNKNOWN,
|
|
29
28
|
data_source_info: null,
|
|
30
29
|
active_herd_gps_trackers_connectivity: {},
|
|
31
30
|
};
|
|
32
|
-
|
|
31
|
+
const scoutSlice = createSlice({
|
|
33
32
|
name: "scout",
|
|
34
33
|
initialState,
|
|
35
34
|
reducers: {
|
|
35
|
+
resetScoutState: () => initialState,
|
|
36
36
|
setHerdModules: (state, action) => {
|
|
37
|
-
// Payload is the modules array (legacy) or { modules, contentHash }.
|
|
38
37
|
const payload = action.payload;
|
|
39
38
|
const modules = Array.isArray(payload)
|
|
40
39
|
? payload
|
|
@@ -42,7 +41,12 @@ export const scoutSlice = createSlice({
|
|
|
42
41
|
const contentHash = Array.isArray(payload)
|
|
43
42
|
? null
|
|
44
43
|
: payload.contentHash ?? null;
|
|
45
|
-
|
|
44
|
+
if (state.active_herd_id &&
|
|
45
|
+
!modules.some((module) => module.herd.id?.toString() === state.active_herd_id)) {
|
|
46
|
+
state.active_herd_id = null;
|
|
47
|
+
state.active_device_id = null;
|
|
48
|
+
state.active_herd_gps_trackers_connectivity = {};
|
|
49
|
+
}
|
|
46
50
|
if (contentHash != null) {
|
|
47
51
|
if (state.herd_modules_content_hash === contentHash) {
|
|
48
52
|
return;
|
|
@@ -138,7 +142,6 @@ export const scoutSlice = createSlice({
|
|
|
138
142
|
herd_module.devices.push(device);
|
|
139
143
|
}
|
|
140
144
|
},
|
|
141
|
-
// append device to herd module
|
|
142
145
|
addNewDeviceToHerdModule: (state, action) => {
|
|
143
146
|
const { herd_id, device } = action.payload;
|
|
144
147
|
const herd_module = state.herd_modules.find((hm) => hm.herd.id?.toString() === herd_id);
|
|
@@ -146,11 +149,6 @@ export const scoutSlice = createSlice({
|
|
|
146
149
|
herd_module.devices = [...herd_module.devices, device];
|
|
147
150
|
}
|
|
148
151
|
},
|
|
149
|
-
// NOTE: Tag management will need to be updated to work with RTK Query
|
|
150
|
-
// These actions are commented out until we implement tag management with RTK Query
|
|
151
|
-
// addTag(state, action) { ... },
|
|
152
|
-
// deleteTag(state, action) { ... },
|
|
153
|
-
// updateTag(state, action) { ... },
|
|
154
152
|
addDevice(state, action) {
|
|
155
153
|
for (const herd_module of state.herd_modules) {
|
|
156
154
|
if (herd_module.herd.id === action.payload.herd_id) {
|
|
@@ -205,8 +203,6 @@ export const scoutSlice = createSlice({
|
|
|
205
203
|
}
|
|
206
204
|
}
|
|
207
205
|
},
|
|
208
|
-
// NOTE: Events, sessions, and artifacts are now handled by RTK Query
|
|
209
|
-
// These actions have been removed as they're no longer needed
|
|
210
206
|
setUser: (state, action) => {
|
|
211
207
|
state.user = action.payload;
|
|
212
208
|
},
|
|
@@ -215,6 +211,5 @@ export const scoutSlice = createSlice({
|
|
|
215
211
|
},
|
|
216
212
|
},
|
|
217
213
|
});
|
|
218
|
-
|
|
219
|
-
export const { setHerdModules, setStatus, setHerdModulesLoadingState, setLoadingPerformance, setHerdModulesLoadedInMs, setHerdModulesApiServerProcessingDuration, setHerdModulesApiTotalRequestDuration, setUserApiDuration, setDataProcessingDuration, setCacheLoadDuration, setActiveHerdId, setActiveDeviceId, setDataSource, setDataSourceInfo, updateSessionSummariesForHerdModule, appendPlansToHerdModule, setUser, addNewDeviceToHerdModule, updateDeviceForHerdModule, addDevice, deleteDevice, updateDevice, addPlan, deletePlan, updatePlan, setActiveHerdGpsTrackersConnectivity, } = scoutSlice.actions;
|
|
214
|
+
export const { resetScoutState, setHerdModules, setStatus, setHerdModulesLoadingState, setLoadingPerformance, setHerdModulesLoadedInMs, setHerdModulesApiServerProcessingDuration, setHerdModulesApiTotalRequestDuration, setUserApiDuration, setDataProcessingDuration, setCacheLoadDuration, setActiveHerdId, setActiveDeviceId, setDataSource, setDataSourceInfo, updateSessionSummariesForHerdModule, appendPlansToHerdModule, setUser, addNewDeviceToHerdModule, updateDeviceForHerdModule, addDevice, deleteDevice, updateDevice, addPlan, deletePlan, updatePlan, setActiveHerdGpsTrackersConnectivity, } = scoutSlice.actions;
|
|
220
215
|
export default scoutSlice.reducer;
|