[Perf] Do not load emoji keywords on each chat opening
This commit is contained in:
parent
60acbc2f02
commit
69b9394a18
@ -8,7 +8,7 @@ import { ApiMessage } from '../../api/types';
|
|||||||
|
|
||||||
import '../../modules/actions/all';
|
import '../../modules/actions/all';
|
||||||
import {
|
import {
|
||||||
ANIMATION_END_DELAY, DEBUG, INACTIVE_MARKER, PAGE_TITLE,
|
ANIMATION_END_DELAY, BASE_EMOJI_KEYWORD_LANG, DEBUG, INACTIVE_MARKER, PAGE_TITLE,
|
||||||
} from '../../config';
|
} from '../../config';
|
||||||
import { pick } from '../../util/iteratees';
|
import { pick } from '../../util/iteratees';
|
||||||
import {
|
import {
|
||||||
@ -36,6 +36,7 @@ import SafeLinkModal from './SafeLinkModal.async';
|
|||||||
import HistoryCalendar from './HistoryCalendar.async';
|
import HistoryCalendar from './HistoryCalendar.async';
|
||||||
|
|
||||||
import './Main.scss';
|
import './Main.scss';
|
||||||
|
import { LangCode } from '../../types';
|
||||||
|
|
||||||
type StateProps = {
|
type StateProps = {
|
||||||
animationLevel: number;
|
animationLevel: number;
|
||||||
@ -50,11 +51,12 @@ type StateProps = {
|
|||||||
safeLinkModalUrl?: string;
|
safeLinkModalUrl?: string;
|
||||||
isHistoryCalendarOpen: boolean;
|
isHistoryCalendarOpen: boolean;
|
||||||
shouldSkipHistoryAnimations?: boolean;
|
shouldSkipHistoryAnimations?: boolean;
|
||||||
|
language?: LangCode;
|
||||||
};
|
};
|
||||||
|
|
||||||
type DispatchProps = Pick<GlobalActions, (
|
type DispatchProps = Pick<GlobalActions, (
|
||||||
'loadAnimatedEmojis' | 'loadNotificationSettings' | 'loadNotificationExceptions' | 'updateIsOnline' |
|
'loadAnimatedEmojis' | 'loadNotificationSettings' | 'loadNotificationExceptions' | 'updateIsOnline' |
|
||||||
'loadTopInlineBots'
|
'loadTopInlineBots' | 'loadEmojiKeywords'
|
||||||
)>;
|
)>;
|
||||||
|
|
||||||
const ANIMATION_DURATION = 350;
|
const ANIMATION_DURATION = 350;
|
||||||
@ -78,11 +80,13 @@ const Main: FC<StateProps & DispatchProps> = ({
|
|||||||
safeLinkModalUrl,
|
safeLinkModalUrl,
|
||||||
isHistoryCalendarOpen,
|
isHistoryCalendarOpen,
|
||||||
shouldSkipHistoryAnimations,
|
shouldSkipHistoryAnimations,
|
||||||
|
language,
|
||||||
loadAnimatedEmojis,
|
loadAnimatedEmojis,
|
||||||
loadNotificationSettings,
|
loadNotificationSettings,
|
||||||
loadNotificationExceptions,
|
loadNotificationExceptions,
|
||||||
updateIsOnline,
|
updateIsOnline,
|
||||||
loadTopInlineBots,
|
loadTopInlineBots,
|
||||||
|
loadEmojiKeywords,
|
||||||
}) => {
|
}) => {
|
||||||
if (DEBUG && !DEBUG_isLogged) {
|
if (DEBUG && !DEBUG_isLogged) {
|
||||||
DEBUG_isLogged = true;
|
DEBUG_isLogged = true;
|
||||||
@ -98,10 +102,15 @@ const Main: FC<StateProps & DispatchProps> = ({
|
|||||||
loadNotificationSettings();
|
loadNotificationSettings();
|
||||||
loadNotificationExceptions();
|
loadNotificationExceptions();
|
||||||
loadTopInlineBots();
|
loadTopInlineBots();
|
||||||
|
|
||||||
|
loadEmojiKeywords({ language: BASE_EMOJI_KEYWORD_LANG });
|
||||||
|
if (language !== BASE_EMOJI_KEYWORD_LANG) {
|
||||||
|
loadEmojiKeywords({ language });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
lastSyncTime, loadAnimatedEmojis, loadNotificationExceptions, loadNotificationSettings, updateIsOnline,
|
lastSyncTime, loadAnimatedEmojis, loadNotificationExceptions, loadNotificationSettings, updateIsOnline,
|
||||||
loadTopInlineBots,
|
loadTopInlineBots, loadEmojiKeywords, language,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -244,10 +253,11 @@ export default memo(withGlobal(
|
|||||||
safeLinkModalUrl: global.safeLinkModalUrl,
|
safeLinkModalUrl: global.safeLinkModalUrl,
|
||||||
isHistoryCalendarOpen: Boolean(global.historyCalendarSelectedAt),
|
isHistoryCalendarOpen: Boolean(global.historyCalendarSelectedAt),
|
||||||
shouldSkipHistoryAnimations: global.shouldSkipHistoryAnimations,
|
shouldSkipHistoryAnimations: global.shouldSkipHistoryAnimations,
|
||||||
|
language: global.settings.byKey.language,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
(setGlobal, actions): DispatchProps => pick(actions, [
|
(setGlobal, actions): DispatchProps => pick(actions, [
|
||||||
'loadAnimatedEmojis', 'loadNotificationSettings', 'loadNotificationExceptions', 'updateIsOnline',
|
'loadAnimatedEmojis', 'loadNotificationSettings', 'loadNotificationExceptions', 'updateIsOnline',
|
||||||
'loadTopInlineBots',
|
'loadTopInlineBots', 'loadEmojiKeywords',
|
||||||
]),
|
]),
|
||||||
)(Main));
|
)(Main));
|
||||||
|
|||||||
@ -18,7 +18,7 @@ import {
|
|||||||
ApiUser,
|
ApiUser,
|
||||||
MAIN_THREAD_ID,
|
MAIN_THREAD_ID,
|
||||||
} from '../../../api/types';
|
} from '../../../api/types';
|
||||||
import { LangCode, InlineBotSettings } from '../../../types';
|
import { InlineBotSettings } from '../../../types';
|
||||||
|
|
||||||
import { BASE_EMOJI_KEYWORD_LANG, EDITABLE_INPUT_ID, SCHEDULED_WHEN_ONLINE } from '../../../config';
|
import { BASE_EMOJI_KEYWORD_LANG, EDITABLE_INPUT_ID, SCHEDULED_WHEN_ONLINE } from '../../../config';
|
||||||
import { IS_VOICE_RECORDING_SUPPORTED, IS_SINGLE_COLUMN_LAYOUT, IS_IOS } from '../../../util/environment';
|
import { IS_VOICE_RECORDING_SUPPORTED, IS_SINGLE_COLUMN_LAYOUT, IS_IOS } from '../../../util/environment';
|
||||||
@ -124,7 +124,6 @@ type StateProps = {
|
|||||||
lastSyncTime?: number;
|
lastSyncTime?: number;
|
||||||
contentToBeScheduled?: GlobalState['messages']['contentToBeScheduled'];
|
contentToBeScheduled?: GlobalState['messages']['contentToBeScheduled'];
|
||||||
shouldSuggestStickers?: boolean;
|
shouldSuggestStickers?: boolean;
|
||||||
language: LangCode;
|
|
||||||
baseEmojiKeywords?: Record<string, string[]>;
|
baseEmojiKeywords?: Record<string, string[]>;
|
||||||
emojiKeywords?: Record<string, string[]>;
|
emojiKeywords?: Record<string, string[]>;
|
||||||
serverTimeOffset: number;
|
serverTimeOffset: number;
|
||||||
@ -137,7 +136,7 @@ type DispatchProps = Pick<GlobalActions, (
|
|||||||
'sendMessage' | 'editMessage' | 'saveDraft' | 'forwardMessages' |
|
'sendMessage' | 'editMessage' | 'saveDraft' | 'forwardMessages' |
|
||||||
'clearDraft' | 'showDialog' | 'setStickerSearchQuery' | 'setGifSearchQuery' |
|
'clearDraft' | 'showDialog' | 'setStickerSearchQuery' | 'setGifSearchQuery' |
|
||||||
'openPollModal' | 'closePollModal' | 'loadScheduledHistory' | 'openChat' | 'closePaymentModal' |
|
'openPollModal' | 'closePollModal' | 'loadScheduledHistory' | 'openChat' | 'closePaymentModal' |
|
||||||
'clearReceipt' | 'addRecentEmoji' | 'loadEmojiKeywords' | 'sendInlineBotResult'
|
'clearReceipt' | 'addRecentEmoji' | 'sendInlineBotResult'
|
||||||
)>;
|
)>;
|
||||||
|
|
||||||
enum MainButtonState {
|
enum MainButtonState {
|
||||||
@ -188,7 +187,6 @@ const Composer: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
lastSyncTime,
|
lastSyncTime,
|
||||||
contentToBeScheduled,
|
contentToBeScheduled,
|
||||||
shouldSuggestStickers,
|
shouldSuggestStickers,
|
||||||
language,
|
|
||||||
baseEmojiKeywords,
|
baseEmojiKeywords,
|
||||||
emojiKeywords,
|
emojiKeywords,
|
||||||
serverTimeOffset,
|
serverTimeOffset,
|
||||||
@ -210,7 +208,6 @@ const Composer: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
openChat,
|
openChat,
|
||||||
clearReceipt,
|
clearReceipt,
|
||||||
addRecentEmoji,
|
addRecentEmoji,
|
||||||
loadEmojiKeywords,
|
|
||||||
sendInlineBotResult,
|
sendInlineBotResult,
|
||||||
}) => {
|
}) => {
|
||||||
const lang = useLang();
|
const lang = useLang();
|
||||||
@ -242,15 +239,6 @@ const Composer: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
}
|
}
|
||||||
}, [isReady, chatId, loadScheduledHistory, lastSyncTime, threadId]);
|
}, [isReady, chatId, loadScheduledHistory, lastSyncTime, threadId]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (lastSyncTime && isReady) {
|
|
||||||
loadEmojiKeywords({ language: BASE_EMOJI_KEYWORD_LANG });
|
|
||||||
if (language !== BASE_EMOJI_KEYWORD_LANG) {
|
|
||||||
loadEmojiKeywords({ language });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [loadEmojiKeywords, language, lastSyncTime, isReady]);
|
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (!appendixRef.current) return;
|
if (!appendixRef.current) return;
|
||||||
|
|
||||||
@ -1038,7 +1026,6 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
isReceiptModalOpen: Boolean(global.payment.receipt),
|
isReceiptModalOpen: Boolean(global.payment.receipt),
|
||||||
shouldSuggestStickers: global.settings.byKey.shouldSuggestStickers,
|
shouldSuggestStickers: global.settings.byKey.shouldSuggestStickers,
|
||||||
recentEmojis: global.recentEmojis,
|
recentEmojis: global.recentEmojis,
|
||||||
language,
|
|
||||||
baseEmojiKeywords: baseEmojiKeywords ? baseEmojiKeywords.keywords : undefined,
|
baseEmojiKeywords: baseEmojiKeywords ? baseEmojiKeywords.keywords : undefined,
|
||||||
emojiKeywords: emojiKeywords ? emojiKeywords.keywords : undefined,
|
emojiKeywords: emojiKeywords ? emojiKeywords.keywords : undefined,
|
||||||
serverTimeOffset: global.serverTimeOffset,
|
serverTimeOffset: global.serverTimeOffset,
|
||||||
@ -1062,7 +1049,6 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
'loadScheduledHistory',
|
'loadScheduledHistory',
|
||||||
'openChat',
|
'openChat',
|
||||||
'addRecentEmoji',
|
'addRecentEmoji',
|
||||||
'loadEmojiKeywords',
|
|
||||||
'sendInlineBotResult',
|
'sendInlineBotResult',
|
||||||
]),
|
]),
|
||||||
)(Composer));
|
)(Composer));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user