Skip to content

Commit

Permalink
small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham1206agra committed Sep 25, 2023
1 parent ee69b18 commit dc67364
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/pages/home/sidebar/SidebarLinks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable rulesdir/onyx-props-must-have-default */
import React, {useEffect, useRef} from 'react';
import React, {useEffect, useRef, useCallback} from 'react';
import {View} from 'react-native';
import _ from 'underscore';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -45,7 +45,6 @@ const propTypes = {

isLoading: PropTypes.bool.isRequired,

// eslint-disable-next-line react/require-default-props
priorityMode: PropTypes.oneOf(_.values(CONST.PRIORITY_MODE)),

isActiveReport: PropTypes.func.isRequired,
Expand Down Expand Up @@ -106,32 +105,35 @@ function SidebarLinks({onLinkClick, insets, optionListItems, isLoading, priority
};
}, []);

const showSearchPage = () => {
const showSearchPage = useCallback(() => {
if (isCreateMenuOpen) {
// Prevent opening Search page when click Search icon quickly after clicking FAB icon
return;
}

Navigation.navigate(ROUTES.SEARCH);
};
}, [isCreateMenuOpen]);

/**
* Show Report page with selected report id
*
* @param {Object} option
* @param {String} option.reportID
*/
const showReportPage = (option) => {
// Prevent opening Report page when clicking LHN row quickly after clicking FAB icon
// or when clicking the active LHN row on large screens
// or when continuously clicking different LHNs, only apply to small screen
// since getTopmostReportId always returns on other devices
if (isCreateMenuOpen || (!isSmallScreenWidth && isActiveReport(option.reportID)) || (isSmallScreenWidth && Navigation.getTopmostReportId())) {
return;
}
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(option.reportID));
onLinkClick();
}
const showReportPage = useCallback(
(option) => {
// Prevent opening Report page when clicking LHN row quickly after clicking FAB icon
// or when clicking the active LHN row on large screens
// or when continuously clicking different LHNs, only apply to small screen
// since getTopmostReportId always returns on other devices
if (isCreateMenuOpen || (!isSmallScreenWidth && isActiveReport(option.reportID)) || (isSmallScreenWidth && Navigation.getTopmostReportId())) {
return;
}
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(option.reportID));
onLinkClick();
},
[isCreateMenuOpen, isSmallScreenWidth, isActiveReport, onLinkClick],
);

const viewMode = priorityMode === CONST.PRIORITY_MODE.GSD ? CONST.OPTION_MODE.COMPACT : CONST.OPTION_MODE.DEFAULT;

Expand All @@ -144,7 +146,7 @@ function SidebarLinks({onLinkClick, insets, optionListItems, isLoading, priority
<Header
title={
<LogoComponent
fill={defaultTheme.textLight}
fill={defaultTheme.text}
width={variables.lhnLogoWidth}
height={variables.lhnLogoHeight}
/>
Expand Down

0 comments on commit dc67364

Please sign in to comment.