From c11baac4b4f78d853a68dba31b1f34c08fcb915d Mon Sep 17 00:00:00 2001 From: Jake Dallimore Date: Fri, 4 Oct 2019 09:24:19 +0800 Subject: [PATCH] MDL-66226 core_message: wrap promise chains in pending for behat Fixes random failures by forcing behat to wait for the pane to render. --- .../build/message_drawer_view_overview_section.min.js | 2 +- .../message_drawer_view_overview_section.min.js.map | 2 +- .../amd/src/message_drawer_view_overview_section.js | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/message/amd/build/message_drawer_view_overview_section.min.js b/message/amd/build/message_drawer_view_overview_section.min.js index 0c6173e1787..27ff9bc5851 100644 --- a/message/amd/build/message_drawer_view_overview_section.min.js +++ b/message/amd/build/message_drawer_view_overview_section.min.js @@ -1,2 +1,2 @@ -function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _iterableToArrayLimit(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g=a[Symbol.iterator](),h;!(d=(h=g.next()).done);d=!0){c.push(h.value);if(b&&c.length===b)break}}catch(a){e=!0;f=a}finally{try{if(!d&&null!=g["return"])g["return"]()}finally{if(e)throw f}}return c}function _arrayWithHoles(a){if(Array.isArray(a))return a}define ("core_message/message_drawer_view_overview_section",["jquery","core/custom_interaction_events","core/notification","core/pubsub","core/str","core/templates","core/user_date","core_message/message_repository","core_message/message_drawer_events","core_message/message_drawer_router","core_message/message_drawer_routes","core_message/message_drawer_lazy_load_list","core_message/message_drawer_view_conversation_constants"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n={TOGGLE:"[data-region=\"toggle\"]",CONVERSATION:"[data-conversation-id]",BLOCKED_ICON_CONTAINER:"[data-region=\"contact-icon-blocked\"]",LAST_MESSAGE:"[data-region=\"last-message\"]",LAST_MESSAGE_DATE:"[data-region=\"last-message-date\"]",MUTED_ICON_CONTAINER:"[data-region=\"muted-icon-container\"]",UNREAD_COUNT:"[data-region=\"unread-count\"]",SECTION_TOTAL_COUNT:"[data-region=\"section-total-count\"]",SECTION_TOTAL_COUNT_CONTAINER:"[data-region=\"section-total-count-container\"]",SECTION_UNREAD_COUNT:"[data-region=\"section-unread-count\"]",PLACEHOLDER_CONTAINER:"[data-region=\"placeholder-container\"]"},o={CONVERSATIONS_LIST:"core_message/message_drawer_conversations_list",CONVERSATIONS_LIST_ITEMS_PLACEHOLDER:"core_message/message_drawer_conversations_list_items_placeholder"},p=50,q={},r=!1,s=!1,t=function(a){return l.getRoot(a).hasClass("show")},u=function(a){a.addClass("expanded")},v=function(a){a.removeClass("expanded")},w=function(a,b){var c=a.find(n.SECTION_TOTAL_COUNT_CONTAINER),d=c.find(n.SECTION_TOTAL_COUNT);d.text(b);c.removeClass("hidden");e.get_string("totalconversations","core_message",b).done(function(a){c.attr("aria-label",a)});var g=20p){c=c.slice(0,-1)}else{l.setLoadedAll(a,!0)}d=d+p;c.forEach(function(a){q[a.id]=a});return c}).catch(c.exception)}},B=function(a){return a.find(n.SECTION_TOTAL_COUNT)},C=function(a){return a.find(n.SECTION_UNREAD_COUNT)},D=function(a){if(r){var b=B(a),c=parseInt(b.text());c=c+1;b.text(c)}},E=function(a){if(r){var b=B(a),c=parseInt(b.text());c=c-1;b.text(c)}},F=function(a){if(s){var b=C(a),c=parseInt(b.text());c=c-1;b.text(c);if(1>c){b.addClass("hidden")}}},G=function(a,b){return a.find("[data-conversation-id=\""+b+"\"]")},H=function(a,b){return a.find("[data-user-id=\""+b+"\"]")},I=function(a){a.find(n.MUTED_ICON_CONTAINER).removeClass("hidden")},J=function(a){a.find(n.MUTED_ICON_CONTAINER).addClass("hidden")},K=function(a){a.find(n.BLOCKED_ICON_CONTAINER).removeClass("hidden")},L=function(a){a.find(n.BLOCKED_ICON_CONTAINER).addClass("hidden")},M=function(a,b,d){var e=a.find(n.CONVERSATION);if(!e.length){var f=l.getRoot(a);l.showContent(f);l.hideEmptyMessage(f)}q[b.id]=b;return z([b],d).then(function(b){var c=l.getContentContainer(a);return c.prepend(b)}).then(function(){return D(a)}).catch(c.exception)},N=function(a,b){b.remove();E(a);var c=a.find(n.CONVERSATION);if(!c.length){var d=l.getRoot(a);l.hideContent(d);l.showEmptyMessage(d)}},O=function(a,b){var c=b.find(n.UNREAD_COUNT);c.text("0");c.addClass("hidden");F(a)},P=function(f,g,h,m,o,p){var r=l.getRoot(g),s=function(a){var b=parseInt(a.type,10);if(m&&0>m.indexOf(b)||o&&!a.isFavourite||!o&&a.isFavourite){return!1}return!0},t=g.find(n.TOGGLE);g.css("min-height",t.outerHeight());g.on("show.bs.collapse",function(){u(g);l.show(r,h,function(a,b,d){return z(b,d).then(function(b){a.append(b);return b}).catch(c.exception)})});g.on("hidden.bs.collapse",function(){v(g)});d.subscribe(i.CONTACT_BLOCKED,function(a){var b=H(g,a);if(b.length){K(b)}});d.subscribe(i.CONTACT_UNBLOCKED,function(a){var b=H(g,a);if(b.length){L(b)}});d.subscribe(i.CONVERSATION_SET_MUTED,function(a){var b=a.id,c=G(g,b);if(c.length){I(c)}});d.subscribe(i.CONVERSATION_UNSET_MUTED,function(a){var b=a.id,c=G(g,b);if(c.length){J(c)}});d.subscribe(i.CONVERSATION_NEW_LAST_MESSAGE,function(a){if(!s(a)){return}var b=a.loggedInUserId,d=a.id,e=G(g,d);a=y(a);if(e.length){var f=l.getContentContainer(g);z([a],b).then(function(a){f.prepend(a);e.remove();return a}).catch(c.exception)}else{M(g,a,b)}});d.subscribe(i.CONVERSATION_DELETED,function(a){var b=G(g,a);delete q[a];if(b.length){N(g,b)}});d.subscribe(i.CONVERSATION_READ,function(a){var b=G(g,a);if(b.length){O(g,b)}});d.subscribe(i.CONVERSATION_SET_FAVOURITE,function(a){var b=null;if(s(a)){b=G(g,a.id);if(!b.length){M(g,y(a),a.loggedInUserId)}}else{b=G(g,a.id);if(b.length){N(g,b)}}});d.subscribe(i.CONVERSATION_UNSET_FAVOURITE,function(a){var b=null;if(s(a)){b=G(g,a.id);if(!b.length){M(g,y(a),a.loggedInUserId)}}else{b=G(g,a.id);if(b.length){N(g,b)}}});b.define(g,[b.events.activate]);g.on(b.events.activate,n.CONVERSATION,function(b,c){var d=a(b.target).closest(n.CONVERSATION),e=d.attr("data-conversation-id"),g=q[e];j.go(f,k.VIEW_CONVERSATION,g,p);c.originalEvent.preventDefault()})};return{show:function show(b,d,e,f,g,h,i,j,k){var m=a(e);if(!m.attr("data-init")){var n=A(g,h,0);P(b,m,n,g,h,k);if(t(m)){u(m);var o=l.getRoot(m);l.show(o,n,function(a,b,d){return z(b,d).then(function(b){a.append(b);return b}).catch(c.exception)})}i.then(function(a){w(m,a);r=!0}).catch(function(){});j.then(function(a){x(m,a);s=!0}).catch(function(){});m.attr("data-init",!0)}},isVisible:t}}); +function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _iterableToArrayLimit(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g=a[Symbol.iterator](),h;!(d=(h=g.next()).done);d=!0){c.push(h.value);if(b&&c.length===b)break}}catch(a){e=!0;f=a}finally{try{if(!d&&null!=g["return"])g["return"]()}finally{if(e)throw f}}return c}function _arrayWithHoles(a){if(Array.isArray(a))return a}define ("core_message/message_drawer_view_overview_section",["jquery","core/custom_interaction_events","core/notification","core/pubsub","core/str","core/pending","core/templates","core/user_date","core_message/message_repository","core_message/message_drawer_events","core_message/message_drawer_router","core_message/message_drawer_routes","core_message/message_drawer_lazy_load_list","core_message/message_drawer_view_conversation_constants"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){var o={TOGGLE:"[data-region=\"toggle\"]",CONVERSATION:"[data-conversation-id]",BLOCKED_ICON_CONTAINER:"[data-region=\"contact-icon-blocked\"]",LAST_MESSAGE:"[data-region=\"last-message\"]",LAST_MESSAGE_DATE:"[data-region=\"last-message-date\"]",MUTED_ICON_CONTAINER:"[data-region=\"muted-icon-container\"]",UNREAD_COUNT:"[data-region=\"unread-count\"]",SECTION_TOTAL_COUNT:"[data-region=\"section-total-count\"]",SECTION_TOTAL_COUNT_CONTAINER:"[data-region=\"section-total-count-container\"]",SECTION_UNREAD_COUNT:"[data-region=\"section-unread-count\"]",PLACEHOLDER_CONTAINER:"[data-region=\"placeholder-container\"]"},p={CONVERSATIONS_LIST:"core_message/message_drawer_conversations_list",CONVERSATIONS_LIST_ITEMS_PLACEHOLDER:"core_message/message_drawer_conversations_list_items_placeholder"},q=50,r={},s=!1,t=!1,u=function(a){return m.getRoot(a).hasClass("show")},v=function(a){a.addClass("expanded")},w=function(a){a.removeClass("expanded")},x=function(a,b){var c=a.find(o.SECTION_TOTAL_COUNT_CONTAINER),d=c.find(o.SECTION_TOTAL_COUNT);d.text(b);c.removeClass("hidden");e.get_string("totalconversations","core_message",b).done(function(a){c.attr("aria-label",a)});var f=20q){c=c.slice(0,-1)}else{m.setLoadedAll(a,!0)}d=d+q;c.forEach(function(a){r[a.id]=a});return c}).catch(c.exception)}},C=function(a){return a.find(o.SECTION_TOTAL_COUNT)},D=function(a){return a.find(o.SECTION_UNREAD_COUNT)},E=function(a){if(s){var b=C(a),c=parseInt(b.text());c=c+1;b.text(c)}},F=function(a){if(s){var b=C(a),c=parseInt(b.text());c=c-1;b.text(c)}},G=function(a){if(t){var b=D(a),c=parseInt(b.text());c=c-1;b.text(c);if(1>c){b.addClass("hidden")}}},H=function(a,b){return a.find("[data-conversation-id=\""+b+"\"]")},I=function(a,b){return a.find("[data-user-id=\""+b+"\"]")},J=function(a){a.find(o.MUTED_ICON_CONTAINER).removeClass("hidden")},K=function(a){a.find(o.MUTED_ICON_CONTAINER).addClass("hidden")},L=function(a){a.find(o.BLOCKED_ICON_CONTAINER).removeClass("hidden")},M=function(a){a.find(o.BLOCKED_ICON_CONTAINER).addClass("hidden")},N=function(a,b,d){var e=a.find(o.CONVERSATION);if(!e.length){var f=m.getRoot(a);m.showContent(f);m.hideEmptyMessage(f)}r[b.id]=b;return A([b],d).then(function(b){var c=m.getContentContainer(a);return c.prepend(b)}).then(function(){return E(a)}).catch(c.exception)},O=function(a,b){b.remove();F(a);var c=a.find(o.CONVERSATION);if(!c.length){var d=m.getRoot(a);m.hideContent(d);m.showEmptyMessage(d)}},P=function(a,b){var c=b.find(o.UNREAD_COUNT);c.text("0");c.addClass("hidden");G(a)},Q=function(f,g,h,i,n,p){var q=m.getRoot(g),s=function(a){var b=parseInt(a.type,10);if(i&&0>i.indexOf(b)||n&&!a.isFavourite||!n&&a.isFavourite){return!1}return!0},t=g.find(o.TOGGLE);g.css("min-height",t.outerHeight());g.on("show.bs.collapse",function(){v(g);m.show(q,h,function(a,b,d){return A(b,d).then(function(b){a.append(b);return b}).catch(c.exception)})});g.on("hidden.bs.collapse",function(){w(g)});d.subscribe(j.CONTACT_BLOCKED,function(a){var b=I(g,a);if(b.length){L(b)}});d.subscribe(j.CONTACT_UNBLOCKED,function(a){var b=I(g,a);if(b.length){M(b)}});d.subscribe(j.CONVERSATION_SET_MUTED,function(a){var b=a.id,c=H(g,b);if(c.length){J(c)}});d.subscribe(j.CONVERSATION_UNSET_MUTED,function(a){var b=a.id,c=H(g,b);if(c.length){K(c)}});d.subscribe(j.CONVERSATION_NEW_LAST_MESSAGE,function(a){if(!s(a)){return}var b=a.loggedInUserId,d=a.id,e=H(g,d);a=z(a);if(e.length){var f=m.getContentContainer(g);A([a],b).then(function(a){f.prepend(a);e.remove();return a}).catch(c.exception)}else{N(g,a,b)}});d.subscribe(j.CONVERSATION_DELETED,function(a){var b=H(g,a);delete r[a];if(b.length){O(g,b)}});d.subscribe(j.CONVERSATION_READ,function(a){var b=H(g,a);if(b.length){P(g,b)}});d.subscribe(j.CONVERSATION_SET_FAVOURITE,function(a){var b=null;if(s(a)){b=H(g,a.id);if(!b.length){N(g,z(a),a.loggedInUserId)}}else{b=H(g,a.id);if(b.length){O(g,b)}}});d.subscribe(j.CONVERSATION_UNSET_FAVOURITE,function(a){var b=null;if(s(a)){b=H(g,a.id);if(!b.length){N(g,z(a),a.loggedInUserId)}}else{b=H(g,a.id);if(b.length){O(g,b)}}});b.define(g,[b.events.activate]);g.on(b.events.activate,o.CONVERSATION,function(b,c){var d=a(b.target).closest(o.CONVERSATION),e=d.attr("data-conversation-id"),g=r[e];k.go(f,l.VIEW_CONVERSATION,g,p);c.originalEvent.preventDefault()})};return{show:function show(b,d,e,f,g,h,i,j,k){var l=a(e);if(!l.attr("data-init")){var n=B(g,h,0);Q(b,l,n,g,h,k);if(u(l)){v(l);var o=m.getRoot(l);m.show(o,n,function(a,b,d){return A(b,d).then(function(b){a.append(b);return b}).catch(c.exception)})}i.then(function(a){x(l,a);s=!0}).catch(function(){});j.then(function(a){y(l,a);t=!0}).catch(function(){});l.attr("data-init",!0)}},isVisible:u}}); //# sourceMappingURL=message_drawer_view_overview_section.min.js.map diff --git a/message/amd/build/message_drawer_view_overview_section.min.js.map b/message/amd/build/message_drawer_view_overview_section.min.js.map index 11361a0ace8..8b8c6ac394c 100644 --- a/message/amd/build/message_drawer_view_overview_section.min.js.map +++ b/message/amd/build/message_drawer_view_overview_section.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/message_drawer_view_overview_section.js"],"names":["define","$","CustomEvents","Notification","PubSub","Str","Templates","UserDate","MessageRepository","MessageDrawerEvents","MessageDrawerRouter","MessageDrawerRoutes","LazyLoadList","MessageDrawerViewConversationContants","SELECTORS","TOGGLE","CONVERSATION","BLOCKED_ICON_CONTAINER","LAST_MESSAGE","LAST_MESSAGE_DATE","MUTED_ICON_CONTAINER","UNREAD_COUNT","SECTION_TOTAL_COUNT","SECTION_TOTAL_COUNT_CONTAINER","SECTION_UNREAD_COUNT","PLACEHOLDER_CONTAINER","TEMPLATES","CONVERSATIONS_LIST","CONVERSATIONS_LIST_ITEMS_PLACEHOLDER","LOAD_LIMIT","loadedConversationsById","loadedTotalCounts","loadedUnreadCounts","isVisible","root","getRoot","hasClass","setExpanded","addClass","setCollapsed","removeClass","renderTotalCount","count","container","find","countElement","text","get_string","done","string","attr","numPlaceholders","placeholders","Array","apply","map","render","then","html","placeholderContainer","catch","renderUnreadCount","formatConversationFromEvent","conversation","recursivelyLowercaseKeys","object","Object","keys","reduce","carry","key","isArray","toLowerCase","formatted","messages","message","useridfrom","userfrom","id","conversations","userId","formatMessagePreview","lastMessage","Promise","resolve","isMedia","includes","messagePreview","pix","label","labelPromise","pixPromise","renderPix","all","labelResult","pixResult","exception","mapPromises","length","formattedConversation","imageurl","name","subname","unreadcount","ismuted","lastmessagedate","timecreated","sentfromcurrentuser","lastmessage","otherUser","type","CONVERSATION_TYPES","SELF","members","PRIVATE","member","userid","showonlinestatus","isonline","isblocked","PUBLIC","lastsendername","fullname","formattedConversations","forEach","Date","toDateString","istoday","getLoadCallback","types","includeFavourites","offset","includeSelfConversations","nonSelfConversationTypes","filter","candidate","getConversations","response","slice","setLoadedAll","getTotalConversationCountElement","getTotalUnreadConversationCountElement","incrementTotalConversationCount","element","parseInt","decrementTotalConversationCount","decrementTotalUnreadConversationCount","getConversationElement","conversationId","getConversationElementFromUserId","muteConversation","conversationElement","unmuteConversation","blockContact","unblockContact","createNewConversationFromEvent","existingConversations","listRoot","showContent","hideEmptyMessage","contentContainer","getContentContainer","prepend","deleteConversation","remove","hideContent","showEmptyMessage","markConversationAsRead","unreadCount","registerEventListeners","namespace","loadCallback","fromPanel","conversationBelongsToThisSection","conversationType","indexOf","isFavourite","toggle","css","outerHeight","on","show","append","subscribe","CONTACT_BLOCKED","CONTACT_UNBLOCKED","CONVERSATION_SET_MUTED","CONVERSATION_UNSET_MUTED","CONVERSATION_NEW_LAST_MESSAGE","loggedInUserId","CONVERSATION_DELETED","CONVERSATION_READ","CONVERSATION_SET_FAVOURITE","CONVERSATION_UNSET_FAVOURITE","events","activate","e","data","target","closest","go","VIEW_CONVERSATION","originalEvent","preventDefault","header","body","footer","totalCountPromise","unreadCountPromise"],"mappings":"whBAsBAA,OAA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S,CAAEA,CAFR,CAIV,CAvwBK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Controls a section of the overview page in the message drawer.\n *\n * @module core_message/message_drawer_view_overview_section\n * @copyright 2018 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(\n[\n 'jquery',\n 'core/custom_interaction_events',\n 'core/notification',\n 'core/pubsub',\n 'core/str',\n 'core/templates',\n 'core/user_date',\n 'core_message/message_repository',\n 'core_message/message_drawer_events',\n 'core_message/message_drawer_router',\n 'core_message/message_drawer_routes',\n 'core_message/message_drawer_lazy_load_list',\n 'core_message/message_drawer_view_conversation_constants'\n],\nfunction(\n $,\n CustomEvents,\n Notification,\n PubSub,\n Str,\n Templates,\n UserDate,\n MessageRepository,\n MessageDrawerEvents,\n MessageDrawerRouter,\n MessageDrawerRoutes,\n LazyLoadList,\n MessageDrawerViewConversationContants\n) {\n\n var SELECTORS = {\n TOGGLE: '[data-region=\"toggle\"]',\n CONVERSATION: '[data-conversation-id]',\n BLOCKED_ICON_CONTAINER: '[data-region=\"contact-icon-blocked\"]',\n LAST_MESSAGE: '[data-region=\"last-message\"]',\n LAST_MESSAGE_DATE: '[data-region=\"last-message-date\"]',\n MUTED_ICON_CONTAINER: '[data-region=\"muted-icon-container\"]',\n UNREAD_COUNT: '[data-region=\"unread-count\"]',\n SECTION_TOTAL_COUNT: '[data-region=\"section-total-count\"]',\n SECTION_TOTAL_COUNT_CONTAINER: '[data-region=\"section-total-count-container\"]',\n SECTION_UNREAD_COUNT: '[data-region=\"section-unread-count\"]',\n PLACEHOLDER_CONTAINER: '[data-region=\"placeholder-container\"]'\n };\n\n var TEMPLATES = {\n CONVERSATIONS_LIST: 'core_message/message_drawer_conversations_list',\n CONVERSATIONS_LIST_ITEMS_PLACEHOLDER: 'core_message/message_drawer_conversations_list_items_placeholder'\n };\n\n var LOAD_LIMIT = 50;\n var loadedConversationsById = {};\n var loadedTotalCounts = false;\n var loadedUnreadCounts = false;\n\n /**\n * Get the section visibility status.\n *\n * @param {Object} root The section container element.\n * @return {Bool} Is section visible.\n */\n var isVisible = function(root) {\n return LazyLoadList.getRoot(root).hasClass('show');\n };\n\n /**\n * Set this section as expanded.\n *\n * @param {Object} root The section container element.\n */\n var setExpanded = function(root) {\n root.addClass('expanded');\n };\n\n /**\n * Set this section as collapsed.\n *\n * @param {Object} root The section container element.\n */\n var setCollapsed = function(root) {\n root.removeClass('expanded');\n };\n\n /**\n * Render the total count value and show it for the user. Also update the placeholder\n * HTML for better visuals.\n *\n * @param {Object} root The section container element.\n * @param {Number} count The total count\n */\n var renderTotalCount = function(root, count) {\n var container = root.find(SELECTORS.SECTION_TOTAL_COUNT_CONTAINER);\n var countElement = container.find(SELECTORS.SECTION_TOTAL_COUNT);\n countElement.text(count);\n container.removeClass('hidden');\n Str.get_string('totalconversations', 'core_message', count).done(function(string) {\n container.attr('aria-label', string);\n });\n\n var numPlaceholders = count > 20 ? 20 : count;\n // Array of \"true\" up to the number of placeholders we want.\n var placeholders = Array.apply(null, Array(numPlaceholders)).map(function() {\n return true;\n });\n\n // Replace the current placeholder (loading spinner) with some nicer placeholders that\n // better represent the content.\n Templates.render(TEMPLATES.CONVERSATIONS_LIST_ITEMS_PLACEHOLDER, {placeholders: placeholders})\n .then(function(html) {\n var placeholderContainer = root.find(SELECTORS.PLACEHOLDER_CONTAINER);\n placeholderContainer.html(html);\n return;\n })\n .catch(function() {\n // Silently ignore. Doesn't matter if we can't render the placeholders.\n });\n };\n\n /**\n * Render the unread count value and show it for the user if it's higher than zero.\n *\n * @param {Object} root The section container element.\n * @param {Number} count The unread count\n */\n var renderUnreadCount = function(root, count) {\n var countElement = root.find(SELECTORS.SECTION_UNREAD_COUNT);\n countElement.text(count);\n\n Str.get_string('unreadconversations', 'core_message', count).done(function(string) {\n countElement.attr('aria-label', string);\n });\n\n if (count > 0) {\n countElement.removeClass('hidden');\n }\n };\n\n /**\n * Create a formatted conversation object from the the one we get from events. The new object\n * will be in a format that matches what we receive from the server.\n *\n * @param {Object} conversation\n * @return {Object} formatted conversation.\n */\n var formatConversationFromEvent = function(conversation) {\n // Recursively lowercase all of the keys for an object.\n var recursivelyLowercaseKeys = function(object) {\n return Object.keys(object).reduce(function(carry, key) {\n if ($.isArray(object[key])) {\n carry[key.toLowerCase()] = object[key].map(recursivelyLowercaseKeys);\n } else {\n carry[key.toLowerCase()] = object[key];\n }\n\n return carry;\n }, {});\n };\n\n // Recursively lowercase all of the keys for the conversation.\n var formatted = recursivelyLowercaseKeys(conversation);\n\n // Make sure all messages have the useridfrom property set.\n formatted.messages = formatted.messages.map(function(message) {\n message.useridfrom = message.userfrom.id;\n return message;\n });\n\n return formatted;\n };\n\n /**\n * Render the messages in the overview page.\n *\n * @param {Object} contentContainer Conversations content container.\n * @param {Array} conversations List of conversations to render.\n * @param {Number} userId Logged in user id.\n * @return {Object} jQuery promise.\n */\n var render = function(conversations, userId) {\n\n // Helper to format the last message for rendering.\n // Returns a promise which resolves to either a string, or null\n // (such as in the event of an empty personal space).\n var formatMessagePreview = function(lastMessage) {\n if (!lastMessage) {\n return new Promise(function(resolve) {\n resolve(null);\n });\n }\n var isMedia = lastMessage.text.includes('src');\n\n if (!isMedia) {\n // Try to get the text value of the content.\n // If that's not possible, we'll report it under the catch-all 'other media'.\n var messagePreview = $(lastMessage.text).text();\n if (messagePreview) {\n return new Promise(function(resolve) {\n resolve(messagePreview);\n });\n }\n }\n\n // As a fallback, report unknowns as 'other media' type content.\n var pix = 'i/messagecontentmultimediageneral';\n var label = 'messagecontentmultimediageneral';\n\n if (lastMessage.text.includes(' LOAD_LIMIT) {\n conversations = conversations.slice(0, -1);\n } else {\n LazyLoadList.setLoadedAll(root, true);\n }\n\n offset = offset + LOAD_LIMIT;\n\n conversations.forEach(function(conversation) {\n loadedConversationsById[conversation.id] = conversation;\n });\n\n return conversations;\n })\n .catch(Notification.exception);\n };\n };\n\n /**\n * Get the total count container element.\n *\n * @param {Object} root Overview messages container element.\n * @return {Object} Total count container element.\n */\n var getTotalConversationCountElement = function(root) {\n return root.find(SELECTORS.SECTION_TOTAL_COUNT);\n };\n\n /**\n * Get the unread conversations count container element.\n *\n * @param {Object} root Overview messages container element.\n * @return {Object} Unread conversations count container element.\n */\n var getTotalUnreadConversationCountElement = function(root) {\n return root.find(SELECTORS.SECTION_UNREAD_COUNT);\n };\n\n /**\n * Increment the total conversations count.\n *\n * @param {Object} root Overview messages container element.\n */\n var incrementTotalConversationCount = function(root) {\n if (loadedTotalCounts) {\n var element = getTotalConversationCountElement(root);\n var count = parseInt(element.text());\n count = count + 1;\n element.text(count);\n }\n };\n\n /**\n * Decrement the total conversations count.\n *\n * @param {Object} root Overview messages container element.\n */\n var decrementTotalConversationCount = function(root) {\n if (loadedTotalCounts) {\n var element = getTotalConversationCountElement(root);\n var count = parseInt(element.text());\n count = count - 1;\n element.text(count);\n }\n };\n\n /**\n * Decrement the total unread conversations count.\n *\n * @param {Object} root Overview messages container element.\n */\n var decrementTotalUnreadConversationCount = function(root) {\n if (loadedUnreadCounts) {\n var element = getTotalUnreadConversationCountElement(root);\n var count = parseInt(element.text());\n count = count - 1;\n element.text(count);\n\n if (count < 1) {\n element.addClass('hidden');\n }\n }\n };\n\n /**\n * Get a contact / conversation element.\n *\n * @param {Object} root Overview messages container element.\n * @param {Number} conversationId The conversation id.\n * @return {Object} Conversation element.\n */\n var getConversationElement = function(root, conversationId) {\n return root.find('[data-conversation-id=\"' + conversationId + '\"]');\n };\n\n /**\n * Get a contact / conversation element from a user id.\n *\n * @param {Object} root Overview messages container element.\n * @param {Number} userId The user id.\n * @return {Object} Conversation element.\n */\n var getConversationElementFromUserId = function(root, userId) {\n return root.find('[data-user-id=\"' + userId + '\"]');\n };\n\n /**\n * Show the conversation is muted icon.\n *\n * @param {Object} conversationElement The conversation element.\n */\n var muteConversation = function(conversationElement) {\n conversationElement.find(SELECTORS.MUTED_ICON_CONTAINER).removeClass('hidden');\n };\n\n /**\n * Hide the conversation is muted icon.\n *\n * @param {Object} conversationElement The conversation element.\n */\n var unmuteConversation = function(conversationElement) {\n conversationElement.find(SELECTORS.MUTED_ICON_CONTAINER).addClass('hidden');\n };\n\n /**\n * Show the contact is blocked icon.\n *\n * @param {Object} conversationElement The conversation element.\n */\n var blockContact = function(conversationElement) {\n conversationElement.find(SELECTORS.BLOCKED_ICON_CONTAINER).removeClass('hidden');\n };\n\n /**\n * Hide the contact is blocked icon.\n *\n * @param {Object} conversationElement The conversation element.\n */\n var unblockContact = function(conversationElement) {\n conversationElement.find(SELECTORS.BLOCKED_ICON_CONTAINER).addClass('hidden');\n };\n\n /**\n * Create an render new conversation element in the list of conversations.\n *\n * @param {Object} root Overview messages container element.\n * @param {Object} conversation The conversation.\n * @param {Number} userId The logged in user id.\n * @return {Object} jQuery promise\n */\n var createNewConversationFromEvent = function(root, conversation, userId) {\n var existingConversations = root.find(SELECTORS.CONVERSATION);\n\n if (!existingConversations.length) {\n // If we didn't have any conversations then we need to show\n // the content of the list and hide the empty message.\n var listRoot = LazyLoadList.getRoot(root);\n LazyLoadList.showContent(listRoot);\n LazyLoadList.hideEmptyMessage(listRoot);\n }\n\n // Cache the conversation.\n loadedConversationsById[conversation.id] = conversation;\n\n return render([conversation], userId)\n .then(function(html) {\n var contentContainer = LazyLoadList.getContentContainer(root);\n return contentContainer.prepend(html);\n })\n .then(function() {\n return incrementTotalConversationCount(root);\n })\n .catch(Notification.exception);\n };\n\n /**\n * Delete a conversation from the list of conversations.\n *\n * @param {Object} root Overview messages container element.\n * @param {Object} conversationElement The conversation element.\n */\n var deleteConversation = function(root, conversationElement) {\n conversationElement.remove();\n decrementTotalConversationCount(root);\n\n var conversations = root.find(SELECTORS.CONVERSATION);\n if (!conversations.length) {\n // If we don't have any conversations then we need to hide\n // the content of the list and show the empty message.\n var listRoot = LazyLoadList.getRoot(root);\n LazyLoadList.hideContent(listRoot);\n LazyLoadList.showEmptyMessage(listRoot);\n }\n };\n\n /**\n * Mark a conversation as read.\n *\n * @param {Object} root Overview messages container element.\n * @param {Object} conversationElement The conversation element.\n */\n var markConversationAsRead = function(root, conversationElement) {\n var unreadCount = conversationElement.find(SELECTORS.UNREAD_COUNT);\n unreadCount.text('0');\n unreadCount.addClass('hidden');\n decrementTotalUnreadConversationCount(root);\n };\n\n /**\n * Listen to, and handle events in this section.\n *\n * @param {String} namespace Unique identifier for the Routes\n * @param {Object} root The section container element.\n * @param {Function} loadCallback The callback to load items.\n * @param {Array|null} types The conversation types for this section\n * @param {bool} includeFavourites If this section includes favourites\n * @param {String} fromPanel Routing argument to send if the section is loaded in message index left panel.\n */\n var registerEventListeners = function(namespace, root, loadCallback, types, includeFavourites, fromPanel) {\n var listRoot = LazyLoadList.getRoot(root);\n var conversationBelongsToThisSection = function(conversation) {\n // Make sure the type is an int so that the index of check matches correctly.\n var conversationType = parseInt(conversation.type, 10);\n if (\n // If the conversation type isn't one this section cares about then we can ignore it.\n (types && types.indexOf(conversationType) < 0) ||\n // If this is the favourites section and the conversation isn't a favourite then ignore it.\n (includeFavourites && !conversation.isFavourite) ||\n // If this section doesn't include favourites and the conversation is a favourite then ignore it.\n (!includeFavourites && conversation.isFavourite)\n ) {\n return false;\n }\n\n return true;\n };\n\n // Set the minimum height of the section to the height of the toggle. This\n // smooths out the collapse animation.\n var toggle = root.find(SELECTORS.TOGGLE);\n root.css('min-height', toggle.outerHeight());\n\n root.on('show.bs.collapse', function() {\n setExpanded(root);\n LazyLoadList.show(listRoot, loadCallback, function(contentContainer, conversations, userId) {\n return render(conversations, userId)\n .then(function(html) {\n contentContainer.append(html);\n return html;\n })\n .catch(Notification.exception);\n });\n });\n\n root.on('hidden.bs.collapse', function() {\n setCollapsed(root);\n });\n\n PubSub.subscribe(MessageDrawerEvents.CONTACT_BLOCKED, function(userId) {\n var conversationElement = getConversationElementFromUserId(root, userId);\n if (conversationElement.length) {\n blockContact(conversationElement);\n }\n });\n\n PubSub.subscribe(MessageDrawerEvents.CONTACT_UNBLOCKED, function(userId) {\n var conversationElement = getConversationElementFromUserId(root, userId);\n\n if (conversationElement.length) {\n unblockContact(conversationElement);\n }\n });\n\n PubSub.subscribe(MessageDrawerEvents.CONVERSATION_SET_MUTED, function(conversation) {\n var conversationId = conversation.id;\n var conversationElement = getConversationElement(root, conversationId);\n if (conversationElement.length) {\n muteConversation(conversationElement);\n }\n });\n\n PubSub.subscribe(MessageDrawerEvents.CONVERSATION_UNSET_MUTED, function(conversation) {\n var conversationId = conversation.id;\n var conversationElement = getConversationElement(root, conversationId);\n if (conversationElement.length) {\n unmuteConversation(conversationElement);\n }\n });\n\n PubSub.subscribe(MessageDrawerEvents.CONVERSATION_NEW_LAST_MESSAGE, function(conversation) {\n if (!conversationBelongsToThisSection(conversation)) {\n return;\n }\n\n var loggedInUserId = conversation.loggedInUserId;\n var conversationId = conversation.id;\n var element = getConversationElement(root, conversationId);\n conversation = formatConversationFromEvent(conversation);\n if (element.length) {\n var contentContainer = LazyLoadList.getContentContainer(root);\n render([conversation], loggedInUserId)\n .then(function(html) {\n contentContainer.prepend(html);\n element.remove();\n return html;\n })\n .catch(Notification.exception);\n } else {\n createNewConversationFromEvent(root, conversation, loggedInUserId);\n }\n });\n\n PubSub.subscribe(MessageDrawerEvents.CONVERSATION_DELETED, function(conversationId) {\n var conversationElement = getConversationElement(root, conversationId);\n delete loadedConversationsById[conversationId];\n if (conversationElement.length) {\n deleteConversation(root, conversationElement);\n }\n });\n\n PubSub.subscribe(MessageDrawerEvents.CONVERSATION_READ, function(conversationId) {\n var conversationElement = getConversationElement(root, conversationId);\n if (conversationElement.length) {\n markConversationAsRead(root, conversationElement);\n }\n });\n\n PubSub.subscribe(MessageDrawerEvents.CONVERSATION_SET_FAVOURITE, function(conversation) {\n var conversationElement = null;\n if (conversationBelongsToThisSection(conversation)) {\n conversationElement = getConversationElement(root, conversation.id);\n if (!conversationElement.length) {\n createNewConversationFromEvent(\n root,\n formatConversationFromEvent(conversation),\n conversation.loggedInUserId\n );\n }\n } else {\n conversationElement = getConversationElement(root, conversation.id);\n if (conversationElement.length) {\n deleteConversation(root, conversationElement);\n }\n }\n });\n\n PubSub.subscribe(MessageDrawerEvents.CONVERSATION_UNSET_FAVOURITE, function(conversation) {\n var conversationElement = null;\n if (conversationBelongsToThisSection(conversation)) {\n conversationElement = getConversationElement(root, conversation.id);\n if (!conversationElement.length) {\n createNewConversationFromEvent(\n root,\n formatConversationFromEvent(conversation),\n conversation.loggedInUserId\n );\n }\n } else {\n conversationElement = getConversationElement(root, conversation.id);\n if (conversationElement.length) {\n deleteConversation(root, conversationElement);\n }\n }\n });\n\n CustomEvents.define(root, [CustomEvents.events.activate]);\n root.on(CustomEvents.events.activate, SELECTORS.CONVERSATION, function(e, data) {\n var conversationElement = $(e.target).closest(SELECTORS.CONVERSATION);\n var conversationId = conversationElement.attr('data-conversation-id');\n var conversation = loadedConversationsById[conversationId];\n MessageDrawerRouter.go(namespace, MessageDrawerRoutes.VIEW_CONVERSATION, conversation, fromPanel);\n\n data.originalEvent.preventDefault();\n });\n };\n\n /**\n * Setup the section.\n *\n * @param {String} namespace Unique identifier for the Routes\n * @param {Object} header The header container element.\n * @param {Object} body The section container element.\n * @param {Object} footer The footer container element.\n * @param {Array} types The conversation types that show in this section\n * @param {bool} includeFavourites If this section includes favourites\n * @param {Object} totalCountPromise Resolves wth the total conversations count\n * @param {Object} unreadCountPromise Resolves wth the unread conversations count\n * @param {bool} fromPanel shown in message app panel.\n */\n var show = function(namespace, header, body, footer, types, includeFavourites, totalCountPromise, unreadCountPromise,\n fromPanel) {\n var root = $(body);\n\n if (!root.attr('data-init')) {\n var loadCallback = getLoadCallback(types, includeFavourites, 0);\n registerEventListeners(namespace, root, loadCallback, types, includeFavourites, fromPanel);\n\n if (isVisible(root)) {\n setExpanded(root);\n var listRoot = LazyLoadList.getRoot(root);\n LazyLoadList.show(listRoot, loadCallback, function(contentContainer, conversations, userId) {\n return render(conversations, userId)\n .then(function(html) {\n contentContainer.append(html);\n return html;\n })\n .catch(Notification.exception);\n });\n }\n\n // This is given to us by the calling code because the total counts for all sections\n // are loaded in a single ajax request rather than one request per section.\n totalCountPromise.then(function(count) {\n renderTotalCount(root, count);\n loadedTotalCounts = true;\n return;\n })\n .catch(function() {\n // Silently ignore if we can't updated the counts. No need to bother the user.\n });\n\n // This is given to us by the calling code because the unread counts for all sections\n // are loaded in a single ajax request rather than one request per section.\n unreadCountPromise.then(function(count) {\n renderUnreadCount(root, count);\n loadedUnreadCounts = true;\n return;\n })\n .catch(function() {\n // Silently ignore if we can't updated the counts. No need to bother the user.\n });\n\n root.attr('data-init', true);\n }\n };\n\n return {\n show: show,\n isVisible: isVisible\n };\n});\n"],"file":"message_drawer_view_overview_section.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/message_drawer_view_overview_section.js"],"names":["define","$","CustomEvents","Notification","PubSub","Str","Pending","Templates","UserDate","MessageRepository","MessageDrawerEvents","MessageDrawerRouter","MessageDrawerRoutes","LazyLoadList","MessageDrawerViewConversationContants","SELECTORS","TOGGLE","CONVERSATION","BLOCKED_ICON_CONTAINER","LAST_MESSAGE","LAST_MESSAGE_DATE","MUTED_ICON_CONTAINER","UNREAD_COUNT","SECTION_TOTAL_COUNT","SECTION_TOTAL_COUNT_CONTAINER","SECTION_UNREAD_COUNT","PLACEHOLDER_CONTAINER","TEMPLATES","CONVERSATIONS_LIST","CONVERSATIONS_LIST_ITEMS_PLACEHOLDER","LOAD_LIMIT","loadedConversationsById","loadedTotalCounts","loadedUnreadCounts","isVisible","root","getRoot","hasClass","setExpanded","addClass","setCollapsed","removeClass","renderTotalCount","count","container","find","countElement","text","get_string","done","string","attr","numPlaceholders","placeholders","Array","apply","map","render","then","html","placeholderContainer","catch","renderUnreadCount","formatConversationFromEvent","conversation","recursivelyLowercaseKeys","object","Object","keys","reduce","carry","key","isArray","toLowerCase","formatted","messages","message","useridfrom","userfrom","id","conversations","userId","pending","formatMessagePreview","lastMessage","Promise","resolve","isMedia","includes","messagePreview","pix","label","labelPromise","pixPromise","renderPix","all","labelResult","pixResult","exception","mapPromises","length","formattedConversation","imageurl","name","subname","unreadcount","ismuted","lastmessagedate","timecreated","sentfromcurrentuser","lastmessage","otherUser","type","CONVERSATION_TYPES","SELF","members","PRIVATE","member","userid","showonlinestatus","isonline","isblocked","PUBLIC","lastsendername","fullname","formattedConversations","forEach","Date","toDateString","istoday","js","Deferred","error","getLoadCallback","types","includeFavourites","offset","includeSelfConversations","nonSelfConversationTypes","filter","candidate","getConversations","response","slice","setLoadedAll","getTotalConversationCountElement","getTotalUnreadConversationCountElement","incrementTotalConversationCount","element","parseInt","decrementTotalConversationCount","decrementTotalUnreadConversationCount","getConversationElement","conversationId","getConversationElementFromUserId","muteConversation","conversationElement","unmuteConversation","blockContact","unblockContact","createNewConversationFromEvent","existingConversations","listRoot","showContent","hideEmptyMessage","contentContainer","getContentContainer","prepend","deleteConversation","remove","hideContent","showEmptyMessage","markConversationAsRead","unreadCount","registerEventListeners","namespace","loadCallback","fromPanel","conversationBelongsToThisSection","conversationType","indexOf","isFavourite","toggle","css","outerHeight","on","show","append","subscribe","CONTACT_BLOCKED","CONTACT_UNBLOCKED","CONVERSATION_SET_MUTED","CONVERSATION_UNSET_MUTED","CONVERSATION_NEW_LAST_MESSAGE","loggedInUserId","CONVERSATION_DELETED","CONVERSATION_READ","CONVERSATION_SET_FAVOURITE","CONVERSATION_UNSET_FAVOURITE","events","activate","e","data","target","closest","go","VIEW_CONVERSATION","originalEvent","preventDefault","header","body","footer","totalCountPromise","unreadCountPromise"],"mappings":"whBAsBAA,O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AAhB,CACAX,CAAiB,GAEpB,CAJD,EAKC6B,KALD,CAKO,UAAW,CAEjB,CAPD,EAWAwJ,CAAkB,CAAC3J,IAAnB,CAAwB,SAASf,CAAT,CAAgB,CACpCmB,CAAiB,CAAC3B,CAAD,CAAOQ,CAAP,CAAjB,CACAV,CAAkB,GAErB,CAJD,EAKC4B,KALD,CAKO,UAAW,CAEjB,CAPD,EASA1B,CAAI,CAACgB,IAAL,CAAU,WAAV,IACH,CACJ,CAEM,CAEHjB,SAAS,CAAEA,CAFR,CAIV,CAhxBK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Controls a section of the overview page in the message drawer.\n *\n * @module core_message/message_drawer_view_overview_section\n * @copyright 2018 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(\n[\n 'jquery',\n 'core/custom_interaction_events',\n 'core/notification',\n 'core/pubsub',\n 'core/str',\n 'core/pending',\n 'core/templates',\n 'core/user_date',\n 'core_message/message_repository',\n 'core_message/message_drawer_events',\n 'core_message/message_drawer_router',\n 'core_message/message_drawer_routes',\n 'core_message/message_drawer_lazy_load_list',\n 'core_message/message_drawer_view_conversation_constants'\n],\nfunction(\n $,\n CustomEvents,\n Notification,\n PubSub,\n Str,\n Pending,\n Templates,\n UserDate,\n MessageRepository,\n MessageDrawerEvents,\n MessageDrawerRouter,\n MessageDrawerRoutes,\n LazyLoadList,\n MessageDrawerViewConversationContants\n) {\n\n var SELECTORS = {\n TOGGLE: '[data-region=\"toggle\"]',\n CONVERSATION: '[data-conversation-id]',\n BLOCKED_ICON_CONTAINER: '[data-region=\"contact-icon-blocked\"]',\n LAST_MESSAGE: '[data-region=\"last-message\"]',\n LAST_MESSAGE_DATE: '[data-region=\"last-message-date\"]',\n MUTED_ICON_CONTAINER: '[data-region=\"muted-icon-container\"]',\n UNREAD_COUNT: '[data-region=\"unread-count\"]',\n SECTION_TOTAL_COUNT: '[data-region=\"section-total-count\"]',\n SECTION_TOTAL_COUNT_CONTAINER: '[data-region=\"section-total-count-container\"]',\n SECTION_UNREAD_COUNT: '[data-region=\"section-unread-count\"]',\n PLACEHOLDER_CONTAINER: '[data-region=\"placeholder-container\"]'\n };\n\n var TEMPLATES = {\n CONVERSATIONS_LIST: 'core_message/message_drawer_conversations_list',\n CONVERSATIONS_LIST_ITEMS_PLACEHOLDER: 'core_message/message_drawer_conversations_list_items_placeholder'\n };\n\n var LOAD_LIMIT = 50;\n var loadedConversationsById = {};\n var loadedTotalCounts = false;\n var loadedUnreadCounts = false;\n\n /**\n * Get the section visibility status.\n *\n * @param {Object} root The section container element.\n * @return {Bool} Is section visible.\n */\n var isVisible = function(root) {\n return LazyLoadList.getRoot(root).hasClass('show');\n };\n\n /**\n * Set this section as expanded.\n *\n * @param {Object} root The section container element.\n */\n var setExpanded = function(root) {\n root.addClass('expanded');\n };\n\n /**\n * Set this section as collapsed.\n *\n * @param {Object} root The section container element.\n */\n var setCollapsed = function(root) {\n root.removeClass('expanded');\n };\n\n /**\n * Render the total count value and show it for the user. Also update the placeholder\n * HTML for better visuals.\n *\n * @param {Object} root The section container element.\n * @param {Number} count The total count\n */\n var renderTotalCount = function(root, count) {\n var container = root.find(SELECTORS.SECTION_TOTAL_COUNT_CONTAINER);\n var countElement = container.find(SELECTORS.SECTION_TOTAL_COUNT);\n countElement.text(count);\n container.removeClass('hidden');\n Str.get_string('totalconversations', 'core_message', count).done(function(string) {\n container.attr('aria-label', string);\n });\n\n var numPlaceholders = count > 20 ? 20 : count;\n // Array of \"true\" up to the number of placeholders we want.\n var placeholders = Array.apply(null, Array(numPlaceholders)).map(function() {\n return true;\n });\n\n // Replace the current placeholder (loading spinner) with some nicer placeholders that\n // better represent the content.\n Templates.render(TEMPLATES.CONVERSATIONS_LIST_ITEMS_PLACEHOLDER, {placeholders: placeholders})\n .then(function(html) {\n var placeholderContainer = root.find(SELECTORS.PLACEHOLDER_CONTAINER);\n placeholderContainer.html(html);\n return;\n })\n .catch(function() {\n // Silently ignore. Doesn't matter if we can't render the placeholders.\n });\n };\n\n /**\n * Render the unread count value and show it for the user if it's higher than zero.\n *\n * @param {Object} root The section container element.\n * @param {Number} count The unread count\n */\n var renderUnreadCount = function(root, count) {\n var countElement = root.find(SELECTORS.SECTION_UNREAD_COUNT);\n countElement.text(count);\n\n Str.get_string('unreadconversations', 'core_message', count).done(function(string) {\n countElement.attr('aria-label', string);\n });\n\n if (count > 0) {\n countElement.removeClass('hidden');\n }\n };\n\n /**\n * Create a formatted conversation object from the the one we get from events. The new object\n * will be in a format that matches what we receive from the server.\n *\n * @param {Object} conversation\n * @return {Object} formatted conversation.\n */\n var formatConversationFromEvent = function(conversation) {\n // Recursively lowercase all of the keys for an object.\n var recursivelyLowercaseKeys = function(object) {\n return Object.keys(object).reduce(function(carry, key) {\n if ($.isArray(object[key])) {\n carry[key.toLowerCase()] = object[key].map(recursivelyLowercaseKeys);\n } else {\n carry[key.toLowerCase()] = object[key];\n }\n\n return carry;\n }, {});\n };\n\n // Recursively lowercase all of the keys for the conversation.\n var formatted = recursivelyLowercaseKeys(conversation);\n\n // Make sure all messages have the useridfrom property set.\n formatted.messages = formatted.messages.map(function(message) {\n message.useridfrom = message.userfrom.id;\n return message;\n });\n\n return formatted;\n };\n\n /**\n * Render the messages in the overview page.\n *\n * @param {Object} contentContainer Conversations content container.\n * @param {Array} conversations List of conversations to render.\n * @param {Number} userId Logged in user id.\n * @return {Object} jQuery promise.\n */\n var render = function(conversations, userId) {\n\n // Helper to format the last message for rendering.\n // Returns a promise which resolves to either a string, or null\n // (such as in the event of an empty personal space).\n var pending = new Pending();\n var formatMessagePreview = function(lastMessage) {\n if (!lastMessage) {\n return new Promise(function(resolve) {\n resolve(null);\n });\n }\n var isMedia = lastMessage.text.includes('src');\n\n if (!isMedia) {\n // Try to get the text value of the content.\n // If that's not possible, we'll report it under the catch-all 'other media'.\n var messagePreview = $(lastMessage.text).text();\n if (messagePreview) {\n return new Promise(function(resolve) {\n resolve(messagePreview);\n });\n }\n }\n\n // As a fallback, report unknowns as 'other media' type content.\n var pix = 'i/messagecontentmultimediageneral';\n var label = 'messagecontentmultimediageneral';\n\n if (lastMessage.text.includes(' LOAD_LIMIT) {\n conversations = conversations.slice(0, -1);\n } else {\n LazyLoadList.setLoadedAll(root, true);\n }\n\n offset = offset + LOAD_LIMIT;\n\n conversations.forEach(function(conversation) {\n loadedConversationsById[conversation.id] = conversation;\n });\n\n return conversations;\n })\n .catch(Notification.exception);\n };\n };\n\n /**\n * Get the total count container element.\n *\n * @param {Object} root Overview messages container element.\n * @return {Object} Total count container element.\n */\n var getTotalConversationCountElement = function(root) {\n return root.find(SELECTORS.SECTION_TOTAL_COUNT);\n };\n\n /**\n * Get the unread conversations count container element.\n *\n * @param {Object} root Overview messages container element.\n * @return {Object} Unread conversations count container element.\n */\n var getTotalUnreadConversationCountElement = function(root) {\n return root.find(SELECTORS.SECTION_UNREAD_COUNT);\n };\n\n /**\n * Increment the total conversations count.\n *\n * @param {Object} root Overview messages container element.\n */\n var incrementTotalConversationCount = function(root) {\n if (loadedTotalCounts) {\n var element = getTotalConversationCountElement(root);\n var count = parseInt(element.text());\n count = count + 1;\n element.text(count);\n }\n };\n\n /**\n * Decrement the total conversations count.\n *\n * @param {Object} root Overview messages container element.\n */\n var decrementTotalConversationCount = function(root) {\n if (loadedTotalCounts) {\n var element = getTotalConversationCountElement(root);\n var count = parseInt(element.text());\n count = count - 1;\n element.text(count);\n }\n };\n\n /**\n * Decrement the total unread conversations count.\n *\n * @param {Object} root Overview messages container element.\n */\n var decrementTotalUnreadConversationCount = function(root) {\n if (loadedUnreadCounts) {\n var element = getTotalUnreadConversationCountElement(root);\n var count = parseInt(element.text());\n count = count - 1;\n element.text(count);\n\n if (count < 1) {\n element.addClass('hidden');\n }\n }\n };\n\n /**\n * Get a contact / conversation element.\n *\n * @param {Object} root Overview messages container element.\n * @param {Number} conversationId The conversation id.\n * @return {Object} Conversation element.\n */\n var getConversationElement = function(root, conversationId) {\n return root.find('[data-conversation-id=\"' + conversationId + '\"]');\n };\n\n /**\n * Get a contact / conversation element from a user id.\n *\n * @param {Object} root Overview messages container element.\n * @param {Number} userId The user id.\n * @return {Object} Conversation element.\n */\n var getConversationElementFromUserId = function(root, userId) {\n return root.find('[data-user-id=\"' + userId + '\"]');\n };\n\n /**\n * Show the conversation is muted icon.\n *\n * @param {Object} conversationElement The conversation element.\n */\n var muteConversation = function(conversationElement) {\n conversationElement.find(SELECTORS.MUTED_ICON_CONTAINER).removeClass('hidden');\n };\n\n /**\n * Hide the conversation is muted icon.\n *\n * @param {Object} conversationElement The conversation element.\n */\n var unmuteConversation = function(conversationElement) {\n conversationElement.find(SELECTORS.MUTED_ICON_CONTAINER).addClass('hidden');\n };\n\n /**\n * Show the contact is blocked icon.\n *\n * @param {Object} conversationElement The conversation element.\n */\n var blockContact = function(conversationElement) {\n conversationElement.find(SELECTORS.BLOCKED_ICON_CONTAINER).removeClass('hidden');\n };\n\n /**\n * Hide the contact is blocked icon.\n *\n * @param {Object} conversationElement The conversation element.\n */\n var unblockContact = function(conversationElement) {\n conversationElement.find(SELECTORS.BLOCKED_ICON_CONTAINER).addClass('hidden');\n };\n\n /**\n * Create an render new conversation element in the list of conversations.\n *\n * @param {Object} root Overview messages container element.\n * @param {Object} conversation The conversation.\n * @param {Number} userId The logged in user id.\n * @return {Object} jQuery promise\n */\n var createNewConversationFromEvent = function(root, conversation, userId) {\n var existingConversations = root.find(SELECTORS.CONVERSATION);\n\n if (!existingConversations.length) {\n // If we didn't have any conversations then we need to show\n // the content of the list and hide the empty message.\n var listRoot = LazyLoadList.getRoot(root);\n LazyLoadList.showContent(listRoot);\n LazyLoadList.hideEmptyMessage(listRoot);\n }\n\n // Cache the conversation.\n loadedConversationsById[conversation.id] = conversation;\n\n return render([conversation], userId)\n .then(function(html) {\n var contentContainer = LazyLoadList.getContentContainer(root);\n return contentContainer.prepend(html);\n })\n .then(function() {\n return incrementTotalConversationCount(root);\n })\n .catch(Notification.exception);\n };\n\n /**\n * Delete a conversation from the list of conversations.\n *\n * @param {Object} root Overview messages container element.\n * @param {Object} conversationElement The conversation element.\n */\n var deleteConversation = function(root, conversationElement) {\n conversationElement.remove();\n decrementTotalConversationCount(root);\n\n var conversations = root.find(SELECTORS.CONVERSATION);\n if (!conversations.length) {\n // If we don't have any conversations then we need to hide\n // the content of the list and show the empty message.\n var listRoot = LazyLoadList.getRoot(root);\n LazyLoadList.hideContent(listRoot);\n LazyLoadList.showEmptyMessage(listRoot);\n }\n };\n\n /**\n * Mark a conversation as read.\n *\n * @param {Object} root Overview messages container element.\n * @param {Object} conversationElement The conversation element.\n */\n var markConversationAsRead = function(root, conversationElement) {\n var unreadCount = conversationElement.find(SELECTORS.UNREAD_COUNT);\n unreadCount.text('0');\n unreadCount.addClass('hidden');\n decrementTotalUnreadConversationCount(root);\n };\n\n /**\n * Listen to, and handle events in this section.\n *\n * @param {String} namespace Unique identifier for the Routes\n * @param {Object} root The section container element.\n * @param {Function} loadCallback The callback to load items.\n * @param {Array|null} types The conversation types for this section\n * @param {bool} includeFavourites If this section includes favourites\n * @param {String} fromPanel Routing argument to send if the section is loaded in message index left panel.\n */\n var registerEventListeners = function(namespace, root, loadCallback, types, includeFavourites, fromPanel) {\n var listRoot = LazyLoadList.getRoot(root);\n var conversationBelongsToThisSection = function(conversation) {\n // Make sure the type is an int so that the index of check matches correctly.\n var conversationType = parseInt(conversation.type, 10);\n if (\n // If the conversation type isn't one this section cares about then we can ignore it.\n (types && types.indexOf(conversationType) < 0) ||\n // If this is the favourites section and the conversation isn't a favourite then ignore it.\n (includeFavourites && !conversation.isFavourite) ||\n // If this section doesn't include favourites and the conversation is a favourite then ignore it.\n (!includeFavourites && conversation.isFavourite)\n ) {\n return false;\n }\n\n return true;\n };\n\n // Set the minimum height of the section to the height of the toggle. This\n // smooths out the collapse animation.\n var toggle = root.find(SELECTORS.TOGGLE);\n root.css('min-height', toggle.outerHeight());\n\n root.on('show.bs.collapse', function() {\n setExpanded(root);\n LazyLoadList.show(listRoot, loadCallback, function(contentContainer, conversations, userId) {\n return render(conversations, userId)\n .then(function(html) {\n contentContainer.append(html);\n return html;\n })\n .catch(Notification.exception);\n });\n });\n\n root.on('hidden.bs.collapse', function() {\n setCollapsed(root);\n });\n\n PubSub.subscribe(MessageDrawerEvents.CONTACT_BLOCKED, function(userId) {\n var conversationElement = getConversationElementFromUserId(root, userId);\n if (conversationElement.length) {\n blockContact(conversationElement);\n }\n });\n\n PubSub.subscribe(MessageDrawerEvents.CONTACT_UNBLOCKED, function(userId) {\n var conversationElement = getConversationElementFromUserId(root, userId);\n\n if (conversationElement.length) {\n unblockContact(conversationElement);\n }\n });\n\n PubSub.subscribe(MessageDrawerEvents.CONVERSATION_SET_MUTED, function(conversation) {\n var conversationId = conversation.id;\n var conversationElement = getConversationElement(root, conversationId);\n if (conversationElement.length) {\n muteConversation(conversationElement);\n }\n });\n\n PubSub.subscribe(MessageDrawerEvents.CONVERSATION_UNSET_MUTED, function(conversation) {\n var conversationId = conversation.id;\n var conversationElement = getConversationElement(root, conversationId);\n if (conversationElement.length) {\n unmuteConversation(conversationElement);\n }\n });\n\n PubSub.subscribe(MessageDrawerEvents.CONVERSATION_NEW_LAST_MESSAGE, function(conversation) {\n if (!conversationBelongsToThisSection(conversation)) {\n return;\n }\n\n var loggedInUserId = conversation.loggedInUserId;\n var conversationId = conversation.id;\n var element = getConversationElement(root, conversationId);\n conversation = formatConversationFromEvent(conversation);\n if (element.length) {\n var contentContainer = LazyLoadList.getContentContainer(root);\n render([conversation], loggedInUserId)\n .then(function(html) {\n contentContainer.prepend(html);\n element.remove();\n return html;\n })\n .catch(Notification.exception);\n } else {\n createNewConversationFromEvent(root, conversation, loggedInUserId);\n }\n });\n\n PubSub.subscribe(MessageDrawerEvents.CONVERSATION_DELETED, function(conversationId) {\n var conversationElement = getConversationElement(root, conversationId);\n delete loadedConversationsById[conversationId];\n if (conversationElement.length) {\n deleteConversation(root, conversationElement);\n }\n });\n\n PubSub.subscribe(MessageDrawerEvents.CONVERSATION_READ, function(conversationId) {\n var conversationElement = getConversationElement(root, conversationId);\n if (conversationElement.length) {\n markConversationAsRead(root, conversationElement);\n }\n });\n\n PubSub.subscribe(MessageDrawerEvents.CONVERSATION_SET_FAVOURITE, function(conversation) {\n var conversationElement = null;\n if (conversationBelongsToThisSection(conversation)) {\n conversationElement = getConversationElement(root, conversation.id);\n if (!conversationElement.length) {\n createNewConversationFromEvent(\n root,\n formatConversationFromEvent(conversation),\n conversation.loggedInUserId\n );\n }\n } else {\n conversationElement = getConversationElement(root, conversation.id);\n if (conversationElement.length) {\n deleteConversation(root, conversationElement);\n }\n }\n });\n\n PubSub.subscribe(MessageDrawerEvents.CONVERSATION_UNSET_FAVOURITE, function(conversation) {\n var conversationElement = null;\n if (conversationBelongsToThisSection(conversation)) {\n conversationElement = getConversationElement(root, conversation.id);\n if (!conversationElement.length) {\n createNewConversationFromEvent(\n root,\n formatConversationFromEvent(conversation),\n conversation.loggedInUserId\n );\n }\n } else {\n conversationElement = getConversationElement(root, conversation.id);\n if (conversationElement.length) {\n deleteConversation(root, conversationElement);\n }\n }\n });\n\n CustomEvents.define(root, [CustomEvents.events.activate]);\n root.on(CustomEvents.events.activate, SELECTORS.CONVERSATION, function(e, data) {\n var conversationElement = $(e.target).closest(SELECTORS.CONVERSATION);\n var conversationId = conversationElement.attr('data-conversation-id');\n var conversation = loadedConversationsById[conversationId];\n MessageDrawerRouter.go(namespace, MessageDrawerRoutes.VIEW_CONVERSATION, conversation, fromPanel);\n\n data.originalEvent.preventDefault();\n });\n };\n\n /**\n * Setup the section.\n *\n * @param {String} namespace Unique identifier for the Routes\n * @param {Object} header The header container element.\n * @param {Object} body The section container element.\n * @param {Object} footer The footer container element.\n * @param {Array} types The conversation types that show in this section\n * @param {bool} includeFavourites If this section includes favourites\n * @param {Object} totalCountPromise Resolves wth the total conversations count\n * @param {Object} unreadCountPromise Resolves wth the unread conversations count\n * @param {bool} fromPanel shown in message app panel.\n */\n var show = function(namespace, header, body, footer, types, includeFavourites, totalCountPromise, unreadCountPromise,\n fromPanel) {\n var root = $(body);\n\n if (!root.attr('data-init')) {\n var loadCallback = getLoadCallback(types, includeFavourites, 0);\n registerEventListeners(namespace, root, loadCallback, types, includeFavourites, fromPanel);\n\n if (isVisible(root)) {\n setExpanded(root);\n var listRoot = LazyLoadList.getRoot(root);\n LazyLoadList.show(listRoot, loadCallback, function(contentContainer, conversations, userId) {\n return render(conversations, userId)\n .then(function(html) {\n contentContainer.append(html);\n return html;\n })\n .catch(Notification.exception);\n });\n }\n\n // This is given to us by the calling code because the total counts for all sections\n // are loaded in a single ajax request rather than one request per section.\n totalCountPromise.then(function(count) {\n renderTotalCount(root, count);\n loadedTotalCounts = true;\n return;\n })\n .catch(function() {\n // Silently ignore if we can't updated the counts. No need to bother the user.\n });\n\n // This is given to us by the calling code because the unread counts for all sections\n // are loaded in a single ajax request rather than one request per section.\n unreadCountPromise.then(function(count) {\n renderUnreadCount(root, count);\n loadedUnreadCounts = true;\n return;\n })\n .catch(function() {\n // Silently ignore if we can't updated the counts. No need to bother the user.\n });\n\n root.attr('data-init', true);\n }\n };\n\n return {\n show: show,\n isVisible: isVisible\n };\n});\n"],"file":"message_drawer_view_overview_section.min.js"} \ No newline at end of file diff --git a/message/amd/src/message_drawer_view_overview_section.js b/message/amd/src/message_drawer_view_overview_section.js index 1f8b326fe01..256dfd71542 100644 --- a/message/amd/src/message_drawer_view_overview_section.js +++ b/message/amd/src/message_drawer_view_overview_section.js @@ -27,6 +27,7 @@ define( 'core/notification', 'core/pubsub', 'core/str', + 'core/pending', 'core/templates', 'core/user_date', 'core_message/message_repository', @@ -42,6 +43,7 @@ function( Notification, PubSub, Str, + Pending, Templates, UserDate, MessageRepository, @@ -204,6 +206,7 @@ function( // Helper to format the last message for rendering. // Returns a promise which resolves to either a string, or null // (such as in the event of an empty personal space). + var pending = new Pending(); var formatMessagePreview = function(lastMessage) { if (!lastMessage) { return new Promise(function(resolve) { @@ -309,7 +312,13 @@ function( }); return Templates.render(TEMPLATES.CONVERSATIONS_LIST, {conversations: formattedConversations}); - }).catch(Notification.exception); + }).then(function(html, js) { + pending.resolve(); + return $.Deferred().resolve(html, js); + }).catch(function(error) { + pending.resolve(); + Notification.exception(error); + }); }; /**