[Perf] Clean-up invisible secondary sections

This commit is contained in:
Alexander Zinchuk 2021-06-24 14:46:15 +03:00
parent 3f5c8edceb
commit 73b1d105c3
6 changed files with 17 additions and 4 deletions

View File

@ -243,6 +243,8 @@ const LeftColumn: FC<StateProps & DispatchProps> = ({
name={IS_SINGLE_COLUMN_LAYOUT ? 'slide-layers' : 'push-slide'} name={IS_SINGLE_COLUMN_LAYOUT ? 'slide-layers' : 'push-slide'}
renderCount={RENDER_COUNT} renderCount={RENDER_COUNT}
activeKey={contentType} activeKey={contentType}
shouldCleanup
cleanupExceptionKey={ContentType.Main}
> >
{(isActive) => { {(isActive) => {
switch (contentType) { switch (contentType) {

View File

@ -122,7 +122,13 @@ const LeftMain: FC<OwnProps & StateProps> = ({
onReset={onReset} onReset={onReset}
/> />
<ConnectionState /> <ConnectionState />
<Transition name="zoom-fade" renderCount={TRANSITION_RENDER_COUNT} activeKey={content}> <Transition
name="zoom-fade"
renderCount={TRANSITION_RENDER_COUNT}
activeKey={content}
shouldCleanup
cleanupExceptionKey={LeftColumnContent.ChatList}
>
{(isActive) => { {(isActive) => {
switch (content) { switch (content) {
case LeftColumnContent.ChatList: case LeftColumnContent.ChatList:

View File

@ -63,7 +63,7 @@ const LeftSearch: FC<OwnProps & StateProps & DispatchProps> = ({
onReset, onReset,
}) => { }) => {
const lang = useLang(); const lang = useLang();
const [activeTab, setActiveTab] = useState(0); const [activeTab, setActiveTab] = useState(currentContent);
const dateSearchQuery = useMemo(() => parseDateString(searchQuery), [searchQuery]); const dateSearchQuery = useMemo(() => parseDateString(searchQuery), [searchQuery]);
const handleSwitchTab = useCallback((index: number) => { const handleSwitchTab = useCallback((index: number) => {

View File

@ -253,6 +253,8 @@ const RightColumn: FC<StateProps & DispatchProps> = ({
name={shouldSkipTransition ? 'none' : 'zoom-fade'} name={shouldSkipTransition ? 'none' : 'zoom-fade'}
renderCount={MAIN_SCREENS_COUNT + MANAGEMENT_SCREENS_COUNT} renderCount={MAIN_SCREENS_COUNT + MANAGEMENT_SCREENS_COUNT}
activeKey={isManagement ? MAIN_SCREENS_COUNT + managementScreen : renderingContentKey} activeKey={isManagement ? MAIN_SCREENS_COUNT + managementScreen : renderingContentKey}
shouldCleanup
cleanupExceptionKey={RightColumnContent.ChatInfo}
> >
{renderContent} {renderContent}
</Transition> </Transition>

View File

@ -25,6 +25,7 @@ type OwnProps = {
renderCount?: number; renderCount?: number;
shouldRestoreHeight?: boolean; shouldRestoreHeight?: boolean;
shouldCleanup?: boolean; shouldCleanup?: boolean;
cleanupExceptionKey?: number;
id?: string; id?: string;
className?: string; className?: string;
onStart?: () => void; onStart?: () => void;
@ -55,6 +56,7 @@ const Transition: FC<OwnProps> = ({
renderCount, renderCount,
shouldRestoreHeight, shouldRestoreHeight,
shouldCleanup, shouldCleanup,
cleanupExceptionKey,
id, id,
className, className,
onStart, onStart,
@ -85,7 +87,7 @@ const Transition: FC<OwnProps> = ({
useLayoutEffect(() => { useLayoutEffect(() => {
function cleanup() { function cleanup() {
if (!shouldCleanup) { if (!shouldCleanup || cleanupExceptionKey === prevActiveKey) {
return; return;
} }
@ -212,6 +214,7 @@ const Transition: FC<OwnProps> = ({
renderCount, renderCount,
shouldRestoreHeight, shouldRestoreHeight,
shouldCleanup, shouldCleanup,
cleanupExceptionKey,
animationLevel, animationLevel,
forceUpdate, forceUpdate,
]); ]);

View File

@ -19,7 +19,7 @@ import { setLanguage } from '../../../util/langProvider';
addReducer('apiUpdate', (global, actions, update: ApiUpdate) => { addReducer('apiUpdate', (global, actions, update: ApiUpdate) => {
if (DEBUG) { if (DEBUG) {
if (update['@type'] !== 'updateUserStatus') { if (update['@type'] !== 'updateUserStatus' && update['@type'] !== 'updateServerTimeOffset') {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('[GramJs] UPDATE', update['@type'], { update }); console.log('[GramJs] UPDATE', update['@type'], { update });
} }