Seen By: Use config values from the API (#1671)

This commit is contained in:
Alexander Zinchuk 2022-01-26 23:29:22 +01:00
parent f6573a7ceb
commit 4033c5b3e6
4 changed files with 12 additions and 6 deletions

View File

@ -15,6 +15,8 @@ type GramJsAppConfig = {
groupcall_video_participants_max: number;
reactions_default: string;
reactions_uniq_max: number;
chat_read_mark_size_threshold: number;
chat_read_mark_expire_period: number;
};
function buildEmojiSounds(appConfig: GramJsAppConfig) {
@ -42,5 +44,7 @@ export function buildApiConfig(json: GramJs.TypeJSONValue): ApiAppConfig {
return {
emojiSounds: buildEmojiSounds(appConfig),
defaultReaction: appConfig.reactions_default,
seenByMaxChatMembers: appConfig.chat_read_mark_size_threshold,
seenByExpiresAt: appConfig.chat_read_mark_expire_period,
};
}

View File

@ -127,6 +127,8 @@ export interface ApiCountryCode extends ApiCountry {
export interface ApiAppConfig {
emojiSounds: Record<string, string>;
defaultReaction: string;
seenByMaxChatMembers: number;
seenByExpiresAt: number;
}
export interface GramJsEmojiInteraction {

View File

@ -17,7 +17,7 @@ import {
isActionMessage, isChatChannel,
isChatGroup, isOwnMessage, areReactionsEmpty, isUserId,
} from '../../../modules/helpers';
import { SEEN_BY_MEMBERS_EXPIRE, SEEN_BY_MEMBERS_CHAT_MAX, SERVICE_NOTIFICATIONS_USER_ID } from '../../../config';
import { SERVICE_NOTIFICATIONS_USER_ID } from '../../../config';
import { getDayStartAt } from '../../../util/dateFormat';
import { copyTextToClipboard } from '../../../util/clipboard';
import useShowTransition from '../../../hooks/useShowTransition';
@ -409,6 +409,7 @@ export default memo(withGlobal<OwnProps>(
const { threadId } = selectCurrentMessageList(global) || {};
const activeDownloads = selectActiveDownloadIds(global, message.chatId);
const chat = selectChat(global, message.chatId);
const { seenByExpiresAt, seenByMaxChatMembers } = global.appConfig || {};
const {
noOptions,
canReply,
@ -429,12 +430,14 @@ export default memo(withGlobal<OwnProps>(
const isScheduled = messageListType === 'scheduled';
const isChannel = chat && isChatChannel(chat);
const canShowSeenBy = Boolean(chat
&& seenByMaxChatMembers
&& seenByExpiresAt
&& isChatGroup(chat)
&& isOwnMessage(message)
&& !isScheduled
&& chat.membersCount
&& chat.membersCount < SEEN_BY_MEMBERS_CHAT_MAX
&& message.date > Date.now() / 1000 - SEEN_BY_MEMBERS_EXPIRE);
&& chat.membersCount < seenByMaxChatMembers
&& message.date > Date.now() / 1000 - seenByExpiresAt);
const isPrivate = chat && isUserId(chat.id);
const isAction = isActionMessage(message);
const canShowReactionsCount = !isChannel && !isScheduled && !isAction && !isPrivate && message.reactions

View File

@ -176,9 +176,6 @@ export const LIGHT_THEME_BG_COLOR = '#A2AF8E';
export const DARK_THEME_BG_COLOR = '#0F0F0F';
export const DARK_THEME_PATTERN_COLOR = '#0a0a0a8c';
export const DEFAULT_PATTERN_COLOR = 'rgba(90, 110, 70, 0.6)';
// TODO Get values from `getConfig` method once it's available
export const SEEN_BY_MEMBERS_CHAT_MAX = 50;
export const SEEN_BY_MEMBERS_EXPIRE = 604680; // One week - 2 min
// Group calls
export const GROUP_CALL_VOLUME_MULTIPLIER = 100;