Seen By: Use config values from the API (#1671)
This commit is contained in:
parent
f6573a7ceb
commit
4033c5b3e6
@ -15,6 +15,8 @@ type GramJsAppConfig = {
|
|||||||
groupcall_video_participants_max: number;
|
groupcall_video_participants_max: number;
|
||||||
reactions_default: string;
|
reactions_default: string;
|
||||||
reactions_uniq_max: number;
|
reactions_uniq_max: number;
|
||||||
|
chat_read_mark_size_threshold: number;
|
||||||
|
chat_read_mark_expire_period: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
function buildEmojiSounds(appConfig: GramJsAppConfig) {
|
function buildEmojiSounds(appConfig: GramJsAppConfig) {
|
||||||
@ -42,5 +44,7 @@ export function buildApiConfig(json: GramJs.TypeJSONValue): ApiAppConfig {
|
|||||||
return {
|
return {
|
||||||
emojiSounds: buildEmojiSounds(appConfig),
|
emojiSounds: buildEmojiSounds(appConfig),
|
||||||
defaultReaction: appConfig.reactions_default,
|
defaultReaction: appConfig.reactions_default,
|
||||||
|
seenByMaxChatMembers: appConfig.chat_read_mark_size_threshold,
|
||||||
|
seenByExpiresAt: appConfig.chat_read_mark_expire_period,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -127,6 +127,8 @@ export interface ApiCountryCode extends ApiCountry {
|
|||||||
export interface ApiAppConfig {
|
export interface ApiAppConfig {
|
||||||
emojiSounds: Record<string, string>;
|
emojiSounds: Record<string, string>;
|
||||||
defaultReaction: string;
|
defaultReaction: string;
|
||||||
|
seenByMaxChatMembers: number;
|
||||||
|
seenByExpiresAt: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GramJsEmojiInteraction {
|
export interface GramJsEmojiInteraction {
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import {
|
|||||||
isActionMessage, isChatChannel,
|
isActionMessage, isChatChannel,
|
||||||
isChatGroup, isOwnMessage, areReactionsEmpty, isUserId,
|
isChatGroup, isOwnMessage, areReactionsEmpty, isUserId,
|
||||||
} from '../../../modules/helpers';
|
} 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 { getDayStartAt } from '../../../util/dateFormat';
|
||||||
import { copyTextToClipboard } from '../../../util/clipboard';
|
import { copyTextToClipboard } from '../../../util/clipboard';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransition from '../../../hooks/useShowTransition';
|
||||||
@ -409,6 +409,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
const { threadId } = selectCurrentMessageList(global) || {};
|
const { threadId } = selectCurrentMessageList(global) || {};
|
||||||
const activeDownloads = selectActiveDownloadIds(global, message.chatId);
|
const activeDownloads = selectActiveDownloadIds(global, message.chatId);
|
||||||
const chat = selectChat(global, message.chatId);
|
const chat = selectChat(global, message.chatId);
|
||||||
|
const { seenByExpiresAt, seenByMaxChatMembers } = global.appConfig || {};
|
||||||
const {
|
const {
|
||||||
noOptions,
|
noOptions,
|
||||||
canReply,
|
canReply,
|
||||||
@ -429,12 +430,14 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
const isScheduled = messageListType === 'scheduled';
|
const isScheduled = messageListType === 'scheduled';
|
||||||
const isChannel = chat && isChatChannel(chat);
|
const isChannel = chat && isChatChannel(chat);
|
||||||
const canShowSeenBy = Boolean(chat
|
const canShowSeenBy = Boolean(chat
|
||||||
|
&& seenByMaxChatMembers
|
||||||
|
&& seenByExpiresAt
|
||||||
&& isChatGroup(chat)
|
&& isChatGroup(chat)
|
||||||
&& isOwnMessage(message)
|
&& isOwnMessage(message)
|
||||||
&& !isScheduled
|
&& !isScheduled
|
||||||
&& chat.membersCount
|
&& chat.membersCount
|
||||||
&& chat.membersCount < SEEN_BY_MEMBERS_CHAT_MAX
|
&& chat.membersCount < seenByMaxChatMembers
|
||||||
&& message.date > Date.now() / 1000 - SEEN_BY_MEMBERS_EXPIRE);
|
&& message.date > Date.now() / 1000 - seenByExpiresAt);
|
||||||
const isPrivate = chat && isUserId(chat.id);
|
const isPrivate = chat && isUserId(chat.id);
|
||||||
const isAction = isActionMessage(message);
|
const isAction = isActionMessage(message);
|
||||||
const canShowReactionsCount = !isChannel && !isScheduled && !isAction && !isPrivate && message.reactions
|
const canShowReactionsCount = !isChannel && !isScheduled && !isAction && !isPrivate && message.reactions
|
||||||
|
|||||||
@ -176,9 +176,6 @@ export const LIGHT_THEME_BG_COLOR = '#A2AF8E';
|
|||||||
export const DARK_THEME_BG_COLOR = '#0F0F0F';
|
export const DARK_THEME_BG_COLOR = '#0F0F0F';
|
||||||
export const DARK_THEME_PATTERN_COLOR = '#0a0a0a8c';
|
export const DARK_THEME_PATTERN_COLOR = '#0a0a0a8c';
|
||||||
export const DEFAULT_PATTERN_COLOR = 'rgba(90, 110, 70, 0.6)';
|
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
|
// Group calls
|
||||||
export const GROUP_CALL_VOLUME_MULTIPLIER = 100;
|
export const GROUP_CALL_VOLUME_MULTIPLIER = 100;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user