Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-68657

Change in the messaging JS functions after MDL-67881

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.8.3
    • Fix Version/s: None
    • Component/s: JavaScript, Messages
    • Labels:
      None
    • Affected Branches:
      MOODLE_38_STABLE

      Description

      In our plugin we have a view that displays a list of users and the "Message" button next to each of them. For this button we used the JS code like this:

          require(['jquery', 'core/custom_interaction_events', 'core_message/message_drawer_helper'],
          function($, CustomEvents, MessageDrawerHelper) {
              var elementLocator = '[data-action="wpmessage"][data-userid]';
              CustomEvents.define($('body'), [CustomEvents.events.activate]);
              $('body').on(CustomEvents.events.activate, elementLocator, function(e, data) {
                  e.preventDefault();
                  data.originalEvent.preventDefault();
                  MessageDrawerHelper.createConversationWithUser(parseInt($(e.currentTarget).attr('data-userid')));
              });
          });
      

      We copied this code from "send" method from core_message/message_user_button . We could not use the method directly because it assumed that the the button already exists, where we needed a listener for the selector (this is a paginated list with AJAX loading of additional pages and AJAX applying of the filters). In fact we originally used the "send" method and had to re-write the code because it was not compatible with dynamic contents.

      Change from MDL-67881 broke our code because method createConversationWithUser() now accepts the {userid: userid} and not just userid. There are several other methods and pubsub event listeneres that were changed in this issue and the change is not backward-compatible.

      message/amd/src/message_drawer_helper.js does not mention that the functions are not public API, maybe all we need to do is to add comments there that these methods should not be used directly and redirect to core_message/message_user_button . Edit: see comments, the functionality of 'core_message/message_user_button' has also been change in non-backward-compatible way in 3.8.3

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              marina Marina Glancy
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated: