diff options
Diffstat (limited to 'modern/src/main')
-rw-r--r-- | modern/src/main/MainPage.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/modern/src/main/MainPage.js b/modern/src/main/MainPage.js index 2d0671ae..3669dd50 100644 --- a/modern/src/main/MainPage.js +++ b/modern/src/main/MainPage.js @@ -191,10 +191,20 @@ const MainPage = () => { dispatch(devicesActions.select(deviceId)); }, [dispatch]); + const deviceGroups = (device) => { + const groupIds = []; + let { groupId } = device; + while (groupId) { + groupIds.push(groupId); + groupId = groups[groupId].groupId; + } + return groupIds; + }; + useEffect(() => { const filtered = Object.values(devices) .filter((device) => !filterStatuses.length || filterStatuses.includes(device.status)) - .filter((device) => !filterGroups.length || filterGroups.includes(device.groupId)) + .filter((device) => !filterGroups.length || deviceGroups(device).some((id) => filterGroups.includes(id))) .filter((device) => { const keyword = filterKeyword.toLowerCase(); return [device.name, device.uniqueId, device.phone, device.model, device.contact].some((s) => s && s.toLowerCase().includes(keyword)); |