@adventurelabs/scout-core 1.0.95 → 1.0.96
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.
|
@@ -15,14 +15,14 @@ export function useScoutRealtimeConnectivity(scoutSupabase) {
|
|
|
15
15
|
// Handle connectivity broadcasts
|
|
16
16
|
const handleConnectivityBroadcast = useCallback((payload) => {
|
|
17
17
|
const { event, payload: data } = payload;
|
|
18
|
-
const connectivityData = data.
|
|
18
|
+
const connectivityData = data.record || data.old_record;
|
|
19
19
|
// Only process GPS tracker data (no session_id)
|
|
20
20
|
if (!connectivityData?.device_id || connectivityData.session_id) {
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
const deviceId = connectivityData.device_id;
|
|
24
24
|
const updatedConnectivity = { ...connectivity };
|
|
25
|
-
switch (
|
|
25
|
+
switch (data.operation) {
|
|
26
26
|
case "INSERT":
|
|
27
27
|
if (!updatedConnectivity[deviceId]) {
|
|
28
28
|
updatedConnectivity[deviceId] = [];
|
|
@@ -9,21 +9,20 @@ export function useScoutRealtimeDevices(scoutSupabase) {
|
|
|
9
9
|
const activeHerdId = useSelector((state) => state.scout.active_herd_id);
|
|
10
10
|
// Device broadcast handler
|
|
11
11
|
const handleDeviceBroadcast = useCallback((payload) => {
|
|
12
|
-
console.log("[Devices] Broadcast received:", payload.payload.
|
|
13
|
-
const event = payload.payload.event;
|
|
12
|
+
console.log("[Devices] Broadcast received:", payload.payload.operation);
|
|
14
13
|
const data = payload.payload;
|
|
15
|
-
switch (
|
|
14
|
+
switch (data.operation) {
|
|
16
15
|
case "INSERT":
|
|
17
|
-
if (data.
|
|
18
|
-
dispatch(addDevice(data.
|
|
16
|
+
if (data.record)
|
|
17
|
+
dispatch(addDevice(data.record));
|
|
19
18
|
break;
|
|
20
19
|
case "UPDATE":
|
|
21
|
-
if (data.
|
|
22
|
-
dispatch(updateDevice(data.
|
|
20
|
+
if (data.record)
|
|
21
|
+
dispatch(updateDevice(data.record));
|
|
23
22
|
break;
|
|
24
23
|
case "DELETE":
|
|
25
|
-
if (data.
|
|
26
|
-
dispatch(deleteDevice(data.
|
|
24
|
+
if (data.old_record)
|
|
25
|
+
dispatch(deleteDevice(data.old_record));
|
|
27
26
|
break;
|
|
28
27
|
}
|
|
29
28
|
}, [dispatch]);
|