Your IP : 216.73.216.95


Current Path : /var/www/ljmtc/cbt/message/amd/build/
Upload File :
Current File : /var/www/ljmtc/cbt/message/amd/build/message_drawer_view_overview_section.min.js.map

{"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","deletedConversationsById","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","tmpElement","document","createElement","innerHTML","replace","isMedia","querySelector","messagePreview","indexOf","pix","label","includes","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","isFavourite","toggle","css","outerHeight","on","show","append","subscribe","CONTACT_BLOCKED","CONTACT_UNBLOCKED","CONVERSATION_SET_MUTED","CONVERSATION_UNSET_MUTED","CONVERSATION_NEW_LAST_MESSAGE","pendingPromise","loggedInUserId","timeadded","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,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,CAWIC,CAXJ,CAYIC,CAZJ,CAaIC,CAbJ,CAcIC,CAdJ,CAeE,IAEMC,CAAAA,CAAS,CAAG,CACZC,MAAM,CAAE,0BADI,CAEZC,YAAY,CAAE,wBAFF,CAGZC,sBAAsB,CAAE,wCAHZ,CAIZC,YAAY,CAAE,gCAJF,CAKZC,iBAAiB,CAAE,qCALP,CAM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AAU,WAAV,IACH,CACJ,CAEM,CAEHjB,SAAS,CAAEA,CAFR,CAIV,CApyBK,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 <http://www.gnu.org/licenses/>.\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 <ryan@moodle.com>\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 deletedConversationsById = {};\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 {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            // Check the message html for a src attribute, indicative of media.\n            // Replace <img with <noimg to stop browsers pre-fetching the image as part of tmp element creation.\n            var tmpElement = document.createElement(\"element\");\n            tmpElement.innerHTML = lastMessage.text.replace(/<img /g, '<noimg ');\n            var isMedia = tmpElement.querySelector(\"[src]\") || false;\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                    // The text value of the message must have no html/script tags.\n                    if (messagePreview.indexOf('<') == -1) {\n                        return 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('<img')) {\n                pix = 'i/messagecontentimage';\n                label = 'messagecontentimage';\n            } else if (lastMessage.text.includes('<video')) {\n                pix = 'i/messagecontentvideo';\n                label = 'messagecontentvideo';\n            } else if (lastMessage.text.includes('<audio')) {\n                pix = 'i/messagecontentaudio';\n                label = 'messagecontentaudio';\n            }\n\n            try {\n                var labelString = await Str.get_string(label, 'core_message');\n                var icon = await Templates.renderPix(pix, 'core', labelString);\n                return icon + ' ' + labelString;\n            } catch (error) {\n                Notification.exception(error);\n                return null;\n            }\n        };\n\n        var mapPromises = conversations.map(function(conversation) {\n\n            var lastMessage = conversation.messages.length ? conversation.messages[conversation.messages.length - 1] : null;\n\n            return formatMessagePreview(lastMessage)\n                .then(function(messagePreview) {\n                    var formattedConversation = {\n                        id: conversation.id,\n                        imageurl: conversation.imageurl,\n                        name: conversation.name,\n                        subname: conversation.subname,\n                        unreadcount: conversation.unreadcount,\n                        ismuted: conversation.ismuted,\n                        lastmessagedate: lastMessage ? lastMessage.timecreated : null,\n                        sentfromcurrentuser: lastMessage ? lastMessage.useridfrom == userId : null,\n                        lastmessage: messagePreview\n                    };\n\n                    var otherUser = null;\n                    if (conversation.type == MessageDrawerViewConversationContants.CONVERSATION_TYPES.SELF) {\n                        // Self-conversations have only one member.\n                        otherUser = conversation.members[0];\n                    } else if (conversation.type == MessageDrawerViewConversationContants.CONVERSATION_TYPES.PRIVATE) {\n                        // For private conversations, remove the current userId from the members to get the other user.\n                        otherUser = conversation.members.reduce(function(carry, member) {\n                            if (!carry && member.id != userId) {\n                                carry = member;\n                            }\n                            return carry;\n                        }, null);\n                    }\n\n                    if (otherUser !== null) {\n                        formattedConversation.userid = otherUser.id;\n                        formattedConversation.showonlinestatus = otherUser.showonlinestatus;\n                        formattedConversation.isonline = otherUser.isonline;\n                        formattedConversation.isblocked = otherUser.isblocked;\n                    }\n\n                    if (conversation.type == MessageDrawerViewConversationContants.CONVERSATION_TYPES.PUBLIC) {\n                        formattedConversation.lastsendername = conversation.members.reduce(function(carry, member) {\n                            if (!carry && lastMessage && member.id == lastMessage.useridfrom) {\n                                carry = member.fullname;\n                            }\n                            return carry;\n                        }, null);\n                    }\n\n                    return formattedConversation;\n                }).catch(Notification.exception);\n        });\n\n        return Promise.all(mapPromises)\n            .then(function(formattedConversations) {\n                formattedConversations.forEach(function(conversation) {\n                    if (new Date().toDateString() == new Date(conversation.lastmessagedate * 1000).toDateString()) {\n                        conversation.istoday = true;\n                    }\n                });\n\n                return Templates.render(TEMPLATES.CONVERSATIONS_LIST, {conversations: formattedConversations});\n            }).then(function(html, js) {\n                pending.resolve();\n                return $.Deferred().resolve(html, js);\n            }).catch(function(error) {\n                pending.resolve();\n                Notification.exception(error);\n            });\n    };\n\n    /**\n     * Build the callback to load conversations.\n     *\n     * @param  {Array|null} types The conversation types for this section.\n     * @param  {bool} includeFavourites Include/exclude favourites.\n     * @param  {Number} offset Result offset\n     * @return {Function}\n     */\n    var getLoadCallback = function(types, includeFavourites, offset) {\n        // Note: This function is a bit messy because we've added the concept of loading\n        // multiple conversations types (e.g. private + self) at once but haven't properly\n        // updated the web service to accept an array of types. Instead we've added a new\n        // parameter for the self type which means we can only ever load self + other type.\n        // This should be improved to make it more extensible in the future. Adding new params\n        // for each type isn't very scalable.\n        var type = null;\n        // Include self conversations in the results by default.\n        var includeSelfConversations = true;\n        if (types && types.length) {\n            // Just get the conversation types that aren't \"self\" for now.\n            var nonSelfConversationTypes = types.filter(function(candidate) {\n                return candidate != MessageDrawerViewConversationContants.CONVERSATION_TYPES.SELF;\n            });\n            // If we're specifically asking for a list of types that doesn't include the self\n            // conversations then we don't need to include them.\n            includeSelfConversations = types.length != nonSelfConversationTypes.length;\n            // As mentioned above the webservice is currently limited to loading one type at a\n            // time (plus self conversations) so let's hope we never change this.\n            type = nonSelfConversationTypes[0];\n        }\n\n        return function(root, userId) {\n            return MessageRepository.getConversations(\n                    userId,\n                    type,\n                    LOAD_LIMIT + 1,\n                    offset,\n                    includeFavourites,\n                    includeSelfConversations\n                )\n                .then(function(response) {\n                    var conversations = response.conversations;\n\n                    if (conversations.length > 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 pendingPromise = new Pending('core_message/message_drawer_view_overview_section:new');\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                        if (deletedConversationsById[conversationId]) {\n                            // This conversation was deleted at some point since the messaging drawer was created.\n                            if (conversation.messages[0].timeadded < deletedConversationsById[conversationId]) {\n                                // The 'new' message was added before the conversation was deleted.\n                                // This is probably stale data.\n                                return;\n                            }\n                        }\n                        contentContainer.prepend(html);\n                        element.remove();\n\n                        return;\n                    })\n                    .then(pendingPromise.resolve)\n                    .catch(Notification.exception);\n            } else if (conversation.messages.length) {\n                createNewConversationFromEvent(root, conversation, loggedInUserId)\n                .then(pendingPromise.resolve)\n                .catch();\n            } else {\n                pendingPromise.resolve();\n            }\n        });\n\n        PubSub.subscribe(MessageDrawerEvents.CONVERSATION_DELETED, function(conversationId) {\n            var conversationElement = getConversationElement(root, conversationId);\n            delete loadedConversationsById[conversationId];\n            deletedConversationsById[conversationId] = new Date();\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"}