Skip to content

Commit

Permalink
respect showGaps and showComplex feature toggles for pixelgraph webso…
Browse files Browse the repository at this point in the history
…cket subscriptions
  • Loading branch information
YeonV committed Feb 18, 2025
1 parent d343bff commit e1ccef1
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
14 changes: 13 additions & 1 deletion src/pages/Devices/Devices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,19 @@ const Devices = () => {

useEffect(() => {
if (graphs && graphsMulti) {
setPixelGraphs(Object.keys(virtuals))
setPixelGraphs(
Object.keys(virtuals)
.filter((v) =>
showComplex
? v
: !(
v.endsWith('-mask') ||
v.endsWith('-foreground') ||
v.endsWith('-background')
)
)
.filter((v) => (showGaps ? v : !v.startsWith('gap-')))
)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [graphs, graphsMulti, setPixelGraphs])
Expand Down
16 changes: 14 additions & 2 deletions src/pages/Home/DbDevices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,21 @@ const DbDevices = () => {

useEffect(() => {
if (graphs && graphsMulti) {
setPixelGraphs(Object.keys(virtuals))
setPixelGraphs(
Object.keys(virtuals)
.filter((v) =>
showComplex
? v
: !(
v.endsWith('-mask') ||
v.endsWith('-foreground') ||
v.endsWith('-background')
)
)
.filter((v) => (showGaps ? v : !v.startsWith('gap-')))
)
}
}, [graphs, graphsMulti, setPixelGraphs, virtuals])
}, [graphs, graphsMulti, setPixelGraphs, virtuals, showComplex, showGaps])

const handleEvent: GridEventListener<'rowClick'> = (params) =>
navigate(`/device/${params.row.id}`)
Expand Down
16 changes: 15 additions & 1 deletion src/utils/Websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ export const HandleWs = () => {
const setPixelGraphs = useStore((state) => state.setPixelGraphs)
const graphs = useStore((state) => state.graphs)
const graphsMulti = useStore((state) => state.graphsMulti)
const showComplex = useStore((state) => state.showComplex)
const showGaps = useStore((state) => state.showGaps)
const [wsReady, setWsReady] = useState(false)

useLayoutEffect(() => {
Expand All @@ -216,7 +218,19 @@ export const HandleWs = () => {
if (!graphs || !graphsMulti) {
setPixelGraphs([])
} else {
setPixelGraphs(Object.keys(virtuals))
setPixelGraphs(
Object.keys(virtuals)
.filter((v) =>
showComplex
? v
: !(
v.endsWith('-mask') ||
v.endsWith('-foreground') ||
v.endsWith('-background')
)
)
.filter((v) => (showGaps ? v : !v.startsWith('gap-')))
)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [graphs, graphsMulti])
Expand Down

0 comments on commit e1ccef1

Please sign in to comment.