-
Notifications
You must be signed in to change notification settings - Fork 1
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
SC-206 Filters out used Channels #531
base: master
Are you sure you want to change the base?
Conversation
function filterChannels(chs: OpenXDA.Types.Channel[]) { | ||
return chs.filter(ch => | ||
!(ch.Asset.length > 0) | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be wrapped with a useMemo instead of being a function? That way, we only run this function once any time props.Channels changes and not a bunch of times every rerender.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that's true. I don't think we run this function on every rerender. It just get's defined as a new function on every re-render. that may be perfectly fine.
But the real question is why are we filtering through this twice?
ChannelSelector
will filter it by whatever matches the Search state, so it will run through the list anyway. It would make sense to add this Filter there instead of filtering it here and in ChannelSelector
Thinking this through, we may need/want to retain the ability to "Unselect" Channels already tied to this asset. otherwhise there is an issue in the workflow where someone accidentally assigns a channel, closes the modal and has no way of undoing that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above
Added a filterChannel function