Skip to content

How to get media elements? #6

@rahmanharoon

Description

@rahmanharoon

I have tried this code and i also done image upload feature,

Here is the messages data am getting:

{
createdAt: Thu Dec 23 2021 12:56:23 GMT+0530 (India Standard Time) {}
received: true
text: "Hai"
user: {_id: "Ghost", name: "Ghost"}
_id: '1'
}, 
{
createdAt: Thu Dec 23 2021 12:56:23 GMT+0530 (India Standard Time) {}
received: true
text: null
user: {_id: "Ghost", name: "Ghost"}
_id: '2'
}

the second object of _jd 2 contains media elements and i can see the media objects on console before parsing,

useEffect(() => {
      TwilioService.getInstance()
        .getChatClient()
        .then((client: any) => client.getChannelBySid(channelId))
        .then((channel: any) => setChannelEvents(channel))
        .then((currentChannel: any) => currentChannel.getMessages())
        .then((paginator: any) => {
          chatMessagesPaginator.current = paginator;
          const newMessages = TwilioService.getInstance().parseMessages(
            paginator.items,
          );
          console.log(newMessages, "newMessages", paginator.items)
          setMessages(newMessages);
        })
        .catch((err: any) =>
          showMessage({message: err.message, type: 'danger'}),
        )
        .finally(() => setLoading(false));
    }, [channelId, setChannelEvents]);

in paginator.items i can see the type: 'media' and media url inside the state,

Is their any way to get media object along with messages

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions