Fix: hide motherboard component on unsupported OS#1110
Conversation
Coverage Report
File CoverageNo changed files found. |
There was a problem hiding this comment.
Pull request overview
This PR hides the Motherboard dashboard item on OSes where it isn’t supported, preventing users from selecting or rendering that component outside of Windows.
Changes:
- Filter the dashboard item selector list to exclude
motherboardwhen not on Windows. - Render
MotherboardDataInfoonly whenplatform() === "windows".
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/features/hardware/dashboard/components/DashboardItemSelector.tsx |
Filters selectable dashboard items to hide motherboard on non-Windows. |
src/features/hardware/dashboard/Dashboard.tsx |
Conditionally renders the motherboard dashboard component only on Windows. |
| const { t } = useTranslation(); | ||
| const os = platform(); | ||
|
|
There was a problem hiding this comment.
platform() is evaluated on every render and it runs even when the component immediately returns null (when visibleItems is falsy). Consider moving the OS lookup after the early return and memoizing/caching it (e.g., useMemo) so the dropdown render doesn’t repeatedly call into the OS plugin unnecessarily.
| const { t } = useTranslation(); | ||
| const sensors = useSensors(useSensor(PointerSensor)); | ||
| const { visibleItems, toggleItem } = useDashboardSelector(); | ||
| const os = platform(); | ||
|
|
There was a problem hiding this comment.
platform() is called directly in the component body, which means it runs on every re-render. If this call is non-trivial (plugin invoke), it should be memoized/cached (e.g., useMemo) or computed once higher up and passed down, so rendering/drag interactions don’t repeatedly re-query the OS.
No description provided.