[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'}
renderCount={RENDER_COUNT}
activeKey={contentType}
shouldCleanup
cleanupExceptionKey={ContentType.Main}
>
{(isActive) => {
switch (contentType) {

View File

@ -122,7 +122,13 @@ const LeftMain: FC<OwnProps & StateProps> = ({
onReset={onReset}
/>
<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) => {
switch (content) {
case LeftColumnContent.ChatList:

View File

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

View File

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

View File

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

View File

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