Skip to content

Commit

Permalink
Merge pull request #33779 from Expensify/Rory-MuteUnread
Browse files Browse the repository at this point in the history
Don't treat muted reports as unread in LHN
  • Loading branch information
rlinoz authored Jan 24, 2024
2 parents 864e697 + 9c9c654 commit edf0fd0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
21 changes: 10 additions & 11 deletions src/components/LHNOptionsList/OptionRowLHN.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,17 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti
return null;
}

const isInFocusMode = viewMode === CONST.OPTION_MODE.COMPACT;
const textStyle = isFocused ? styles.sidebarLinkActiveText : styles.sidebarLinkText;
const textUnreadStyle = optionItem?.isUnread ? [textStyle, styles.sidebarLinkTextBold] : [textStyle];
const textUnreadStyle = optionItem?.isUnread && optionItem.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.MUTE ? [textStyle, styles.sidebarLinkTextBold] : [textStyle];
const displayNameStyle = [styles.optionDisplayName, styles.optionDisplayNameCompact, styles.pre, textUnreadStyle, style];
const alternateTextStyle =
viewMode === CONST.OPTION_MODE.COMPACT
? [textStyle, styles.optionAlternateText, styles.pre, styles.textLabelSupporting, styles.optionAlternateTextCompact, styles.ml2, style]
: [textStyle, styles.optionAlternateText, styles.pre, styles.textLabelSupporting, style];
const alternateTextStyle = isInFocusMode
? [textStyle, styles.optionAlternateText, styles.pre, styles.textLabelSupporting, styles.optionAlternateTextCompact, styles.ml2, style]
: [textStyle, styles.optionAlternateText, styles.pre, styles.textLabelSupporting, style];

const contentContainerStyles =
viewMode === CONST.OPTION_MODE.COMPACT ? [styles.flex1, styles.flexRow, styles.overflowHidden, StyleUtils.getCompactContentContainerStyles()] : [styles.flex1];
const contentContainerStyles = isInFocusMode ? [styles.flex1, styles.flexRow, styles.overflowHidden, StyleUtils.getCompactContentContainerStyles()] : [styles.flex1];
const sidebarInnerRowStyle = StyleSheet.flatten<ViewStyle>(
viewMode === CONST.OPTION_MODE.COMPACT
isInFocusMode
? [styles.chatLinkRowPressable, styles.flexGrow1, styles.optionItemAvatarNameWrapper, styles.optionRowCompact, styles.justifyContentCenter]
: [styles.chatLinkRowPressable, styles.flexGrow1, styles.optionItemAvatarNameWrapper, styles.optionRow, styles.justifyContentCenter],
);
Expand Down Expand Up @@ -175,13 +174,13 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti
backgroundColor={hovered && !isFocused ? hoveredBackgroundColor : subscriptAvatarBorderColor}
mainAvatar={optionItem.icons?.[0]}
secondaryAvatar={optionItem.icons?.[1]}
size={viewMode === CONST.OPTION_MODE.COMPACT ? CONST.AVATAR_SIZE.SMALL : CONST.AVATAR_SIZE.DEFAULT}
size={isInFocusMode ? CONST.AVATAR_SIZE.SMALL : CONST.AVATAR_SIZE.DEFAULT}
/>
) : (
<MultipleAvatars
icons={optionItem.icons ?? []}
isFocusMode={viewMode === CONST.OPTION_MODE.COMPACT}
size={viewMode === CONST.OPTION_MODE.COMPACT ? CONST.AVATAR_SIZE.SMALL : CONST.AVATAR_SIZE.DEFAULT}
isFocusMode={isInFocusMode}
size={isInFocusMode ? CONST.AVATAR_SIZE.SMALL : CONST.AVATAR_SIZE.DEFAULT}
secondAvatarStyle={[
StyleUtils.getBackgroundAndBorderStyle(theme.sidebar),
isFocused ? StyleUtils.getBackgroundAndBorderStyle(focusedBackgroundColor) : undefined,
Expand Down
3 changes: 2 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ type OptionData = {
parentReportAction?: OnyxEntry<ReportAction>;
displayNamesWithTooltips?: DisplayNameWithTooltips | null;
descriptiveText?: string;
notificationPreference?: NotificationPreference | null;
isDisabled?: boolean | null;
name?: string | null;
} & Report;
Expand Down Expand Up @@ -3789,7 +3790,7 @@ function shouldReportBeInOptionList({

// All unread chats (even archived ones) in GSD mode will be shown. This is because GSD mode is specifically for focusing the user on the most relevant chats, primarily, the unread ones
if (isInGSDMode) {
return isUnread(report);
return isUnread(report) && report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.MUTE;
}

// Archived reports should always be shown when in default (most recent) mode. This is because you should still be able to access and search for the chats to find them.
Expand Down
1 change: 1 addition & 0 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ function getOrderedReportIDs(
const isInGSDMode = priorityMode === CONST.PRIORITY_MODE.GSD;
const isInDefaultMode = !isInGSDMode;
const allReportsDictValues = Object.values(allReports);

// Filter out all the reports that shouldn't be displayed
let reportsToDisplay = allReportsDictValues.filter((report) => {
const parentReportActionsKey = `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.parentReportID}`;
Expand Down
6 changes: 5 additions & 1 deletion src/libs/UnreadIndicatorUpdater/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ export default function getUnreadReportsForUnreadIndicator(reports: OnyxCollecti
* Chats with hidden preference remain invisible in the LHN and are not considered "unread."
* They are excluded from the LHN rendering, but not filtered from the "option list."
* This ensures they appear in Search, but not in the LHN or unread count.
*
* Furthermore, muted reports may or may not appear in the LHN depending on priority mode,
* but they should not be considered in the unread indicator count.
*/
report?.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
report?.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN &&
report?.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.MUTE,
);
}

Expand Down
3 changes: 3 additions & 0 deletions src/pages/home/sidebar/SidebarLinksData.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import useLocalize from '@hooks/useLocalize';
import usePrevious from '@hooks/usePrevious';
import useThemeStyles from '@hooks/useThemeStyles';
import compose from '@libs/compose';
import * as ReportUtils from '@libs/ReportUtils';
import SidebarUtils from '@libs/SidebarUtils';
import reportPropTypes from '@pages/reportPropTypes';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -172,6 +173,7 @@ const chatReportSelector = (report) =>
hasDraft: report.hasDraft,
isPinned: report.isPinned,
isHidden: report.isHidden,
notificationPreference: report.notificationPreference,
errorFields: {
addWorkspaceRoom: report.errorFields && report.errorFields.addWorkspaceRoom,
},
Expand Down Expand Up @@ -201,6 +203,7 @@ const chatReportSelector = (report) =>
parentReportActionID: report.parentReportActionID,
parentReportID: report.parentReportID,
isDeletedParentAction: report.isDeletedParentAction,
isUnreadWithMention: ReportUtils.isUnreadWithMention(report),
};

/**
Expand Down

0 comments on commit edf0fd0

Please sign in to comment.