Enable React with any Emoji

This commit is contained in:
Ken Powers 2020-06-03 14:36:17 -04:00 committed by Scott Nonnenberg
parent d4ee1d4133
commit 480e1808ba
3 changed files with 26 additions and 36 deletions

View File

@ -15,8 +15,6 @@ try {
// Derive profile key versions, then use those to fetch versioned profiles from server
window.VERSIONED_PROFILE_FETCH = false;
// Enable full emoji picker for reactions
window.REACT_ANY_EMOJI = false;
window.PROTO_ROOT = 'protos';
const config = require('url').parse(window.location.toString(), true).query;

View File

@ -21,10 +21,7 @@ export type OwnProps = {
export type Props = OwnProps & Pick<React.HTMLProps<HTMLDivElement>, 'style'>;
const emojis = ['❤️', '👍', '👎', '😂', '😮', '😢', '😡'];
const getEmojis = () =>
emojis.slice(0, window.REACT_ANY_EMOJI ? emojis.length - 1 : emojis.length);
const emojis = ['❤️', '👍', '👎', '😂', '😮', '😢'];
export const ReactionPicker = React.forwardRef<HTMLDivElement, Props>(
({ i18n, selected, onClose, onPick, renderEmojiPicker, style }, ref) => {
@ -57,13 +54,13 @@ export const ReactionPicker = React.forwardRef<HTMLDivElement, Props>(
// Focus first button and restore focus on unmount
useRestoreFocus(focusRef);
const otherSelected = selected && !getEmojis().includes(selected);
const otherSelected = selected && !emojis.includes(selected);
return pickingOther ? (
renderEmojiPicker({ onPickEmoji, onClose, style, ref })
) : (
<div ref={ref} style={style} className="module-reaction-picker">
{getEmojis().map((emoji, index) => {
{emojis.map((emoji, index) => {
const maybeFocusRef = index === 0 ? focusRef : undefined;
return (
@ -89,31 +86,29 @@ export const ReactionPicker = React.forwardRef<HTMLDivElement, Props>(
</button>
);
})}
{window.REACT_ANY_EMOJI ? (
<button
className={classNames(
'module-reaction-picker__emoji-btn',
otherSelected
? 'module-reaction-picker__emoji-btn--selected'
: 'module-reaction-picker__emoji-btn--more'
)}
onClick={e => {
e.stopPropagation();
if (otherSelected && selected) {
onPick(selected);
} else {
setPickingOther(true);
}
}}
title={i18n('ReactionsViewer--more')}
>
{otherSelected ? (
<div className="module-reaction-picker__emoji-btn__emoji">
<Emoji size={48} emoji={selected} />
</div>
) : null}
</button>
) : null}
<button
className={classNames(
'module-reaction-picker__emoji-btn',
otherSelected
? 'module-reaction-picker__emoji-btn--selected'
: 'module-reaction-picker__emoji-btn--more'
)}
onClick={e => {
e.stopPropagation();
if (otherSelected && selected) {
onPick(selected);
} else {
setPickingOther(true);
}
}}
title={i18n('ReactionsViewer--more')}
>
{otherSelected ? (
<div className="module-reaction-picker__emoji-btn__emoji">
<Emoji size={48} emoji={selected} />
</div>
) : null}
</button>
</div>
);
}

3
ts/window.d.ts vendored
View File

@ -47,9 +47,6 @@ declare global {
ConversationController: ConversationControllerType;
WebAPI: WebAPIConnectType;
Whisper: WhisperType;
// Flags
REACT_ANY_EMOJI: boolean;
}
}