mattermost / mattermost-mobile

Next generation iOS and Android apps for Mattermost in React Native
https://about.mattermost.com/
Apache License 2.0
2.27k stars 1.38k forks source link

Fix sidebar teams order #8281

Closed enahum closed 4 weeks ago

enahum commented 1 month ago

Summary

The code to sort the teams based on the order established by the preferences wasn't working, the preferences are already sorted and if no preferences set we sort by the display name of the team.

Noticed this issue since we started to add more teams on Hub.

Ticket Link

https://mattermost.atlassian.net/browse/MM-60723

Release Note

Fixed sort of teams in the Team Sidebar by following the user preferences if set.
larkox commented 1 month ago

@enahum Is this this ticket? https://mattermost.atlassian.net/browse/MM-60723

enahum commented 1 month ago

@enahum Is this this ticket? https://mattermost.atlassian.net/browse/MM-60723

@larkox seems to be the case

enahum commented 1 month ago

It looks fine, but one question before approving.

Are we positive o will always contain all teams? If not, we may "lose" teams with this change.

It should contain all of them. @hmhealey can you confirm?

hmhealey commented 1 month ago

I don't believe we keep that preference in sync with the user's teams. If I remember right, the preference is only updated when a user reoreders their teams, so:

  1. It starts empty even when the user is on
  2. If a user joins a team, that won't be added to the preference and will have to be placed automatically
  3. If a user leaves a team, that team won't be removed from the preference, so the app will have to be able to handle an ID corresponding to a team the user doesn't have access to

The web app function for handling this is here: https://github.com/mattermost/mattermost/blob/master/webapp/channels/src/utils/team_utils.tsx#L18

hmhealey commented 4 weeks ago

@enahum Did we address the case where the items in that array don't match the users' current teams? It doesn't seem like that was handled, so I don't think that the mobile app will show new teams that the user is added to now unless the user reorders their teams from the web app

enahum commented 4 weeks ago

@hmhealey you are saying that if:

  1. User orders the teams
  2. User is added to another team

The order preference is not updated and thus the team won't appear in the UI?

Please confirm this is the case, cause then is not handled and is also affecting other work I'm doing

enahum commented 4 weeks ago

@hmhealey additionally can you confirm if these newly added teams would show above or below the ones you already ordered manually.

If above that would be better I think, specially when you are in a looooooooooot of teams already.

hmhealey commented 3 weeks ago

@hmhealey you are saying that if:

1. User orders the teams

2. User is added to another team

The order preference is not updated and thus the team won't appear in the UI?

Please confirm this is the case, cause then is not handled and is also affecting other work I'm doing

I'm a bit late to reply, but yeah, that's correct.

@hmhealey additionally can you confirm if these newly added teams would show above or below the ones you already ordered manually.

The logic for that is in here. The order is:

  1. Any teams in the preference
  2. Any teams not in the preference, sorted alphabetically by display name
enahum commented 3 weeks ago

Changes for that here https://github.com/mattermost/mattermost-mobile/pull/8306