2022-03-11 19:39:42 +01:00

20 lines
587 B
TypeScript

import { GlobalState } from '../../global/types';
import { selectCurrentMessageList } from './messages';
import { selectChat } from './chats';
export function selectStatistics(global: GlobalState, chatId: string) {
return global.statistics.byChatId[chatId];
}
export function selectIsStatisticsShown(global: GlobalState) {
if (!global.isStatisticsShown) {
return false;
}
const { chatId: currentChatId } = selectCurrentMessageList(global) || {};
const chat = currentChatId ? selectChat(global, currentChatId) : undefined;
return chat?.fullInfo?.canViewStatistics;
}