Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix filter of end devices with startsWith #7476

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ const AppSideNavigation = () => {
const rights = useSelector(selectApplicationRights)
const natsDisabled = useSelector(selectNatsProviderDisabled)
const mqttDisabled = useSelector(selectMqttProviderDisabled)
const topEntityFilter = useCallback(e => e.id.startsWith(appId), [appId])
const topEntityFilter = useCallback(
e => {
const separatedAppId = e.id.split('/')[0]
return separatedAppId === appId
},
[appId],
)
const topEntities = useSelector(state => selectEndDeviceTopEntities(state, topEntityFilter))

if (!app) {
Expand Down
21 changes: 12 additions & 9 deletions pkg/webui/console/store/selectors/top-entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,20 @@ export const selectTopEntities = createSelector(
)

const createTopEntityByTypeSelector = entityType =>
createSelector([selectTopEntities, (_, filter) => filter], (topEntities, filter) => {
if (!topEntities[entityType]) {
return []
}
createSelector(
[selectTopEntities, (_, topEntityFilter) => topEntityFilter],
(topEntities, topEntityFilter) => {
if (!topEntities[entityType]) {
return []
}

const filteredEntities = filter
? topEntities[entityType].filter(filter)
: topEntities[entityType]
const filteredEntities = topEntityFilter
? topEntities[entityType].filter(topEntityFilter)
: topEntities[entityType]

return filteredEntities
})
return filteredEntities
},
)

export const selectTopEntitiesAll = state => selectTopEntities(state)[ALL]

Expand Down
Loading