Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

New sidebar feature fixed #602

Merged
merged 25 commits into from
Nov 9, 2018
Merged

Conversation

csduarte
Copy link
Contributor

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.]

  • Ran make check-style to check for style errors (required for all pull requests)
  • Ran make test to ensure unit and component tests passed
  • Added or updated unit tests (required for all new features)
  • Has redux changes (please link)
  • Has UI changes
  • Includes text changes and localization file (.../i18n/en.json) updates

// 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) => {
Copy link
Member

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?

Copy link

@miguelespinoza miguelespinoza Oct 17, 2018

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

getCurrentUser,
getMyChannelMemberships,
getLastPostPerChannel,
(state, lastUnreadChannel, unreadsAtTop, favoritesAtTop, sorting = 'alpha') => sorting,
Copy link
Member

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

getMapAndSortedUnreadChannelIds,
() => false,
() => false,
filterChannels,
Copy link
Member

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);
    }
);

getCurrentUser,
getMyChannelMemberships,
getLastPostPerChannel,
(state, lastUnreadChannel, unreadsAtTop, favoritesAtTop, sorting = 'alpha') => sorting,
Copy link
Member

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

getSortedFavoriteChannelWithUnreadsIds,
filterUnreadChannels
getFavoritesPreferences,
getFavoriteChannelIds,
Copy link
Member

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/channels.js Show resolved Hide resolved
src/selectors/entities/channels.js Show resolved Hide resolved
src/selectors/entities/channels.js Show resolved Hide resolved
'',
null
);
return JSON.parse(sidebarPreference);
Copy link
Member

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

sorting: 'alpha',
};

export const getSidebarPreferences = createSelector(
Copy link
Member

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?

@hmhealey hmhealey added the 2: Dev Review Requires review by a core commiter label Aug 31, 2018
@hmhealey hmhealey added this to the v5.4.0 milestone Aug 31, 2018
@miguelespinoza
Copy link

Thanks for the feedback @hmhealey. I'm hoping to take a look at it today and tomorrow

@miguelespinoza
Copy link

Just a heads up, we had to put this on hold. Currently we have some top priority tasks for the upcoming weeks.
I'm hoping I can squeeze sometime next week to address this feedback but that's not certain

@hmhealey
Copy link
Member

Thanks for the heads up. Definitely understand since we're doing the same for some other features.

Copy link
Contributor

@sudheerDev sudheerDev left a 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

src/selectors/entities/channels.js Show resolved Hide resolved
@miguelespinoza
Copy link

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

Copy link
Member

@hmhealey hmhealey left a 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

return getMapAndSortedUnreadChannelIds(state, lastUnreadChannel, sorting);
},
(unreadChannelIds, favoritePreferences, mappedAndSortedUnreadChannelIds) => {
return filterChannels(unreadChannelIds, favoritePreferences, mappedAndSortedUnreadChannelIds, false, false);
Copy link
Member

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?

getCurrentUser,
getUsers,
getAllChannels,
getMyChannelMemberships,
getUnreadChannelIds,
getTeammateNameDisplaySetting,
(state, lastUnreadChannel = null) => lastUnreadChannel,
(currentUser, profiles, channels, myMembers, unreadIds, settings, lastUnreadChannel) => {
(currentUser, profiles, channels, myMembers, unreadIds, settings) => {
Copy link
Member

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

@miguelespinoza miguelespinoza force-pushed the sidebar-fixed branch 2 times, most recently from bd3cb58 to 3a9437c Compare October 25, 2018 21:40
@miguelespinoza
Copy link

@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

@hmhealey hmhealey added Do Not Merge/Awaiting PR Awaiting another pull request before merging (e.g. server changes) and removed 2: Dev Review Requires review by a core commiter labels Oct 30, 2018
@hmhealey
Copy link
Member

Looks good. We're going to hold off on merging until the web app and mobile PRs are ready to avoid any compatibility issues

@hmhealey hmhealey removed the Do Not Merge/Awaiting PR Awaiting another pull request before merging (e.g. server changes) label Nov 9, 2018
@hmhealey hmhealey merged commit e86e83d into mattermost:master Nov 9, 2018
@enahum enahum added the 4: Reviews Complete All reviewers have approved the pull request label Nov 9, 2018
DSchalla pushed a commit to DSchalla/mattermost-redux that referenced this pull request Apr 1, 2019
* 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
chetanyakan pushed a commit to brightscout-alpha/mattermost-redux that referenced this pull request Feb 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4: Reviews Complete All reviewers have approved the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants