mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 09:31:20 -04:00
big overhaul for server and webui feature matching, things default to disabled and disappear from UI when disabled.
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
// Feature Helpers
|
||||
// Purpose: Centralizes client-side reads of server-advertised optional features.
|
||||
// Scope: Keeps layout/components from each inventing their own "is this feature configured?" rule.
|
||||
export function isFeatureEnabled(state, featureName) {
|
||||
/*
|
||||
The server owns feature detection because only it can reliably know whether
|
||||
config-driven hardware integrations exist. React should treat missing flags
|
||||
as disabled so old or partial session payloads fail closed and hide extras.
|
||||
*/
|
||||
return Boolean(state?.session?.features?.[featureName]);
|
||||
}
|
||||
|
||||
export function anyFeatureEnabled(state, featureNames = []) {
|
||||
return featureNames.some((featureName) => isFeatureEnabled(state, featureName));
|
||||
}
|
||||
Reference in New Issue
Block a user