Composer: Various fixes for emoji keywords

This commit is contained in:
Alexander Zinchuk 2021-07-14 20:43:37 +03:00
parent d15dc909e2
commit e355ea4d08
4 changed files with 14 additions and 13 deletions

View File

@ -18,7 +18,7 @@ import {
} from '../../../api/types';
import { LangCode } from '../../../types';
import { 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 {
selectChat,
@ -31,7 +31,6 @@ import {
selectEditingMessage,
selectIsChatWithSelf,
selectChatUser,
selectEmojiKeywords,
} from '../../../modules/selectors';
import {
getAllowedAttachmentOptions,
@ -233,11 +232,13 @@ const Composer: FC<OwnProps & StateProps & DispatchProps> = ({
}, [isReady, chatId, loadScheduledHistory, lastSyncTime, threadId]);
useEffect(() => {
loadEmojiKeywords({ language: 'en' });
if (language !== 'en') {
loadEmojiKeywords({ language });
if (lastSyncTime && isReady) {
loadEmojiKeywords({ language: BASE_EMOJI_KEYWORD_LANG });
if (language !== BASE_EMOJI_KEYWORD_LANG) {
loadEmojiKeywords({ language });
}
}
}, [loadEmojiKeywords, language]);
}, [loadEmojiKeywords, language, lastSyncTime, isReady]);
useLayoutEffect(() => {
if (!appendixRef.current) return;
@ -939,8 +940,8 @@ export default memo(withGlobal<OwnProps>(
const messageWithActualBotKeyboard = isChatWithBot && selectNewestMessageWithBotKeyboardButtons(global, chatId);
const scheduledIds = selectScheduledIds(global, chatId);
const { language } = global.settings.byKey;
const baseEmojiKeywords = selectEmojiKeywords(global, 'en');
const emojiKeywords = language !== 'en' ? selectEmojiKeywords(global, language) : undefined;
const baseEmojiKeywords = global.emojiKeywords[BASE_EMOJI_KEYWORD_LANG];
const emojiKeywords = language !== BASE_EMOJI_KEYWORD_LANG ? global.emojiKeywords[language] : undefined;
return {
editingMessage: selectEditingMessage(global, chatId, threadId, messageListType),

View File

@ -112,9 +112,10 @@ export const STICKER_SIZE_FOLDER_SETTINGS = 80;
export const RECENT_STICKERS_LIMIT = 20;
export const MEMOJI_STICKER_ID = 'MEMOJI_STICKER';
export const BASE_EMOJI_KEYWORD_LANG = 'en';
export const MENU_TRANSITION_DURATION = 200;
export const SLIDE_TRANSITION_DURATION = 450;
export const LAYERS_TRANSITION_DURATION = 450;
export const CONTENT_TYPES_FOR_QUICK_UPLOAD = 'image/png,image/gif,image/jpeg,video/mp4,video/avi,video/quicktime';

View File

@ -141,7 +141,6 @@ function updateCache() {
'contactList',
'topPeers',
'recentEmojis',
'emojiKeywords',
'push',
'shouldShowContextMenuHint',
]),

View File

@ -13,7 +13,7 @@ import {
rebuildStickersForEmoji,
} from '../../reducers';
import searchWords from '../../../util/searchWords';
import { selectEmojiKeywords, selectStickerSet } from '../../selectors';
import { selectStickerSet } from '../../selectors';
const ADDED_SETS_THROTTLE = 500;
const ADDED_SETS_THROTTLE_CHUNK = 50;
@ -112,8 +112,8 @@ addReducer('toggleStickerSet', (global, actions, payload) => {
addReducer('loadEmojiKeywords', (global, actions, payload: { language: LangCode }) => {
const { language } = payload;
let currentEmojiKeywords = selectEmojiKeywords(global, language);
let currentEmojiKeywords = global.emojiKeywords[language];
if (currentEmojiKeywords && currentEmojiKeywords.isLoading) {
return;
}
@ -136,7 +136,7 @@ addReducer('loadEmojiKeywords', (global, actions, payload: { language: LangCode
});
global = getGlobal();
currentEmojiKeywords = selectEmojiKeywords(global, language);
currentEmojiKeywords = global.emojiKeywords[language];
if (!emojiKeywords) {
setGlobal({