# Why doesn't Discourse GIFs TC use toolbarEvent instead of app event when adding the GIF?

**URL:** https://meta.discourse.org/t/why-doesnt-discourse-gifs-tc-use-toolbarevent-instead-of-app-event-when-adding-the-gif/387629
**Category:** Development
**Tags:** gifs
**Created:** [5 november 2025 om 03:34 UTC](https://meta.discourse.org/t/why-doesnt-discourse-gifs-tc-use-toolbarevent-instead-of-app-event-when-adding-the-gif/387629 "2025-11-05T03:34:28Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)
#### Post date: [5 november 2025 om 03:34 UTC](https://meta.discourse.org/t/why-doesnt-discourse-gifs-tc-use-toolbarevent-instead-of-app-event-when-adding-the-gif/387629/1 "2025-11-05T03:34:28Z")

</div>

I was looking at the #gifs TC yesterday, and I noticed this block of code:

> <https://github.com/discourse/discourse-gifs/blob/910bd8b73f1939ef046516d231791ab5d27e5ebf/javascripts/discourse/components/modal/gif.gjs#L28-L38>

Where it uses the `appEvents` service. The thing is, why can’t `toolbarEvent` be passed in at the action?

> <https://github.com/discourse/discourse-gifs/blob/910bd8b73f1939ef046516d231791ab5d27e5ebf/javascripts/discourse/initializers/gif-integration.js#L11-L21>

[I’ve tried it](https://github.com/NateDhaliwal/discourse-post-image-carousel/blob/cce808a44bf70f907eb13750b57618c241e2b289/javascripts/discourse/api-initializers/add-image-carousel.js#L23-L28) and it seems to work. Was there a reason why that was not used?

Considering it uses [TextManipulation](https://github.com/discourse/discourse/blob/c7ba17369645e66593a246f577005da5cce23ff1/frontend/discourse/app/lib/composer/text-manipulation.js) under the hood, there seems to be a [`insertText`](https://github.com/discourse/discourse/blob/c7ba17369645e66593a246f577005da5cce23ff1/frontend/discourse/app/lib/composer/text-manipulation.js#L177) method.

Just curious.

Thanks.

---

<div class="post-metadata">

### Author: ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)
#### Post date: [6 november 2025 om 00:12 UTC](https://meta.discourse.org/t/why-doesnt-discourse-gifs-tc-use-toolbarevent-instead-of-app-event-when-adding-the-gif/387629/3 "2025-11-06T00:12:47Z")

</div>

Digging a bit further, I found this line:

> <https://github.com/discourse/discourse/blob/d440592f88c425347d9a1115d6357ddcc7ec3ea8/frontend/discourse/app/components/d-editor.gjs#L697>

So… the app event still performs the same as textManipulation? What would be the added advantage in the TC?

---

<div class="post-metadata">

### Author: ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)
#### Post date: [6 november 2025 om 14:09 UTC](https://meta.discourse.org/t/why-doesnt-discourse-gifs-tc-use-toolbarevent-instead-of-app-event-when-adding-the-gif/387629/4 "2025-11-06T14:09:54Z")

</div>

Anyone has any ideas? I’m considering the appEvent versus toolbarEvent, and knowing the differences (if any) would be helpful.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [6 november 2025 om 14:37 UTC](https://meta.discourse.org/t/why-doesnt-discourse-gifs-tc-use-toolbarevent-instead-of-app-event-when-adding-the-gif/387629/6 "2025-11-06T14:37:08Z")

</div>

I think discourse-gifs does it like this because the Modal is also launched from outside the toolbar:

> <https://github.com/discourse/discourse-gifs/blob/1fa66e5fb2692241dac6c743c7f7db064244b378/javascripts/discourse/components/gif-button.gjs#L13C3-L16C4>

If your new thing is entirely toolbar-based, then I agree toolbarEvents is the cleaner way to go 👌

---

<div class="post-metadata">

### Author: ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)
#### Post date: [7 november 2025 om 02:30 UTC](https://meta.discourse.org/t/why-doesnt-discourse-gifs-tc-use-toolbarevent-instead-of-app-event-when-adding-the-gif/387629/7 "2025-11-07T02:30:41Z")

</div>

Ah, that’s it. Thanks for clarifying, I’ll go ahead with toolbarEvent then.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [7 december 2025 om 02:31 UTC](https://meta.discourse.org/t/why-doesnt-discourse-gifs-tc-use-toolbarevent-instead-of-app-event-when-adding-the-gif/387629/8 "2025-12-07T02:31:04Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
