# Discourse Retort

**URL:** https://meta.discourse.org/t/discourse-retort/35903
**Category:** Plugin
**Tags:** end-of-life
**Created:** [2015年十一月22日 11:53 UTC](https://meta.discourse.org/t/discourse-retort/35903 "2015-11-22T11:53:58Z")
**Posts on this page:** 20
**Page:** 8

<div class="post-metadata">

### Author: ![ehemsley](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ehemsley/32/120706_2.png) [@ehemsley](https://meta.discourse.org/u/ehemsley)
#### Post date: [2017年九月12日 19:27 UTC](https://meta.discourse.org/t/discourse-retort/35903/147 "2017-09-12T19:27:38Z")

</div>

It mostly works now, thanks for the fixes!

One issue is that sometimes clicking the retort button dims the site but doesn’t pop up the emoji picker.  
After a ctrl-R refresh it works again but it’s a little frustrating.

Tested on Opera

EDIT: after some testing it looks like bringing up the reply window, closing it, and then trying the retort button again is what triggers the issue

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [2017年九月13日 06:31 UTC](https://meta.discourse.org/t/discourse-retort/35903/148 "2017-09-13T06:31:35Z")

</div>

So, obviously nobody seem to be having the same problem with on-screen formatting that I have:

> [@Discourse Retort](https://meta.discourse.org/t/retort-a-reaction-style-plugin-for-discourse/35903/146):
>
> How come it becomes like this: Not centered on screen. Buttons not centered. Button widths screwed up., Strange because I can see display: flex put on the wrapper, which certainly will not make the buttons wrap. Am I missing a CSS file or something?

Can this be a conflict with another plugin? The _broken_ previous version was formatting the emoiji box correctly, just won’t show it. How it is shown but formatted obviously incorrectly.

Bummer is… nobody seems to be seeing this except poor me… 😥

---

<div class="post-metadata">

### Author: ![gdpelican](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gdpelican/32/81308_2.png) [@gdpelican](https://meta.discourse.org/u/gdpelican)
#### Post date: [2017年九月13日 13:32 UTC](https://meta.discourse.org/t/discourse-retort/35903/149 "2017-09-13T13:32:05Z")

</div>

It seems likely to be a caching issue to me. Have you tried clearing your cache and reloading? Can you confirm that it happens in multiple browsers?

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [2017年九月13日 15:27 UTC](https://meta.discourse.org/t/discourse-retort/35903/150 "2017-09-13T15:27:10Z")

</div>

Yes, I confirm that this happens in all browsers, with caching turned off.

 ![image](https://global.discourse-cdn.com/meta/original/3X/3/5/35265eafcfffc72e8e385a0e03f8f36cf923d4d8.png)

A screenshot on FireFox, with the DOM tree in inspector.

Since nobody else seems to be encountering this, I suspect this might be a plugin conflict…

These are the plugins I have:

| Name | Version | Enabled? |
| --- | --- | --- |
| babble | 2.0.4 | Y |
| discourse-data-explorer | 0.2 | Y |
| discourse-details | 0.4 | Y |
| discourse-formatting-toolbar | 2.3 | Y |
| discourse-narrative-bot | 0.0.1 | Y |
| discourse-nginx-performance-report | 0.1 | Y |
| discourse-presence | 1.0 | Y |
| discourse-solved | 0.1 | Y |
| Spoiler Alert! | 0.3 | Y |
| discourse-translator | 0.2.0 | Y |
| discourse-voting | 0.4 | Y |
| discourse-whos-online | 1.0 | Y |
| docker\_manager | 0.1 | Y |
| lazyYT | 1.0.1 | Y |
| poll | 0.9 | Y |
| retort | 1.1.2 | Y |

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [2017年九月13日 15:38 UTC](https://meta.discourse.org/t/discourse-retort/35903/151 "2017-09-13T15:38:55Z")

</div>

If `retort limited emoji set` is OFF, then it pops up with the standard emoji picker (you know, the one that pops up when writing a reply).

If `retort limited emoji set` on ON, then it causes this problem, obviously because the wrapper is missing a few DOM panels inside and the buttons got spread directly by the flexbox.

As it happens, the code in `retort-picker.js.es6` defers to the standard emoji picker if `retort limited emoji set` is OFF, which explains the current bahavior. However, if `retort limited emoji set` is ON, then somehow the standard emoji picker still gets shown, instead of retort emoji picker (which has all the relevant buttons created correctly). So, in other words, `this._bindEmojiClick($picker);` is not having the desired effect.

There are _two_ emoji pickers on the page: the standard emoji picker, and the retort emoji picker. The _both_ have the class `emoji-picker`. I am quite sure that the line `const $picker = $('.emoji-picker')` is not correct, since it will return _both_ pickers (when you only want the retort emoji picker). As a result, _both_ the retort emoji picker _and_ the standard emoji picker got buttons created underneath, if `retort limited emoji set` on ON.

And the critical line `this._bindEmojiClick($picker);` binds the click to _two_ pickers, which probably means the last one wins (i.e. the standard emoji picker, which is located below the retort emoji picker).

I am _quite_ sure the correct code should be:

`const $picker = $('.retort-picker.emoji-picker')`

I suspect nobody here limits the emoji’s to a list? 🤔

---

<div class="post-metadata">

### Author: ![gdpelican](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gdpelican/32/81308_2.png) [@gdpelican](https://meta.discourse.org/u/gdpelican)
#### Post date: [2017年九月13日 16:53 UTC](https://meta.discourse.org/t/discourse-retort/35903/152 "2017-09-13T16:53:22Z")

</div>

Hey @schungx the best approach here is going to be to submit a PR to the repo with a fix 🙂

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [2017年九月14日 02:23 UTC](https://meta.discourse.org/t/discourse-retort/35903/153 "2017-09-14T02:23:42Z")

</div>

Problem is:

1. I don’t know Ruby and Rails
2. I don’t know how the system works mostly
3. I don’t know how to do a PR…

😅

Is there, sort of, a “dummies-way” in Github to package a small change as a PR _without_ me having to clone the entire repository?

That’s because I have no way to _test_ my proposed changes. Of course I can probably rebuild the Discourse with my own version of retort, but I am not quite sure how to do that since it involves hooking up to a local Git repository and things get complicated and confusing very quickly…

I am quite sure there is a way to just _enter_ the container and modify the JS file to test things… any pointers into how to do that will be welcome. Also, an indication which file it gets turned into (so I can change the code and test to see if it works) will be nice.

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [2017年九月14日 03:11 UTC](https://meta.discourse.org/t/discourse-retort/35903/154 "2017-09-14T03:11:07Z")

</div>

> [@schungx](#):
>
> Is there, sort of, a “dummies-way” in Github to package a small change as a PR without me having to clone the entire repository?

Yes. Create a Github account, find the file in the repository on Github, and there will be an edit icon. As you don’t have write access, it will automatically fork the repo for you and create a branch. Edit the file right on the website, then push it to your repo. Github will them prompt you to submit a PR.

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [2017年九月14日 05:18 UTC](https://meta.discourse.org/t/discourse-retort/35903/155 "2017-09-14T05:18:16Z")

</div>

@jomaxro Ha great! “Dummies” proof! 👍

@gdpelican I have submitted (my first ever) PR.

Still I need a (dummy-simple) way to modify an existing running container to test out changes without rebuilding the whole thing with a private repository…

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [2017年九月14日 05:24 UTC](https://meta.discourse.org/t/discourse-retort/35903/156 "2017-09-14T05:24:13Z")

</div>

> [@schungx](#):
>
> Still I need a (dummy-simple) way to modify an existing running container to test out changes without rebuilding the whole thing with a private repository…

You’d need a development instance for that. I don’t think there’s a “dummy-simple” setup for development…

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [2017年九月14日 10:31 UTC](https://meta.discourse.org/t/discourse-retort/35903/157 "2017-09-14T10:31:51Z")

</div>

Well, good news and bad news.

Good news is that forking the repository in Github and then branching, I can simply rebuild Discourse by pulling from my fork instead. Then I can test changes. Great!

Bad news is: my proposed changes didn’t work totally… So it is back to more debugging…😅

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [2017年九月14日 11:23 UTC](https://meta.discourse.org/t/discourse-retort/35903/158 "2017-09-14T11:23:15Z")

</div>

After a couple of (long) compiles:

1. Retort conflicts with Babble. If Babble is installed, Retort will popup the Babble emoji picker instead and screw the whole thing up. This is quite strange since both plugins seem to come from the same author…

2. Removing Babble makes it work fine. However, as @ehemsley has pointed out:

> [@ehemsley](#):
>
> after some testing it looks like bringing up the reply window, closing it, and then trying the retort button again is what triggers the issue

1. This is because, in Discorse, the `EmojiPicker` class stores the current emoji picker in a **GLOBAL** variable called `$picker`. Multiple plugins now fight for the same global `$picker` variable. Since `retort-picker` is always loaded first, `$picker` is set to this picker (if Babble is not installed). Once we bring up the reply-post emoji picker, `$picker` got changed to something else. So after that, `retort-picker` no longer works because `$picker` is no longer pointing to it.

2. The solution is, obviously, to insert the element on click, and remove it when closed. This ensures that only _one_ emoji picker is ever present at any time, and `$picker` gets reset every time.

3. In the long run, there really is no reason for Discourse’s `EmojiPIcker` class to store the current picker in a **GLOBAL** variable; it should easily be moved to an instance-based field so that multiple pickers (from different plugins) can co-exist without screwing each other up.

I’ll try to put out a PR when I figure out how to dynamically add/remove widgets.

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [2017年九月14日 15:15 UTC](https://meta.discourse.org/t/discourse-retort/35903/159 "2017-09-14T15:15:50Z")

</div>

Tthe trick is to call `didInsertElement` before `show` and call `didDeleteElement` after `close`. This should reset the `$picker` global variable, and doesn’t appear to have any ill effects so far.

WARNING: LARK’S VOMIT – This is a HACK.

I’ve submitted a new PR.

It doesn’t work together with `discourse/babble` though because it has the same problem with the emoji-picker. The problem is with `discourse/babble`, not with `retort`.

---

<div class="post-metadata">

### Author: ![ehemsley](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ehemsley/32/120706_2.png) [@ehemsley](https://meta.discourse.org/u/ehemsley)
#### Post date: [2017年九月14日 19:22 UTC](https://meta.discourse.org/t/discourse-retort/35903/160 "2017-09-14T19:22:39Z")

</div>

Just tried your fix. Big improvement but there’s one lingering bug:

Open a reply window, click the emoji picker in the reply window, and then click the retort button on a post. The modal will show up empty and make the browser window unresponsive.

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [2017年九月15日 02:29 UTC](https://meta.discourse.org/t/discourse-retort/35903/161 "2017-09-15T02:29:54Z")

</div>

Yup, it is a hack only… The standard `EmojiPicker` in Discourse uses module-global variables to store the picker to popup. Any time the reply window is opened, it gets overwritten to point to a different emoji picker, throwing everything off.

I’ve opened an issue for this:

> [@EmojiPicker stores state in global module-level variables](https://meta.discourse.org/t/emojipicker-stores-state-in-global-module-level-variables/70056):
>
> In emoji-picker.js.es6: The following variables are used for emoji-pickers, but they are currently module-GLOBAL variables instead of instance fields. let $picker, $filter, $results, $list, scrollPosition, $visibleSections, \_checkTimeout; In particker, $picker is used to popup the emoji-picker. It is a module-global variable, so what that means is that there CANNOT BE any permanent emoji-picker’s on the page (e.g. discourse/babble and discourse/retort both put emoji-pickers permanently on th…

When the reply window is open, the variable points to the standard `EmojiPicker`. When you press the retort button, my fix forced-overwrite the variable to point to the `RetortEmojiPicker`. But if the reply window (and the standard `EmojiPicker`) is still open, obviously two emoji pickers together are going to make things _very_ interesting… especially when there is only _one_ module-global variable to point to one of them.

🕶

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [2017年九月21日 02:27 UTC](https://meta.discourse.org/t/discourse-retort/35903/162 "2017-09-21T02:27:51Z")

</div>

With changes in Discourse’s emoji picker in recent versions, this plugin now works again.

I have submitted a PR for some minor fixes to pick up the correct emoji picker when the reply window is open.

[https://github.com/gdpelican/retort/pull/31](https://github.com/gdpelican/retort/pull/31)

---

<div class="post-metadata">

### Author: ![XieLong](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xielong/32/67063_2.png) [@XieLong](https://meta.discourse.org/u/XieLong)
#### Post date: [2017年九月26日 11:38 UTC](https://meta.discourse.org/t/discourse-retort/35903/163 "2017-09-26T11:38:56Z")

</div>

@gdpelican Would it be possible to merge that pull request and release a new version? The plugin is quite awesome and I’d like to turn it back on for my community 🙂

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [2017年九月26日 12:03 UTC](https://meta.discourse.org/t/discourse-retort/35903/164 "2017-09-26T12:03:25Z")

</div>

Just edit `container/app.yaml`, comment out the original line and put in:

`git clone https://github.com/schungx/retort.git`

That works for me.

Until the PR is merged into the official branch.

But I see that @gdpelican has already fixed the `before_filter` issue with a new commit a few hours ago. You can just try rebuilding to see if it works. AFAIK, the changes to `this.$()` are not in yet so there may be conflicts if you have both the retort up as well as a reply window.

---

<div class="post-metadata">

### Author: ![DiscourseMetrics](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discoursemetrics/32/55756_2.png) [@DiscourseMetrics](https://meta.discourse.org/u/DiscourseMetrics)
#### Post date: [2017年九月27日 12:58 UTC](https://meta.discourse.org/t/discourse-retort/35903/165 "2017-09-27T12:58:31Z")

</div>

It would be nice to be able to limit use of Retort to those users with trust level \> X. I have a banned user that keeps creating new accounts and then spams posts he dislikes with lots of negative retorts. 😕

---

<div class="post-metadata">

### Author: ![JamesNorth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jamesnorth/32/283740_2.png) [@JamesNorth](https://meta.discourse.org/u/JamesNorth)
#### Post date: [2017年九月27日 13:12 UTC](https://meta.discourse.org/t/discourse-retort/35903/166 "2017-09-27T13:12:53Z")

</div>

You can limit to one retort per user per post … but yeah would be good.

Seems like that thing from Red Dead Redemption online where people kept shooting your horse because they can’t shoot you in friendly mode.

[上一頁](https://meta.discourse.org/t/discourse-retort/35903.md?page=7)

[下一頁](https://meta.discourse.org/t/discourse-retort/35903.md?page=9)
