From 9bdaa5fdbcaba03f005bfefea19c5a0410e5430f Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Tue, 8 Feb 2022 22:29:32 +0100 Subject: [PATCH] Transition, Right Column: Fix redundant "You must be admin" popup --- src/components/right/Profile.tsx | 3 +-- src/components/right/RightColumn.tsx | 1 - src/components/ui/Transition.tsx | 18 ++++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/components/right/Profile.tsx b/src/components/right/Profile.tsx index b17c5fa7c..d17c8a742 100644 --- a/src/components/right/Profile.tsx +++ b/src/components/right/Profile.tsx @@ -277,8 +277,7 @@ const Profile: FC = ({ function renderSharedMedia() { if (!viewportIds || !canRenderContents || !chatMessages) { - // This is just a single-frame delay, so we do not show spinner - const noSpinner = isFirstTab && viewportIds && !canRenderContents; + const noSpinner = isFirstTab && !canRenderContents; return (
diff --git a/src/components/right/RightColumn.tsx b/src/components/right/RightColumn.tsx index f48d65316..49ff71d8b 100644 --- a/src/components/right/RightColumn.tsx +++ b/src/components/right/RightColumn.tsx @@ -311,7 +311,6 @@ const RightColumn: FC = ({ renderCount={MAIN_SCREENS_COUNT + MANAGEMENT_SCREENS_COUNT} activeKey={isManagement ? MAIN_SCREENS_COUNT + managementScreen : renderingContentKey} shouldCleanup - cleanupExceptionKey={RightColumnContent.ChatInfo} > {renderContent} diff --git a/src/components/ui/Transition.tsx b/src/components/ui/Transition.tsx index 0b6cde979..88f765b77 100644 --- a/src/components/ui/Transition.tsx +++ b/src/components/ui/Transition.tsx @@ -36,8 +36,6 @@ export type TransitionProps = { children: ChildrenFn; }; -const CLEANED_UP = Symbol('CLEANED_UP'); - const classNames = { active: 'Transition__slide--active', }; @@ -67,7 +65,7 @@ const Transition: FC = ({ containerRef = ref; } - const rendersRef = useRef>({}); + const rendersRef = useRef>({}); const prevActiveKey = usePrevious(activeKey); const forceUpdate = useForceUpdate(); @@ -81,11 +79,14 @@ const Transition: FC = ({ useLayoutEffect(() => { function cleanup() { - if (!shouldCleanup || (cleanupExceptionKey !== undefined && cleanupExceptionKey === prevActiveKey)) { + if (!shouldCleanup) { return; } - rendersRef.current = { [prevActiveKey]: CLEANED_UP }; + const preservedRender = cleanupExceptionKey !== undefined ? rendersRef.current[cleanupExceptionKey] : undefined; + + rendersRef.current = preservedRender ? { [cleanupExceptionKey!]: preservedRender } : {}; + forceUpdate(); } @@ -251,11 +252,12 @@ const Transition: FC = ({ const contents = collection.map((key) => { const render = renders[key]; + if (!render) { + return undefined; + } return ( - typeof render === 'function' ? ( -
{render(key === activeKey, key === prevActiveKey, activeKey)}
- ) : undefined +
{render(key === activeKey, key === prevActiveKey, activeKey)}
); });