qpixel icon indicating copy to clipboard operation
qpixel copied to clipboard

Let people flag comments from the in-page preview

Open cellio opened this issue 4 years ago • 3 comments

When looking at a comment thread, somebody (with the right abilities) can see the following actions for each individual comment: link, edit, delete, flag. When a thread is expanded on a post page, though, the only available action is link.

Flagging seems like something we should make it easy to do; if there's something wrong in a visible comment, let's let people tell us that instead of making them load the thread page (which some won't do).

Arguments can be made both ways about editing and deleting, but I think flagging is pretty clear. Can we support that?

cellio avatar Jul 08 '21 02:07 cellio

In app/views/comments/_comment.html.erb, line 53, I found this:

      <% if user_signed_in? && params[:inline] != 'true' %>
        <a href="javascript:void(0)" data-drop="#flag-comment-<%= comment.id %>">flag</a>
        <div class="droppanel is-large h-c-black" id="flag-comment-<%= comment.id %>">
          <label for="flag-post-<%= comment.id %>">Flag reason</label>
          <input type="text" id="flag-post-<%= comment.id %>" class="form-element" />
          <a href="javascript:void(0)" class="flag-link js-comment-flag button is-danger" data-post-id="<%= comment.id %>"
             data-requires-details="true">Flag</a>
        </div>
      <% end %>

I removed && params[:inline] != 'true' from the test and that did in fact cause the "flag" link to appear on an inline comment. However, clicking it didn't do anything. I tried grepping for "Flag reason" (the text that appears in the modal on a thread page), but didn't find anything conclusive. (That is, I got results, but there's no obvious "thread vs inline" check that needs to be changed.) So there's probably some other context that affects this.

It would be nice to be able to fix this item that's in phase 1 on the current roadmap. It looks like I know how to fix half of it.

cellio avatar May 18 '22 00:05 cellio

I've looked through the controller code for both comments and flags, and I can't find where comment flags are implemented. The flags view looks like code for the flag queue, not for flagging. None of the other file names in the controllers directory shouted "look at me" to me. I don't think this change calls for a change to model code. Anybody have a clue to lend?

cellio avatar May 30 '22 17:05 cellio

The problem is that inline thread views are created dynamically.

As a highly simplified view, normally, there is a button and a drop-panel. Co-Design runs a script that adds a listener to the button to open the drop-panel.

However, in this case, since the inline thread doesn't exist yet, the script can't add a listener. Therefore, when the inline thread is shown, there is no listener, and when you click the flag button, nothing happens.

Pre-generating the threads so that the script can hook up the listeners sounds expensive, so the listeners would need to be added afterwards. However, Co-Design currently doesn't expose any API to hook it up after the fact, so this would require a change there.

MoshiKoi avatar Sep 01 '22 05:09 MoshiKoi