GetStream / stream-chat-swiftui

SwiftUI Chat SDK ➜ Stream Chat 💬
https://getstream.io/chat/sdk/swiftui/
Other
348 stars 87 forks source link

animated GIFs in message attachments do not animate #307

Closed paulz closed 1 year ago

paulz commented 1 year ago

What did you do?

attached an animated GIF

GetStreamChatApi.send_user_message(%GetStreamChatApi.Message{
        cid: cid,
        text: Conversations.reset_message(),
        user: GetStreamChatApi.User.robin_ai(),
        attachments: [
          %{
            type: "image",
            image_url: "https://images.gr-assets.com/hostedimages/1514985666ra/24822666.gif"
          }
        ]
      })

What did you expect to happen?

GIF attachment is animated in the chat channel

What happened instead?

Only first frame displayed as a static image

GetStream Environment

GetStream Chat version: 4.3.0 GetStream Chat frameworks: StreamChat, StreamChatSwiftUI iOS version: 16.0 Swift version: 5 Xcode version: 14.2 Device: iPhone

Additional context

martinmitrevski commented 1 year ago

Hi @paulz,

I assume you are doing this with the REST API, right? Since we only have support for giphy attachments via commands in the UI SDKs.

In any case, I see that the type is image in the sample code above. Can you try with giphy maybe?

If that doesn't work, then you can pass extra data in the message to identify it as a gif, and update the message resolving logic to use custom attachments for displaying GIFs created from the outside: https://getstream.io/chat/docs/sdk/ios/swiftui/message-components/attachments/#handling-custom-attachments. In this case, you can still use our GiphyAttachmentView I believe.

Hope that helps, Martin

paulz commented 1 year ago

thank you @martinmitrevski

we were hoping to make this work without changing the client, so both web and swiftui clients can receive gifs we send from server. wondering how users receive each others gifs?

if user A sends /giphy fun to user B in chat we hope user B can see the animation

paulz commented 1 year ago

we want on the server construct the same message format that use B receives from user A

martinmitrevski commented 1 year ago

that should work theoretically. I assume what happens is that the attachment is resolved as an image attachment, and not as a giphy. Maybe you can put a breakpoint in the giphy payload here: https://github.com/GetStream/stream-chat-swift/blob/develop/Sources/StreamChat/Models/Attachments/ChatMessageGiphyAttachment.swift and check why it's not resolved as a giphy attachmment?

martinmitrevski commented 1 year ago

@paulz any updates on this one?

paulz commented 1 year ago

We tried the suggestion but couldn't get it work. So giving up on animated gifs from server for now. Can we convert this to a feature request? Lower priority. Thank you!

martinmitrevski commented 1 year ago

yes, I've created a feature request ticket internally. Can't promise anything about when we can deliver this. Closing this ticket for now.