From b2357773e9b5d101a6f50293d8b004e59d044048 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 19 Mar 2024 22:46:06 +0700 Subject: [PATCH 1/2] fix: An extra space is created at the top of the chat list when pinning and unpinning --- src/components/LHNOptionsList/OptionRowLHN.tsx | 10 +++++----- src/libs/SidebarUtils.ts | 10 ++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index 923337ba9ada..eca9f728da30 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -55,12 +55,12 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti const hasBrickError = optionItem.brickRoadIndicator === CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR; const shouldShowGreenDotIndicator = !hasBrickError && ReportUtils.requiresAttentionFromCurrentUser(optionItem, optionItem.parentReportAction); - const isHidden = optionItem.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; + // const isHidden = optionItem.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; - const shouldOverrideHidden = hasBrickError || isFocused || optionItem.isPinned; - if (isHidden && !shouldOverrideHidden) { - return null; - } + // const shouldOverrideHidden = hasBrickError || isFocused || optionItem.isPinned; + // if (isHidden && !shouldOverrideHidden) { + // return null; + // } const isInFocusMode = viewMode === CONST.OPTION_MODE.COMPACT; const textStyle = isFocused ? styles.sidebarLinkActiveText : styles.sidebarLinkText; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 7bf163416054..8377a339ffff 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -79,9 +79,19 @@ function getOrderedReportIDs( let reportsToDisplay = allReportsDictValues.filter((report) => { const parentReportActionsKey = `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.parentReportID}`; const parentReportActions = allReportActions?.[parentReportActionsKey]; + const reportActions = ReportActionsUtils.getAllReportActions(report.reportID); const parentReportAction = parentReportActions?.find((action) => action && report && action?.reportActionID === report?.parentReportActionID); const doesReportHaveViolations = betas.includes(CONST.BETAS.VIOLATIONS) && !!parentReportAction && ReportUtils.doesTransactionThreadHaveViolations(report, transactionViolations, parentReportAction); + const isHidden = report?.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; + const isFocused = report?.reportID === currentReportId; + const hasErrors = Object.keys(OptionsListUtils.getAllReportErrors(report, reportActions) ?? {}).length !== 0; + const hasBrickError = hasErrors || doesReportHaveViolations ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''; + const shouldOverrideHidden = hasBrickError || isFocused || report.isPinned; + if (isHidden && !shouldOverrideHidden) { + return false; + } + return ReportUtils.shouldReportBeInOptionList({ report, currentReportId: currentReportId ?? '', From b16cef4686f79920f675901fe60202e226e9a04e Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 20 Mar 2024 09:50:28 +0700 Subject: [PATCH 2/2] remove useless code --- src/components/LHNOptionsList/OptionRowLHN.tsx | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index eca9f728da30..5065d1cc7c13 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -54,14 +54,6 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti const hasBrickError = optionItem.brickRoadIndicator === CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR; const shouldShowGreenDotIndicator = !hasBrickError && ReportUtils.requiresAttentionFromCurrentUser(optionItem, optionItem.parentReportAction); - - // const isHidden = optionItem.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; - - // const shouldOverrideHidden = hasBrickError || isFocused || optionItem.isPinned; - // if (isHidden && !shouldOverrideHidden) { - // return null; - // } - const isInFocusMode = viewMode === CONST.OPTION_MODE.COMPACT; const textStyle = isFocused ? styles.sidebarLinkActiveText : styles.sidebarLinkText; const textUnreadStyle = optionItem?.isUnread && optionItem.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.MUTE ? [textStyle, styles.sidebarLinkTextBold] : [textStyle];