Ver Fonte

Code review.

John Livingston há 11 meses atrás
pai
commit
90153c4045
1 ficheiros alterados com 15 adições e 4 exclusões
  1. 15 4
      src/plugins/muc-views/templates/occupant.js

+ 15 - 4
src/plugins/muc-views/templates/occupant.js

@@ -35,6 +35,21 @@ const occupant_title = /** @param {MUCOccupant} o */(o) => {
  * @param {MUCOccupant} o
  */
 async function tplActionButtons (o) {
+    /**
+     * *Hook* which allows plugins to add action buttons on occupants
+     * @event _converse#getOccupantActionButtons
+     * @example
+     *  api.listen.on('getOccupantActionButtons', (el, buttons) => {
+     *      buttons.push({
+     *          'i18n_text': 'Foo',
+     *          'handler': ev => alert('Foo!'),
+     *          'button_class': 'chat-occupant__action-foo',
+     *          'icon_class': 'fa fa-check',
+     *          'name': 'foo'
+     *      });
+     *      return buttons;
+     *  });
+     */
     const buttons = await api.hook('getOccupantActionButtons', o, []);
     if (!buttons?.length) { return '' }
 
@@ -49,10 +64,6 @@ async function tplActionButtons (o) {
         </button>`
     });
 
-    if (!items.length) {
-        return ''
-    }
-
     return html`<converse-dropdown
         class="occupant-actions chatbox-btn"
         .items=${items}