Skip to content

Commit 9be0ef5

Browse files
authored
Refresh params automatically if enable param is updated (#1114)
* Refresh params automatically if enable param is updated * Address copilot review comments
1 parent 512e4dd commit 9be0ef5

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

gcs/src/redux/middleware/socketMiddleware.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ import {
127127
setUpdatePlannedHomePositionFromLoadModal,
128128
} from "../slices/missionSlice"
129129
import {
130+
emitRefreshParams,
130131
resetParamsWriteProgressData,
131132
setAutoPilotRebootModalOpen,
132133
setFetchingParam,
@@ -938,6 +939,24 @@ const socketMiddleware = (store) => {
938939
if (rebootRequired) {
939940
store.dispatch(setRebootPromptModalOpen(true))
940941
}
942+
943+
// Refresh params if an _ENABLE param has been changed
944+
const hasEnableParam = paramsSetSuccessfully.some((param) =>
945+
String(param?.param_id || "")
946+
.toUpperCase()
947+
.endsWith("_ENABLE"),
948+
)
949+
const isOnParamsPage =
950+
store.getState().droneConnection.currentPage === "params"
951+
const isAlreadyFetching = store.getState().paramsSlice.fetchingVars
952+
953+
if (hasEnableParam && isOnParamsPage && !isAlreadyFetching) {
954+
store.dispatch(
955+
setFetchingVarsProgress({ progress: 0, param_id: "" }),
956+
)
957+
store.dispatch(setFetchingVars(true))
958+
store.dispatch(emitRefreshParams())
959+
}
941960
})
942961

943962
socket.socket.on(ParamSpecificSocketEvents.onParamError, (msg) => {

0 commit comments

Comments
 (0)