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 27ff9bc5851..f95afe38125 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/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}}); +function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){c(a);return}if(h.done){b(i)}else{Promise.resolve(i).then(d,e)}}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var h=a.apply(b,c);function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}f(void 0)})}}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 8b8c6ac394c..9f43297dfb4 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","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,OAAM,qDACN,CACI,QADJ,CAEI,gCAFJ,CAGI,mBAHJ,CAII,aAJJ,CAKI,UALJ,CAMI,cANJ,CAOI,gBAPJ,CAQI,gBARJ,CASI,iCATJ,CAUI,oCAVJ,CAWI,oCAXJ,CAYI,oCAZJ,CAaI,4CAbJ,CAcI,yDAdJ,CADM,CAiBN,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKIC,CALJ,CAMIC,CANJ,CAOIC,CAPJ,CAQIC,CARJ,CASIC,CATJ,CAUIC,CAVJ,CAWI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cesContent":["// 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 +{"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","isMedia","includes","messagePreview","pix","label","labelString","renderPix","icon","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","Promise","all","formattedConversations","forEach","Date","toDateString","istoday","js","resolve","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":"kYAsBAA,OAAM,qDACN,CACI,QADJ,CAE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CAACC,CAAD,CAAQC,CAAR,CAA2B,CAA3B,CAAlC,CACAuC,CAAsB,CAACC,CAAD,CAAY1I,CAAZ,CAAkB2I,CAAlB,CAAgC1C,CAAhC,CAAuCC,CAAvC,CAA0D0C,CAA1D,CAAtB,CAEA,GAAI7I,CAAS,CAACC,CAAD,CAAb,CAAqB,CACjBG,CAAW,CAACH,CAAD,CAAX,CACA,GAAI6H,CAAAA,CAAQ,CAAGnJ,CAAY,CAACuB,OAAb,CAAqBD,CAArB,CAAf,CACAtB,CAAY,CAAC2K,IAAb,CAAkBxB,CAAlB,CAA4Bc,CAA5B,CAA0C,SAASX,CAAT,CAA2BnF,CAA3B,CAA0CC,CAA1C,CAAkD,CACxF,MAAOxB,CAAAA,CAAM,CAACuB,CAAD,CAAgBC,CAAhB,CAAN,CACFvB,IADE,CACG,SAASC,CAAT,CAAe,CACjBwG,CAAgB,CAACsB,MAAjB,CAAwB9H,CAAxB,EACA,MAAOA,CAAAA,CACV,CAJE,EAKFE,KALE,CAKI1D,CAAY,CAAC0F,SALjB,CAMV,CAPD,CAQH,CAIDqH,CAAiB,CAACxJ,IAAlB,CAAuB,SAASf,CAAT,CAAgB,CACnCD,CAAgB,CAACP,CAAD,CAAOQ,CAAP,CAAhB,CACAX,CAAiB,GAEpB,CAJD,EAKC6B,KALD,CAKO,UAAW,CAEjB,CAPD,EAWAsJ,CAAkB,CAACzJ,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,CA7wBK,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\n var formatMessagePreview = async function(lastMessage) {\n if (!lastMessage) {\n return null;\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 messagePreview;\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 256dfd71542..e708a446713 100644 --- a/message/amd/src/message_drawer_view_overview_section.js +++ b/message/amd/src/message_drawer_view_overview_section.js @@ -207,11 +207,10 @@ function( // 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) { + + var formatMessagePreview = async function(lastMessage) { if (!lastMessage) { - return new Promise(function(resolve) { - resolve(null); - }); + return null; } var isMedia = lastMessage.text.includes('src'); @@ -220,9 +219,7 @@ function( // If that's not possible, we'll report it under the catch-all 'other media'. var messagePreview = $(lastMessage.text).text(); if (messagePreview) { - return new Promise(function(resolve) { - resolve(messagePreview); - }); + return messagePreview; } } @@ -241,14 +238,14 @@ function( label = 'messagecontentaudio'; } - var labelPromise = Str.get_string(label, 'core_message'); - var pixPromise = labelPromise.then(function(string) { - return Templates.renderPix(pix, 'core', string); - }); - return Promise.all([labelPromise, pixPromise]) - .then(function([labelResult, pixResult]) { - return pixResult + ' ' + labelResult; - }).catch(Notification.exception); + try { + var labelString = await Str.get_string(label, 'core_message'); + var icon = await Templates.renderPix(pix, 'core', labelString); + return icon + ' ' + labelString; + } catch (error) { + Notification.exception(error); + return null; + } }; var mapPromises = conversations.map(function(conversation) {