# 聊天中的 GIF 错误？

**URL:** https://meta.discourse.org/t/gif-bug-in-chat/288369
**Category:** Bug
**Tags:** chat, gifs
**Created:** [2023年十二月12日 12:05 UTC](https://meta.discourse.org/t/gif-bug-in-chat/288369 "2023-12-12T12:05:24Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![sok777](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@sok777](https://meta.discourse.org/u/sok777)
#### Post date: [2023年十二月12日 12:05 UTC](https://meta.discourse.org/t/gif-bug-in-chat/288369/1 "2023-12-12T12:05:24Z")

</div>

我看到聊天在这里按预期工作，但在我们网站上选择 GIF 时注意到一个错误。  
控制台中显示的内容如下：

 ![Screenshot 2023-12-12 at 12.03.49](https://global.discourse-cdn.com/meta/original/4X/0/1/5/015d986edae41f9f3c8f081a5a55e494c7a668ab.png)

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [2023年十二月12日 12:33 UTC](https://meta.discourse.org/t/gif-bug-in-chat/288369/2 "2023-12-12T12:33:50Z")

</div>

只是为了确认一下，您的网站是否已更新到最新版本？

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2023年十二月12日 15:24 UTC](https://meta.discourse.org/t/gif-bug-in-chat/288369/3 "2023-12-12T15:24:25Z")

</div>

在我这边使用最新版本可以正常运行，没有报错。

看起来最近的一个更改 [FIX: correctly uses chat draft property by jjaffeux · Pull Request #54 · discourse/discourse-gifs · GitHub](https://github.com/discourse/discourse-gifs/pull/54/files) 需要 3.2.0.beta4；因此，我假设在这里使用最新版本是个好主意，正如 Jammy 所建议的。

---

<div class="post-metadata">

### Author: ![sok777](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@sok777](https://meta.discourse.org/u/sok777)
#### Post date: [2023年十二月12日 20:55 UTC](https://meta.discourse.org/t/gif-bug-in-chat/288369/4 "2023-12-12T20:55:20Z")

</div>

听起来这就是问题所在。我将尝试更新并报告结果！

---

<div class="post-metadata">

### Author: ![sok777](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@sok777](https://meta.discourse.org/u/sok777)
#### Post date: [2023年十二月17日 16:01 UTC](https://meta.discourse.org/t/gif-bug-in-chat/288369/5 "2023-12-17T16:01:02Z")

</div>

升级后出现新错误，模态窗口甚至无法打开 :/\n ![Screenshot 2023-12-17 at 16.00.04](https://cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/4X/7/5/7/757ac1c1953d28d8522e8d3b880d0578387824f7.png)

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2023年十二月17日 16:25 UTC](https://meta.discourse.org/t/gif-bug-in-chat/288369/6 "2023-12-17T16:25:32Z")

</div>

你也更新了 Discourse 吗？我看到你正在使用最新的主题组件版本，所以我认为你的 Discourse 可能没有更新到最新。 （在我这边运行正常）

---

<div class="post-metadata">

### Author: ![sok777](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@sok777](https://meta.discourse.org/u/sok777)
#### Post date: [2023年十二月17日 16:30 UTC](https://meta.discourse.org/t/gif-bug-in-chat/288369/7 "2023-12-17T16:30:09Z")

</div>

全部更新完毕

 ![Screenshot 2023-12-17 at 16.29.59](https://global.discourse-cdn.com/meta/original/4X/f/e/8/fe8e4d2c0a1354b904dbd7fb1d36b5d2f7d5a112.png)

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2023年十二月17日 17:01 UTC](https://meta.discourse.org/t/gif-bug-in-chat/288369/8 "2023-12-17T17:01:37Z")

</div>

哦，我明白了。你从聊天中插入。我可以重现。

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2023年十二月17日 21:35 UTC](https://meta.discourse.org/t/gif-bug-in-chat/288369/9 "2023-12-17T21:35:12Z")

</div>

我提交了一个 PR 👍

> <https://github.com/discourse/discourse-gifs/pull/60>
>
> Meta: https://meta.discourse.org/t/gif-bug-in-chat/288369/5?u=arkshine
> 
> Follow…up 9607c7afafa6c470dd2ba184d19344524259ddc9.
> 
> Opening the GIF modal from the chat results in this error:
> !\[image\](https://github.com/discourse/discourse-gifs/assets/360640/5d0c8a52-6df5-485b-bb6f-9e97e1aa6408)
> 
> This is because \`modal: service()\` has been added here:
> 
> \`\`\`js
> api.modifyClass("component:chat-composer", {
> pluginId: "discourse-gifs",
> 
> modal: service(),
> 
> @action
> showChatGifModal(context) {
> this.modal.show(GifModal, {
> \`\`\`
> However, \`ChatComposer\` base \[class\](https://github.com/discourse/discourse/blob/main/plugins/chat/assets/javascripts/discourse/components/chat-composer.js#L44) already has the service. 
> This breaks inheritance with \`ChatComposerChannel\` \[child class\](https://github.com/discourse/discourse/blob/main/plugins/chat/assets/javascripts/discourse/components/chat/composer/channel.js), making \`this.modal\` unavailable when \`showChatGifModal\` is called.
> 
> As a solution, \`modal: service(),\` is removed.
> Result after the fix:
> 
> !\[image\](https://github.com/discourse/discourse-gifs/assets/360640/9fdd6318-fb36-49e5-b935-3ef557cf1989)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2023年十二月18日 00:28 UTC](https://meta.discourse.org/t/gif-bug-in-chat/288369/10 "2023-12-18T00:28:59Z")

</div>


