Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: defaultMinimalEmojis not rendering correctly #1935

Closed
tomSidebar opened this issue Feb 11, 2023 · 4 comments · Fixed by #1947
Closed

bug: defaultMinimalEmojis not rendering correctly #1935

tomSidebar opened this issue Feb 11, 2023 · 4 comments · Fixed by #1947
Labels
bug Something isn't working cluster:emoji Issues related to use of emojis released status:confirmed Described issue has been reproduced by the repo maintainer

Comments

@tomSidebar
Copy link

tomSidebar commented Feb 11, 2023

Describe the bug

I am trying to add an emoji to the list of default message reactions. I followed Stream's official guide and also followed this bug report. I was able to add the extra emoji but then the fetched list of defaultMinimalEmojis is not rendering at all (with the exception of the angry emoji, see the screenshot below). The reaction counts are showing up correctly though and you can still react/unreact, it's just that the emojis themselves are not getting rendered.

My basic setup is as follows:

import { defaultMinimalEmojis } from "stream-chat-react/dist/components/Channel/emojiData";

export const customReactions = [
  {
    colons: ":bulb:",
    emoticons: [],
    id: "bulb",
    name: "Bulb",
    native: "💡",
    skin: null,
    unified: "1F4A1",
  },
  ...defaultMinimalEmojis,
];

export const CustomReactionSelector = forwardRef(
  (props: ReactionSelectorProps<DefaultStreamChatGenerics>) => {
    const { reactionSelectorRef } = useMessageContext();

    return (
      <ReactionSelector
        {...props}
        reactionOptions={customReactions}
        ref={reactionSelectorRef}
      />
    );
  }
);
CustomReactionSelector.displayName = "CustomReactionSelector";

export const CustomReactionsList = <
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
>(
  props: ReactionsListProps<StreamChatGenerics>
) => {
  return <ReactionsList {...props} reactionOptions={customReactions} />;
};

<Channel
            ...
            ReactionsList={CustomReactionsList}
            ReactionSelector={CustomReactionSelector}
>

I also tried hardcoding the emojis based on different emoji options they have in their code base: from emojiData.ts, from utils.ts and from SocialReactionList.tsx. None of those steps worked.

Long story short, how do I get the default emojis to show up? Or is there a way to fetch them from somewhere else?

To Reproduce

See the description above.

Expected behavior

I want the default emojis to show up correctly.

Screenshots

Screenshot 2023-02-10 at 6 47 36 PM

Package version

  • stream-chat-react: 9.5.0

Desktop (please complete the following information):

  • OS: macOS Ventura 13.1
  • Browser Chrome
@tomSidebar tomSidebar added bug Something isn't working status: unconfirmed labels Feb 11, 2023
@arnautov-anton
Copy link
Contributor

arnautov-anton commented Feb 13, 2023

Hey @tomSidebar, thank you for submitting the issue - just tested it myself and the implementation of custom reactions is quite unintuitive and with our current setup does not allow the combination of Stream-selected reactions and your custom ones due to different sprites used to render these.

If you're fine with ditching our pre-selected reactions with custom id's then all you need to do is provide list of valid reaction id's from stream-emoji.json (keys from "emojis" object).

Screenshot 2023-02-13 at 1 39 59 PM

You'd then do something like this:

const customReactions = [
  { id: '100' },
  { id: '1234' },
  { id: 'grinning' },
  // ...other emojis if you want
];

// pass it down to your custom components (exactly how you did it in your snippet)

Which would look something like this:
image

