-
Notifications
You must be signed in to change notification settings - Fork 386
Conversation
7ad0e4c
to
1d9747a
Compare
e8ed44c
to
dcdfde2
Compare
src/selectors/entities/channels.js
Outdated
// If we receive an unread for a channel and then a mention the channel | ||
// won't be sorted correctly until we receive a message in another channel | ||
if (!currentUser) { | ||
return []; | ||
} | ||
|
||
const locale = currentUser.locale || General.DEFAULT_LOCALE; | ||
const allUnreadChannels = unreadIds.map((id) => { | ||
const allUnreadChannels = unreadIds.filter((u) => u).map((id) => { |
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.
Why is this filter here? Is there a known case where we end up with a falsey id in unreadIds
?
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.
Last I check I was getting falsy ids. Some were null last I checked. I could check if that's still a problem
src/selectors/entities/channels.js
Outdated
getCurrentUser, | ||
getMyChannelMemberships, | ||
getLastPostPerChannel, | ||
(state, lastUnreadChannel, unreadsAtTop, favoritesAtTop, sorting = 'alpha') => sorting, |
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 we get rid of the unused parameters for these? I see that lastUnreadPost
and sorting
are used, but getMapAndSortedUnreadChannelIds
doesn't use unreadsAtTop
and favoritesAtTop
at all
src/selectors/entities/channels.js
Outdated
getMapAndSortedUnreadChannelIds, | ||
() => false, | ||
() => false, | ||
filterChannels, |
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.
Similarly, can we get rid of the extra argument functions for this selector? If you're concerned about passing the right number of arguments into filterChannels
, you could do it like this to make it a bit clearer
export const getSortedUnreadChannelIds = createIdsSelector(
getUnreadChannelIds,
getFavoritesPreferences,
getMapAndSortedUnreadChannelIds,
(unreadChannelIds, favoriteChannelIds, mappedAndSortedUnreadChannelIds) => {
return filterChannels(unreadChannelIds, favoriteChannelIds, mappedAndSortedUnreadChannelIds, false, false);
}
);
src/selectors/entities/channels.js
Outdated
getCurrentUser, | ||
getMyChannelMemberships, | ||
getLastPostPerChannel, | ||
(state, lastUnreadChannel, unreadsAtTop, favoritesAtTop, sorting = 'alpha') => sorting, |
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.
lastUnreadChannel
, unreadsAtTop
, and favoritesAtTop
don't seem to be used by getFavoriteChannelIds
src/selectors/entities/channels.js
Outdated
getSortedFavoriteChannelWithUnreadsIds, | ||
filterUnreadChannels | ||
getFavoritesPreferences, | ||
getFavoriteChannelIds, |
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.
Instead of passing extra arguments to getFavoriteChannelIds
that it doesn't use, you could remove the extra parameters from it and then change this to
(state, lastUnreadChannel, unreadsAtTop, favoritesAtTop, sorting) => getFavoriteChannelIds(state, sorting)
src/selectors/entities/sidebar.js
Outdated
'', | ||
null | ||
); | ||
return JSON.parse(sidebarPreference); |
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.
JSON.parse
will return a new object each time, so it should be moved into the result function to prevent this from being memoized properly
src/selectors/entities/sidebar.js
Outdated
sorting: 'alpha', | ||
}; | ||
|
||
export const getSidebarPreferences = createSelector( |
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.
Could you move this into selectors/entities/preferences
since sidebar
isn't an entity?
Thanks for the feedback @hmhealey. I'm hoping to take a look at it today and tomorrow |
Just a heads up, we had to put this on hold. Currently we have some top priority tasks for the upcoming weeks. |
Thanks for the heads up. Definitely understand since we're doing the same for some other features. |
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.
LGTM other than Harrison's comments
dcdfde2
to
3ba020c
Compare
Hey @hmhealey, just a heads up. We plan on getting this in shape for merging. I'm addressing your feedback and would greatly appreciate any input for getting this in master soon. Thanks |
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've got a couple other things that could be improved, but the rest of my concerns have been addressed
src/selectors/entities/channels.js
Outdated
return getMapAndSortedUnreadChannelIds(state, lastUnreadChannel, sorting); | ||
}, | ||
(unreadChannelIds, favoritePreferences, mappedAndSortedUnreadChannelIds) => { | ||
return filterChannels(unreadChannelIds, favoritePreferences, mappedAndSortedUnreadChannelIds, false, false); |
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.
Since we're always passing false into these last two, can we skip that call entirely?
src/selectors/entities/channels.js
Outdated
getCurrentUser, | ||
getUsers, | ||
getAllChannels, | ||
getMyChannelMemberships, | ||
getUnreadChannelIds, | ||
getTeammateNameDisplaySetting, | ||
(state, lastUnreadChannel = null) => lastUnreadChannel, | ||
(currentUser, profiles, channels, myMembers, unreadIds, settings, lastUnreadChannel) => { | ||
(currentUser, profiles, channels, myMembers, unreadIds, settings) => { |
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 don't think myMembers
is needed here since the filtering has been removed
bd3cb58
to
3a9437c
Compare
@hmhealey @sudheerDev thanks for the feedback. I've addressed this and will rebase the webapp PR tomorrow. Everything is good to go for the redux PR |
Looks good. We're going to hold off on merging until the web app and mobile PRs are ready to avoid any compatibility issues |
a201ddd
to
b0a415b
Compare
* New selectors for sidebar reorganization * Sort unread channels by mentions * Add test for new grouping and sorting algorithms * Add selector for sidebar preferences * Changes from feedback * Refactor sortByRecency function * Added channel selectors to include unreadIds, for backwards compatibility * Fix failing test for channel selector * Add global unread and favorite support * Unread section should respect sorting preference * Remove empty argument functions * Remove unused arguments * memoize getOrderedChannelIds * Move hasChannelsChanged outside of getOrderedChannelIds * Remove getOrderedChannelIdsDeprecated * Move getSidebarPreferences to selectors/entities/preferences * Move JSON to result function * Fix failing test * Remove string comparison for orderedChannels * Filter channels that have been deleted in getUnreadChannels * Remove unnecessary filterChannel call * Fix test for more_direct_channels selector * Fix issue with filter in getUnreadChannels * remove myMembers from getUnreadChannels * Sidebar preference overrides previous unread sorting
Summary
Bringing back the sidebar feature after a regression with the unread channels indicator on the web side.
Old PR: mattermost/mattermost-webapp#1374
Nothing has changed in the redux library.
Checklist
[Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.]
make check-style
to check for style errors (required for all pull requests)make test
to ensure unit and component tests passed