Refactor connection commands into callbacks#865
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors connection and disconnection commands to use callback hooks, applying the same pattern already used for the reboot functionality. This addresses timing issues where commands were either added when they shouldn't be or missing when needed.
- Renamed
useRebootCallback.jstodroneConnectionCallbacks.jsand added two new hooks:useConnectToDroneFromButtonCallbackanduseDisconnectFromDroneCallback - Moved command registration from
navbar.jsxtocommandHandler.jswhere callbacks are obtained directly from the hooks - Updated all import statements across affected files to reference the renamed module
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| gcs/src/helpers/droneConnectionCallbacks.js | Added new connection/disconnection callback hooks alongside the existing reboot callback |
| gcs/src/components/spotlight/commandHandler.js | Imported and registered the new connection callbacks as commands |
| gcs/src/components/navbar.jsx | Removed local command functions and useEffect, now uses callbacks from hooks |
| gcs/src/params.jsx | Updated import path to reference renamed droneConnectionCallbacks module |
| gcs/src/components/dashboard/tabsSectionTabs/actionTabsSection.jsx | Updated import path to reference renamed droneConnectionCallbacks module |
Comments suppressed due to low confidence (2)
gcs/src/helpers/droneConnectionCallbacks.js:36
- The new hook functions
useConnectToDroneFromButtonCallbackanduseDisconnectFromDroneCallbackare missing JSDoc documentation. For consistency with the existinguseRebootCallbackfunction (lines 16-20), these hooks should include documentation describing their purpose and return values.
gcs/src/helpers/droneConnectionCallbacks.js:43 - The new hook function
useDisconnectFromDroneCallbackis missing JSDoc documentation. For consistency with the existinguseRebootCallbackfunction (lines 16-20), this hook should include documentation describing its purpose and return value.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
gcs/src/helpers/droneConnectionCallbacks.js:43
- Missing JSDoc documentation for the new hook functions. The existing
useRebootCallbackfunction has comprehensive documentation. Consider adding similar documentation for consistency:
/**
* Hook that returns a callback to connect to a drone from a button click.
* Fetches available COM ports and opens the connection modal.
* @returns Callback to initiate drone connection
*/
export function useConnectToDroneFromButtonCallback() {
// ...
}
/**
* Hook that returns a callback to disconnect from a drone.
* @returns Callback to disconnect from drone
*/
export function useDisconnectFromDroneCallback() {
// ...
}💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Apply the same technique as is used for rebooting to connection and disconnection. This should fix both previous issues of the command being added when it shouldn't, and also it not existing when it should.