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

MM-39073: fixes threads unread tab #9047

Merged
merged 4 commits into from
Oct 7, 2021

Conversation

koox00
Copy link
Contributor

@koox00 koox00 commented Oct 5, 2021

Summary

Clicking on an unread thread sometimes made the thread disappear.
This happened because the getThread selector was looking in both all
threads and in unread threads to verify the thread exists in this team,
but if you landed at unread threads tab after a refresh you don't have
more than 5 threads in all threads reducer, and if you click a thread it
was getting removed from the unread reducer.

This commit fixes that by refactoring the getThread selector to use
getMyChannels selector to check if threads belong in a current
team's channel.

PS1: The number 5 is not random, we fetch 5 threads (no unread filter) at mount
so we get the counts.

PS2: There is still a way to have that buggy behavior even after this fix.
The scenario is if you have left a channel you don't get the threads
removed as of yet, so you could replicate the above buggy behavior in
that case.
Since we are going to fix this in a later task (threads will be removed
from "left" channels) I didn't bother to fix it as well.

Ticket Link

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

Release Note

NONE

Clicking on an unread thread sometimes made the thread disappear.
This happened because the getThread selector was looking in both all
threads and in unread threads to verify the thread exists in this team,
but if you landed at unread threads tab after a refresh you don't have
more than 5 threads in all threads reducer, and if you click a thread it
was getting removed from the unread reducer.

This commit fixes that by refactoring the getThread selector to use
user's current team channels to check if threads belong in a current
team's channel.

There is still a way to have that buggy behavior even after this fix.
The scenario is if you have left a channel you don't get the threads
removed as of yet, so you could replicate the above buggy behavior in
that case.
Since we are going to fix this in a later task (threads will be removed
from "left" channels) I didn't bother to fix it as well.
@koox00 koox00 added 2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester labels Oct 5, 2021
@koox00 koox00 added the Setup Cloud Test Server Setup a test server using Mattermost Cloud label Oct 5, 2021
@mm-cloud-bot
Copy link

No Kubernetes clusters available at the moment, please contact the Mattermost Cloud Team or wait a bit.

@mm-cloud-bot mm-cloud-bot removed the Setup Cloud Test Server Setup a test server using Mattermost Cloud label Oct 5, 2021
@koox00 koox00 added the Setup Cloud Test Server Setup a test server using Mattermost Cloud label Oct 5, 2021
Copy link
Member

@calebroseland calebroseland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great change!

@koox00 koox00 requested a review from jgilliam17 October 5, 2021 17:04
export const getThread: (state: GlobalState, threadId: $ID<UserThread> | undefined) => UserThread | null = createSelector(
'getThread',
getThreads,
(state: GlobalState) => getMyChannels(state).map((c) => c.id),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would also need its own memoization since it's returning a new array of channel IDs each time this is called, even if the state hasn't changed.

@koox00 koox00 requested a review from hmhealey October 6, 2021 09:59
@esethna esethna added this to the v6.1.0 milestone Oct 6, 2021
@koox00
Copy link
Contributor Author

koox00 commented Oct 7, 2021

@hmhealey, @jgilliam17 can you prioritize reviewing this PR? It's needed for this one as well #9082

@hmhealey hmhealey removed the 2: Dev Review Requires review by a core commiter label Oct 7, 2021
Copy link
Contributor

@jgilliam17 jgilliam17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @koox00
Tested, looks good to merge.

  • Verified opening older unread threads after refresh is working as expected; opening an unread thread that is lower on the unread tab list than top 5 threads - no longer disappear.

@jgilliam17 jgilliam17 added 4: Reviews Complete All reviewers have approved the pull request and removed 3: QA Review Requires review by a QA tester Setup Cloud Test Server Setup a test server using Mattermost Cloud labels Oct 7, 2021
@mm-cloud-bot
Copy link

Test server destroyed

@jgilliam17 jgilliam17 merged commit c8b8ac7 into mattermost:master Oct 7, 2021
@amyblais amyblais added Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation labels Oct 7, 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 Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation release-note-none
Projects
None yet
7 participants