Code Monkey home page Code Monkey logo

Comments (8)

nuno-vieira avatar nuno-vieira commented on August 12, 2024 1

No problem @borut-t 👍

from stream-chat-swift.

nuno-vieira avatar nuno-vieira commented on August 12, 2024

Hi @borut-t,

We have an example of Slack Reactions in our Slack Demo App. Here is an example: https://github.com/GetStream/stream-chat-swift/blob/develop/Examples/SlackClone/SlackReactionsView.swift,

In order to load all reactions you will need to use the ChatMessageController.loadReactions and ChatMessageController.loadNextReactions for that.

Thanks,
Nuno

from stream-chat-swift.

nuno-vieira avatar nuno-vieira commented on August 12, 2024

I'm closing this one for now. Feel free to re-open the issue if you are still having troubles.

Best,
Nuno

from stream-chat-swift.

borut-t avatar borut-t commented on August 12, 2024

@nuno-vieira thanks for the example. I was looking at the example and could not find the point where app loads reactions.
However, when examining the code and trying to understand how this works, I got a bit worried. You've mentioned I should call loadReactions/loadNextReactions APIs in order to fetch reactions. And this is a bit concerning to me. Loading all reactions for every message while user scrolls through messages will be certainly a sluggish experience.

And I'm not really sure how I can do that using swiftui's ChatChannelView which loads all messages for me.

I'm also looking at this code

        reactions = content.reactionScores.map {
            let userReactionIDs = Set(content.currentUserReactions.map(\.type))
            return ChatMessageReactionData(
                type: $0.key,
                score: $0.value,
                isChosenByCurrentUser: userReactionIDs.contains($0.key)
            )
        }
        .sorted(by: components.reactionsSorting)

Does it mean I could load reactions from ChatMessage.reactionScores?

Can you elaborate a bit?

from stream-chat-swift.

nuno-vieira avatar nuno-vieira commented on August 12, 2024

Hi @borut-t, each message has reactionScores and reactionCounts which might be enough for you. But if you want to have the full details of the reactions, like for example the author, you will need to use loadReactions and loadNextReactions. Usually reactionScores and reactionCounts is enough to display the data in the message list. But if you want the full details, usually you tap on the reactions and it opens a detail view containing all info of the reaction, like the author etc...

from stream-chat-swift.

borut-t avatar borut-t commented on August 12, 2024

Hi @nuno-vieira. Thanks for the feedback!

The thing is that you have a limitation of 30 characters for the MessageReactionType rawValue. And this blocks me from storing emoji names since the length can easily surpass this limitation. I cannot store the unicode value either since no special characters are allowed.

let emoji = 😅
let emojiUnicode = "\u{0001F605}" // not allowed for rawValue
let emojiName = "SMILING FACE WITH OPEN MOUTH AND COLD SWEAT" // too long for rawValue

I have tried with a hashing function but with this approach using reactionsScores I don't have access to the extraData.

What would you suggest in this case?

from stream-chat-swift.

nuno-vieira avatar nuno-vieira commented on August 12, 2024

Hi @borut-t, I think for now your only option might be using the code inside \u{XXXXXX}, and then in your application, you wrap it with \u{}. If that is not enough for you for some reason, you might need to open a ticket on support to request this change in the backend.

Best,
Nuno

from stream-chat-swift.

borut-t avatar borut-t commented on August 12, 2024

I've managed to make this work exactly like that. Now everything works. One issue is still not solvable with this approach and that is the sorting. We are now sorting based on the ChatReactionType. Not optimal, but not a big issue.
Thanks @nuno-vieira for all your help 🙌

from stream-chat-swift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.