[MM-61958] Always fetch team unreads for current team on reconnect (#29529)

This commit is contained in:
Devin Binnie
2024-12-12 12:49:13 -05:00
committed by GitHub
parent a5a92d825a
commit c19e0ea0e7
2 changed files with 2 additions and 15 deletions
@@ -257,7 +257,7 @@ export function reconnect() {
}
const crtEnabled = isCollapsedThreadsEnabled(state);
dispatch(TeamActions.getMyTeamUnreads(crtEnabled, true));
dispatch(TeamActions.getMyTeamUnreads(crtEnabled));
if (crtEnabled) {
const teams = getMyTeams(state);
syncThreads(currentTeamId, currentUserId);
@@ -70,10 +70,7 @@ export function getMyTeams() {
});
}
// The argument skipCurrentTeam is a (not ideal) workaround for CRT mention counts. Unread mentions are stored in the reducer per
// team but we do not track unread mentions for DMs/GMs independently. This results in a bit of funky logic and edge case bugs
// that need workarounds like this. In the future we should fix the root cause with better APIs and redux state.
export function getMyTeamUnreads(collapsedThreads: boolean, skipCurrentTeam = false): ActionFuncAsync {
export function getMyTeamUnreads(collapsedThreads: boolean): ActionFuncAsync {
return async (dispatch, getState) => {
let unreads;
try {
@@ -84,16 +81,6 @@ export function getMyTeamUnreads(collapsedThreads: boolean, skipCurrentTeam = fa
return {error};
}
if (skipCurrentTeam) {
const currentTeamId = getCurrentTeamId(getState());
if (currentTeamId) {
const index = unreads.findIndex((member) => member.team_id === currentTeamId);
if (index >= 0) {
unreads.splice(index, 1);
}
}
}
dispatch(
{
type: TeamTypes.RECEIVED_MY_TEAM_UNREADS,