From b71a97e11f38b7147c47ab598a455d9e993ec9d4 Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Thu, 21 Nov 2019 14:36:28 +0800 Subject: [PATCH] fix: intelligent toggle --- src/components/SideBar.tsx | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/components/SideBar.tsx b/src/components/SideBar.tsx index ffe9643..a2966dc 100644 --- a/src/components/SideBar.tsx +++ b/src/components/SideBar.tsx @@ -50,15 +50,19 @@ const RawGitako: React.FC = function RawGitako(props) { [props.disabled, configContext.val.shortcut], ) - useOnLocationChange(() => { - if (configContext.val.intelligentToggle === null) { - props.setShouldShow( - URLHelper.isInCodePage({ - branchName: props.metaData?.branchName, - }), - ) - } - }, [props.metaData?.branchName, configContext.val.intelligentToggle]) + const updateSideBarVisibility = React.useCallback( + function updateSideBarVisibility() { + if (configContext.val.intelligentToggle === null) { + props.setShouldShow( + URLHelper.isInCodePage({ + branchName: props.metaData?.branchName, + }), + ) + } + }, + [props.metaData?.branchName, configContext.val.intelligentToggle], + ) + useEvent('pjax:complete', updateSideBarVisibility, window) const attachCopyFileButton = React.useCallback( function attachCopyFileButton() {