mirror of
https://github.com/danog/telegram-tt.git
synced 2024-11-30 04:39:00 +01:00
Statistics: Better animation when switching to message statistics (#1882)
This commit is contained in:
parent
dc69997bd3
commit
3300d71e5d
@ -276,7 +276,7 @@ const RightColumn: FC<StateProps> = ({
|
||||
);
|
||||
|
||||
case RightColumnContent.Statistics:
|
||||
return <Statistics chatId={chatId!} isActive={isOpen && isActive} />;
|
||||
return <Statistics chatId={chatId!} />;
|
||||
case RightColumnContent.MessageStatistics:
|
||||
return <MessageStatistics chatId={chatId!} isActive={isOpen && isActive} />;
|
||||
case RightColumnContent.StickerSearch:
|
||||
@ -319,6 +319,7 @@ const RightColumn: FC<StateProps> = ({
|
||||
renderCount={MAIN_SCREENS_COUNT + MANAGEMENT_SCREENS_COUNT}
|
||||
activeKey={isManagement ? MAIN_SCREENS_COUNT + managementScreen : renderingContentKey}
|
||||
shouldCleanup
|
||||
cleanupExceptionKey={renderingContentKey === RightColumnContent.MessageStatistics ? RightColumnContent.Statistics : undefined}
|
||||
>
|
||||
{renderContent}
|
||||
</Transition>
|
||||
|
@ -61,23 +61,19 @@ const GROUP_GRAPHS = Object.keys(GROUP_GRAPHS_TITLES) as (keyof ApiGroupStatisti
|
||||
|
||||
export type OwnProps = {
|
||||
chatId: string;
|
||||
isActive: boolean;
|
||||
};
|
||||
|
||||
export type StateProps = {
|
||||
statistics: ApiChannelStatistics | ApiGroupStatistics;
|
||||
dcId?: number;
|
||||
isGroup: boolean;
|
||||
messageId?: number;
|
||||
};
|
||||
|
||||
const Statistics: FC<OwnProps & StateProps> = ({
|
||||
chatId,
|
||||
isActive,
|
||||
statistics,
|
||||
dcId,
|
||||
isGroup,
|
||||
messageId,
|
||||
}) => {
|
||||
const lang = useLang();
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
@ -92,13 +88,6 @@ const Statistics: FC<OwnProps & StateProps> = ({
|
||||
loadStatistics({ chatId, isGroup });
|
||||
}, [chatId, loadStatistics, isGroup]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isActive) {
|
||||
loadedCharts.current = [];
|
||||
setIsReady(false);
|
||||
}
|
||||
}, [isActive]);
|
||||
|
||||
const graphs = useMemo(() => {
|
||||
return isGroup ? GROUP_GRAPHS : CHANNEL_GRAPHS;
|
||||
}, [isGroup]);
|
||||
@ -179,7 +168,7 @@ const Statistics: FC<OwnProps & StateProps> = ({
|
||||
graphs, graphTitles, isReady, statistics, lang, chatId, loadStatisticsAsyncGraph, dcId, forceUpdate,
|
||||
]);
|
||||
|
||||
if (!isReady || !statistics || messageId) {
|
||||
if (!isReady || !statistics) {
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
@ -214,11 +203,9 @@ export default memo(withGlobal<OwnProps>(
|
||||
const chat = selectChat(global, chatId);
|
||||
const dcId = chat?.fullInfo?.statisticsDcId;
|
||||
const isGroup = chat?.type === 'chatTypeSuperGroup';
|
||||
// Show Loading component if message was already selected for improving transition animation
|
||||
const messageId = global.statistics.currentMessageId;
|
||||
|
||||
return {
|
||||
statistics, dcId, isGroup, messageId,
|
||||
statistics, dcId, isGroup,
|
||||
};
|
||||
},
|
||||
)(Statistics));
|
||||
|
Loading…
Reference in New Issue
Block a user