Create component with list of thread members grouped by first letter of username. The component will be displayed in modal.
The component disallows list scrolling if any menu from its children is open (that's why it keeps opened menus list).
Details
The component can be tested after introducing members modal.
Diff Detail
- Repository
- rCOMM Comm
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
web/modals/threads/members/members-list.react.js | ||
---|---|---|
4 ↗ | (On Diff #10205) | My preference is to use import _ from 'lodash' but in most other places we're importing just a single function from fp package, so to keep consistency use e.g. import _groupBy from 'lodash/fp/groupBy' and we can discuss which approach is better for us. |
23 ↗ | (On Diff #10205) | Why do we need to have an array here? Is there a reason why we can't have a state with single nullable number? |
41–47 ↗ | (On Diff #10205) | To make the memoization work here we should give ThreadMember its user.id and setOpenMenus function and then create callback there |
51 ↗ | (On Diff #10205) | It's a header so we should probably use h here |
web/modals/threads/members/members-list.react.js | ||
---|---|---|
23 ↗ | (On Diff #10205) | When I implemented it with single number, there was a race condition when I was switching between menus - when trying to open one if the other is opened. I happened, that the second one was opened a bit quicker that the first was closed, and the state became invalid. The solution with array of opened menus prevents the problems here. |
web/modals/threads/members/members-list.react.js | ||
---|---|---|
23 ↗ | (On Diff #10205) | I'm not sure why this race condition occurred. But it is possible that onMenuChange can be implemented in a way that avoids this issue: |
web/modals/threads/members/members-list.react.js | ||
---|---|---|
35 | This shouldn't happen, but if somebody's username is the empty string, a[0].localCompare could end up with a fatal error (dereferencing localCompare on undefined). Probably not worth worrying about (the username regex should prevent the empty string from working) |
web/modals/threads/members/members-list.react.js | ||
---|---|---|
37–45 | Yes, good catch. The users are currently displayed sorted by ID by default. I didn't notice it because all users I had in database were registered in alphabetical order accidentally. |