And the data that represents it will look something like this (notice the type property which holds your selected reaction id's):
image

This would mean that all of the previously submitted reactions which were stored under our custom id's (defaultMinimalEmojis) won't be displayed anymore as there's no mapping functionality.

Edit: I was able to find "aliases" key which allows us to map our custom id's to EmojiMart's valid counterparts.

I'm currently working on a fix (and documentation adjustment) that should resolve this issue and allow integrators to use the combination of our default minimal emoji set and their custom sets - if everything goes according to plan, we should be able to release the fix by the end of this week.

Hope this helps, thanks again. Let me know if you have any other questions.

@arnautov-anton arnautov-anton added status:confirmed Described issue has been reproduced by the repo maintainer and removed status: unconfirmed labels Feb 13, 2023
@tomSidebar
Copy link
Author

Thanks for the explanation! Ideally we'd want the previous reactions to persist with this the addition of the extra emoji, so it sounds like your suggested fix will not quite fit our use case.

But that's great news with the proposed fix, that should resolve our issue. Thank you for working on that, looking forward to using that!

@arnautov-anton
Copy link
Contributor

Hey, @tomSidebar, after drafting a "patchy" solution and talking to the team we decided to go an extra mile and redesign the API as the drafted solution - while easier - is also, unfortunately, a breaking change. So if we're going to introduce a breaking change, then we'd like to be sure that we don't have to tamper with it any more in the future. The new solution should be much simpler, easy to transition to and easy to modify if needed. I'll attach this issue to the new PR once it's drafted so you can keep up with the progress.

@MartinCupela MartinCupela added the cluster:emoji Issues related to use of emojis label Apr 18, 2023
arnautov-anton added a commit that referenced this issue Nov 27, 2023
BREAKING CHANGE: `reactionOptions` signature has changed, see release
guide for more information

### 🎯 Goal

Refactor and fix the way reactions work, introduce new way of
customizing with better DX.

Fixes: #1935
Closes: #1637
Closes: #1437
Closes: #2159
Closes:
GetStream/stream-chat-react-native#2023

### 🛠 Implementation details

- ditch EmojiMart implementation, use native/sprite-sheet solution
arnautov-anton added a commit that referenced this issue Nov 27, 2023
BREAKING CHANGE: `reactionOptions` signature has changed, see [release
guide](https://github.com/GetStream/stream-chat-react/blob/v11.0.0/docusaurus/docs/React/release-guides/upgrade-to-v11.mdx) for more information

Refactor and fix the way reactions work, introduce new way of
customizing with better DX.

Fixes: #1935
Closes: #1637
Closes: #1437
Closes: #2159
Closes:
GetStream/stream-chat-react-native#2023

- ditch EmojiMart implementation, use native/sprite-sheet solution
arnautov-anton added a commit that referenced this issue Nov 27, 2023
Refactor and fix the way reactions work, introduce new way of
customizing with better DX.

Fixes: #1935
Closes: #1637
Closes: #1437
Closes: #2159
Closes:
GetStream/stream-chat-react-native#2023

- ditch EmojiMart implementation, use native/sprite-sheet solution

BREAKING CHANGE: `reactionOptions` signature has changed, see [release guide](https://github.com/GetStream/stream-chat-react/blob/v11.0.0/docusaurus/docs/React/release-guides/upgrade-to-v11.mdx) for more information
github-actions bot pushed a commit that referenced this issue Nov 27, 2023
## [11.0.0](v10.20.1...v11.0.0) (2023-11-27)

### ⚠ BREAKING CHANGES

* **emoji-mart:** `EmojiPicker` & `EmojiIndex` signatures changed, `EmojiIndex` has been renamed to `emojiSearchIndex`, both `EmojiPicker` & `emojiSearchIndex` are now optional, see [release guide](https://github.com/GetStream/stream-chat-react/blob/v11.0.0/docusaurus/docs/React/release-guides/upgrade-to-v11.mdx) for more information
* **emoji-mart:** `useImageFlagEmojisOnWindow` flag now requires extra style sheet import, see [release guide](https://github.com/GetStream/stream-chat-react/blob/v11.0.0/docusaurus/docs/React/release-guides/upgrade-to-v11.mdx) for more information
* **emoji-mart:** `reactionOptions` signature has changed, see [release guide](https://github.com/GetStream/stream-chat-react/blob/v11.0.0/docusaurus/docs/React/release-guides/upgrade-to-v11.mdx) for more information
* the first argument to `doSendMessageRequest` is now Channel instance instead of `Channel.cid`
* apply the remark plugins `keepLineBreaksPlugin`, `htmlToTextPlugin` as a part of the default message text parsing, upgrade `unified` libraries

### Bug Fixes

* **emoji-mart:** new reactions  ([#1947](#1947)) ([14bef23](14bef23)), closes [#1935](#1935) [#1637](#1637) [#1437](#1437) [#2159](#2159)
* **emoji-mart:** simplify EmojiPicker & emojiSearchIndex ([#2117](#2117)) ([a6e0a87](a6e0a87)), closes [#2116](#2116) [#2094](#2094)

### Features

* apply keepLineBreaksPlugin & htmlToTextPlugin plugins to text rendering by default ([#2169](#2169)) ([e8047f2](e8047f2)), closes [#2170](#2170) [/github.com/GetStream/stream-chat-react/blob/f0bc7ba2532760cabb1db01e685a35bd3b0b64c5/src/components/Message/renderText/renderText.tsx#L158](https://github.com/GetStream//github.com/GetStream/stream-chat-react/blob/f0bc7ba2532760cabb1db01e685a35bd3b0b64c5/src/components/Message/renderText/renderText.tsx/issues/L158)
* export MessageListNotifications and LinkPreviewList components and component props ([#2181](#2181)) ([a5a7e5a](a5a7e5a))
* require Channel instance as the first argument to doSendMessageRequest ([#2171](#2171)) ([2a06b88](2a06b88))

### Chores

* **deps:** bump stream-chat from 8.14.0 to 8.14.2 ([#2179](#2179)) ([4e6a59d](4e6a59d))
* **deps:** bump stream-chat from 8.14.2 to 8.14.3 ([#2185](#2185)) ([3dd8dab](3dd8dab))
@stream-ci-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 11.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cluster:emoji Issues related to use of emojis released status:confirmed Described issue has been reproduced by the repo maintainer
Projects
None yet
4 participants