From 2a5b9f5f25b4b5fdfb60c21b4edcd9dd20dbda5d Mon Sep 17 00:00:00 2001
From: SpiritCroc <dev@spiritcroc.de>
Date: Wed, 29 May 2024 19:32:42 +0200
Subject: Squashed: Freeform reactions from tadzik/freeform-reactions-upstream
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

commit 9eea56b0080db3720efa49b457707bcde3be6474
Merge: 06f81c9662 8570f16e31
Author: Tadeusz Sośnierz <tadeusz@sosnierz.com>
Date:   Tue Jun 20 09:57:19 2023 +0200

    Merge branch 'develop' into tadzik/freeform-reactions-upstream

commit 06f81c9662fbe033b4eac859d7e14e0ab24a6e91
Merge: ad4fef85b1 0d6a550c33
Author: Michael Telatynski <7t3chguy@gmail.com>
Date:   Wed Aug 31 09:06:49 2022 +0100

    Merge branch 'develop' into tadzik/freeform-reactions

commit ad4fef85b160087b8017b9ae9cf9aebfd5348f41
Merge: 689b57c0b9 5aae974e93
Author: Tadeusz Sośnierz <tadzik@tadzik.net>
Date:   Sun Aug 28 10:11:48 2022 +0200

    Merge branch 'develop' into tadzik/freeform-reactions

commit 689b57c0b91e12907a8dbc3fac3ed10302a11e4a
Author: Tadeusz Sośnierz <tadeusz@sosnierz.com>
Date:   Fri May 20 10:35:06 2022 +0200

    Fix conflict resolution fail in EmojiPicker

commit 70a8e212b748584949b37bc99b72acffce2fd148
Merge: 215df55f13 a0cdc93642
Author: Tadeusz Sośnierz <tadeusz@sosnierz.com>
Date:   Fri May 20 10:25:17 2022 +0200

    Merge branch 'develop' into tadzik/freeform-reactions-upstream

commit 215df55f13162bdc8eb13da5219763c56f560dd0
Author: Tadeusz Sośnierz <tadeusz@sosnierz.com>
Date:   Tue Aug 17 16:30:06 2021 +0200

    Disable freeform emoji reactions in the message composer

commit 6bb8263007e077d22929fcc1fb439d94a4f15c6f
Author: Tadeusz Sośnierz <tadeusz@sosnierz.com>
Date:   Tue Aug 17 12:12:28 2021 +0200

    Add more typing to EmojiPicker

commit b2a1728318a8a5496345797995c1ec09ae3f88e6
Author: Tadeusz Sośnierz <tadeusz@sosnierz.com>
Date:   Tue Aug 17 11:52:35 2021 +0200

    Make free-form reaction button translatable

commit f4adaf00b805baba454fbceb41cc5c081ec886a7
Author: Tadeusz Sośnierz <tadeusz@sosnierz.com>
Date:   Tue Aug 17 11:29:22 2021 +0200

    Allow sending free-form reactions

    Signed-off-by: Tadeusz Sośnierz <tadeusz@sosnierz.com>
---
 src/components/views/emojipicker/EmojiPicker.tsx | 16 ++++++++++++++++
 .../views/emojipicker/ReactionPicker.tsx         |  1 +
 2 files changed, 17 insertions(+)

diff --git a/src/components/views/emojipicker/EmojiPicker.tsx b/src/components/views/emojipicker/EmojiPicker.tsx
index 71659d579b..4acbfd1fcb 100644
--- a/src/components/views/emojipicker/EmojiPicker.tsx
+++ b/src/components/views/emojipicker/EmojiPicker.tsx
@@ -29,6 +29,8 @@ import { Key } from "../../../Keyboard";
 import { clamp } from "../../../utils/numbers";
 import { type ButtonEvent } from "../elements/AccessibleButton";
 
+import AccessibleButton from '../elements/AccessibleButton';
+
 export const CATEGORY_HEADER_HEIGHT = 20;
 export const EMOJI_HEIGHT = 35;
 export const EMOJIS_PER_ROW = 8;
@@ -36,6 +38,7 @@ export const EMOJIS_PER_ROW = 8;
 const ZERO_WIDTH_JOINER = "\u200D";
 
 interface IProps {
+    allowUnlisted?: boolean;
     selectedEmojis?: Set<string>;
     onChoose(unicode: string): boolean;
     onFinished(): void;
@@ -337,6 +340,10 @@ class EmojiPicker extends React.Component<IProps, IState> {
         }
     };
 
+    private reactWith = (reaction: string): void => {
+        this.props.onChoose(reaction);
+    };
+
     private static categoryHeightForEmojiCount(count: number): number {
         if (count === 0) {
             return 0;
@@ -392,6 +399,15 @@ class EmojiPicker extends React.Component<IProps, IState> {
                                     return categoryElement;
                                 })}
                             </AutoHideScrollbar>
+                            {
+                                (this.props.allowUnlisted && this.state.filter) &&
+                                    <AccessibleButton
+                                        kind="link"
+                                        onClick={() => this.reactWith(this.state.filter)}
+                                    >
+                                        { _t('React with "%(reaction)s"', { reaction: this.state.filter }) }
+                                    </AccessibleButton>
+                            }
                             {this.state.previewEmoji ? (
                                 <Preview emoji={this.state.previewEmoji} />
                             ) : (
diff --git a/src/components/views/emojipicker/ReactionPicker.tsx b/src/components/views/emojipicker/ReactionPicker.tsx
index 11b3d9468a..7d369945fe 100644
--- a/src/components/views/emojipicker/ReactionPicker.tsx
+++ b/src/components/views/emojipicker/ReactionPicker.tsx
@@ -126,6 +126,7 @@ class ReactionPicker extends React.Component<IProps, IState> {
     public render(): React.ReactNode {
         return (
             <EmojiPicker
+                allowUnlisted={true}
                 onChoose={this.onChoose}
                 isEmojiDisabled={this.isEmojiDisabled}
                 onFinished={this.props.onFinished}
-- 
2.49.0

