mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-12 00:59:52 +01:00
Sticker Tooltip: Clean input; Emoji Tooltip: Save to recent (#1305)
This commit is contained in:
parent
bedd7727cd
commit
bf6c6ef035
@ -538,7 +538,7 @@ const Composer: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
resetComposer, stopRecordingVoice, showDialog, slowMode, isAdmin, sendMessage, forwardMessages, lang,
|
resetComposer, stopRecordingVoice, showDialog, slowMode, isAdmin, sendMessage, forwardMessages, lang,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const handleStickerSelect = useCallback((sticker: ApiSticker) => {
|
const handleStickerSelect = useCallback((sticker: ApiSticker, shouldPreserveInput = false) => {
|
||||||
sticker = {
|
sticker = {
|
||||||
...sticker,
|
...sticker,
|
||||||
isPreloadedGlobally: true,
|
isPreloadedGlobally: true,
|
||||||
@ -549,7 +549,7 @@ const Composer: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
openCalendar();
|
openCalendar();
|
||||||
} else {
|
} else {
|
||||||
sendMessage({ sticker });
|
sendMessage({ sticker });
|
||||||
requestAnimationFrame(() => { resetComposer(true); });
|
requestAnimationFrame(() => { resetComposer(shouldPreserveInput); });
|
||||||
}
|
}
|
||||||
}, [shouldSchedule, openCalendar, sendMessage, resetComposer]);
|
}, [shouldSchedule, openCalendar, sendMessage, resetComposer]);
|
||||||
|
|
||||||
|
@ -105,6 +105,11 @@ const EmojiTooltip: FC<OwnProps> = ({
|
|||||||
}
|
}
|
||||||
}, [addRecentEmoji, emojis, onEmojiSelect, selectedIndex]);
|
}, [addRecentEmoji, emojis, onEmojiSelect, selectedIndex]);
|
||||||
|
|
||||||
|
const handleClick = useCallback((native: string, id: string) => {
|
||||||
|
onEmojiSelect(native);
|
||||||
|
addRecentEmoji({ emoji: id });
|
||||||
|
}, [addRecentEmoji, onEmojiSelect]);
|
||||||
|
|
||||||
useEffect(() => (isOpen ? captureKeyboardListeners({
|
useEffect(() => (isOpen ? captureKeyboardListeners({
|
||||||
onEsc: onClose,
|
onEsc: onClose,
|
||||||
onLeft: (e: KeyboardEvent) => handleArrowKey(-1, e),
|
onLeft: (e: KeyboardEvent) => handleArrowKey(-1, e),
|
||||||
@ -138,7 +143,7 @@ const EmojiTooltip: FC<OwnProps> = ({
|
|||||||
key={emoji.id}
|
key={emoji.id}
|
||||||
emoji={emoji}
|
emoji={emoji}
|
||||||
focus={selectedIndex === index}
|
focus={selectedIndex === index}
|
||||||
onClick={onEmojiSelect}
|
onClick={handleClick}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
) : shouldRender ? (
|
) : shouldRender ? (
|
||||||
|
@ -32,7 +32,7 @@ export type OwnProps = {
|
|||||||
onLoad: () => void;
|
onLoad: () => void;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
onEmojiSelect: (emoji: string) => void;
|
onEmojiSelect: (emoji: string) => void;
|
||||||
onStickerSelect: (sticker: ApiSticker) => void;
|
onStickerSelect: (sticker: ApiSticker, shouldPreserveInput?: boolean) => void;
|
||||||
onGifSelect: (gif: ApiVideo) => void;
|
onGifSelect: (gif: ApiVideo) => void;
|
||||||
onRemoveSymbol: () => void;
|
onRemoveSymbol: () => void;
|
||||||
onSearchOpen: (type: 'stickers' | 'gifs') => void;
|
onSearchOpen: (type: 'stickers' | 'gifs') => void;
|
||||||
@ -114,6 +114,10 @@ const SymbolMenu: FC<OwnProps & StateProps> = ({
|
|||||||
onSearchOpen(type);
|
onSearchOpen(type);
|
||||||
}, [onClose, onSearchOpen]);
|
}, [onClose, onSearchOpen]);
|
||||||
|
|
||||||
|
const handleStickerSelect = useCallback((sticker: ApiSticker) => {
|
||||||
|
onStickerSelect(sticker, true);
|
||||||
|
}, [onStickerSelect]);
|
||||||
|
|
||||||
const lang = useLang();
|
const lang = useLang();
|
||||||
|
|
||||||
const { canSendStickers, canSendGifs } = allowedAttachmentOptions;
|
const { canSendStickers, canSendGifs } = allowedAttachmentOptions;
|
||||||
@ -133,7 +137,7 @@ const SymbolMenu: FC<OwnProps & StateProps> = ({
|
|||||||
className="picker-tab"
|
className="picker-tab"
|
||||||
loadAndPlay={canSendStickers ? isOpen && (isActive || isFrom) : false}
|
loadAndPlay={canSendStickers ? isOpen && (isActive || isFrom) : false}
|
||||||
canSendStickers={canSendStickers}
|
canSendStickers={canSendStickers}
|
||||||
onStickerSelect={onStickerSelect}
|
onStickerSelect={handleStickerSelect}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case SymbolMenuTabs.GIFs:
|
case SymbolMenuTabs.GIFs:
|
||||||
|
Loading…
Reference in New Issue
Block a user