diff --git a/message/amd/build/message_drawer_events.min.js b/message/amd/build/message_drawer_events.min.js index bb039b6aaf02e..0f5f1d51c780d 100644 --- a/message/amd/build/message_drawer_events.min.js +++ b/message/amd/build/message_drawer_events.min.js @@ -1,10 +1,3 @@ -/** - * Events for the message drawer. - * - * @module core_message/message_drawer_events - * @copyright 2018 Ryan Wyllie - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -define("core_message/message_drawer_events",[],(function(){return{CREATE_CONVERSATION_WITH_USER:"message-drawer-create-conversation-with-user",CONTACT_BLOCKED:"message-drawer-contact-blocked",CONTACT_UNBLOCKED:"message-drawer-contact-unblocked",CONTACT_ADDED:"message-drawer-contact-added",CONTACT_REMOVED:"message-drawer-contact-removed",CONTACT_REQUEST_ACCEPTED:"message-drawer-contact-request-accepted",CONTACT_REQUEST_DECLINED:"message-drawer-contact-request-declined",CONVERSATION_CREATED:"message-drawer-conversation-created",CONVERSATION_NEW_LAST_MESSAGE:"message-drawer-conversation-new-last-message",CONVERSATION_DELETED:"message-drawer-conversation-deleted",CONVERSATION_READ:"message-drawer-conversation-read",CONVERSATION_SET_FAVOURITE:"message-drawer-conversation-set-favourite",CONVERSATION_SET_MUTED:"message-drawer-conversation-set-muted",CONVERSATION_UNSET_FAVOURITE:"message-drawer-conversation-unset-favourite",CONVERSATION_UNSET_MUTED:"message-drawer-conversation-unset-muted",PREFERENCES_UPDATED:"message-drawer-preferences-updated",READY:"message-drawer-ready",ROUTE_CHANGED:"message-drawer-route-change",SHOW:"message-drawer-show",HIDE:"message-drawer-hide",TOGGLE_VISIBILITY:"message-drawer-toggle",SHOW_CONVERSATION:"message-drawer-show-conversation",SHOW_SETTINGS:"message-drawer-show-settings"}})); +define("core_message/message_drawer_events",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;return _exports.default={CREATE_CONVERSATION_WITH_USER:"message-drawer-create-conversation-with-user",CONTACT_BLOCKED:"message-drawer-contact-blocked",CONTACT_UNBLOCKED:"message-drawer-contact-unblocked",CONTACT_ADDED:"message-drawer-contact-added",CONTACT_REMOVED:"message-drawer-contact-removed",CONTACT_REQUEST_ACCEPTED:"message-drawer-contact-request-accepted",CONTACT_REQUEST_DECLINED:"message-drawer-contact-request-declined",CONVERSATION_CREATED:"message-drawer-conversation-created",CONVERSATION_NEW_LAST_MESSAGE:"message-drawer-conversation-new-last-message",CONVERSATION_DELETED:"message-drawer-conversation-deleted",CONVERSATION_READ:"message-drawer-conversation-read",CONVERSATION_SET_FAVOURITE:"message-drawer-conversation-set-favourite",CONVERSATION_SET_MUTED:"message-drawer-conversation-set-muted",CONVERSATION_UNSET_FAVOURITE:"message-drawer-conversation-unset-favourite",CONVERSATION_UNSET_MUTED:"message-drawer-conversation-unset-muted",PREFERENCES_UPDATED:"message-drawer-preferences-updated",READY:"message-drawer-ready",ROUTE_CHANGED:"message-drawer-route-change",SHOW:"message-drawer-show",HIDE:"message-drawer-hide",TOGGLE_VISIBILITY:"message-drawer-toggle",SHOW_CONVERSATION:"message-drawer-show-conversation",SHOW_SETTINGS:"message-drawer-show-settings"},_exports.default})); //# sourceMappingURL=message_drawer_events.min.js.map \ No newline at end of file diff --git a/message/amd/build/message_drawer_events.min.js.map b/message/amd/build/message_drawer_events.min.js.map index de44ee61bc3f0..8ec9535c460f3 100644 --- a/message/amd/build/message_drawer_events.min.js.map +++ b/message/amd/build/message_drawer_events.min.js.map @@ -1 +1 @@ -{"version":3,"file":"message_drawer_events.min.js","sources":["../src/message_drawer_events.js"],"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 * Events for the message drawer.\n *\n * @module core_message/message_drawer_events\n * @copyright 2018 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([], function() {\n return {\n CREATE_CONVERSATION_WITH_USER: 'message-drawer-create-conversation-with-user',\n CONTACT_BLOCKED: 'message-drawer-contact-blocked',\n CONTACT_UNBLOCKED: 'message-drawer-contact-unblocked',\n CONTACT_ADDED: 'message-drawer-contact-added',\n CONTACT_REMOVED: 'message-drawer-contact-removed',\n CONTACT_REQUEST_ACCEPTED: 'message-drawer-contact-request-accepted',\n CONTACT_REQUEST_DECLINED: 'message-drawer-contact-request-declined',\n CONVERSATION_CREATED: 'message-drawer-conversation-created',\n CONVERSATION_NEW_LAST_MESSAGE: 'message-drawer-conversation-new-last-message',\n CONVERSATION_DELETED: 'message-drawer-conversation-deleted',\n CONVERSATION_READ: 'message-drawer-conversation-read',\n CONVERSATION_SET_FAVOURITE: 'message-drawer-conversation-set-favourite',\n CONVERSATION_SET_MUTED: 'message-drawer-conversation-set-muted',\n CONVERSATION_UNSET_FAVOURITE: 'message-drawer-conversation-unset-favourite',\n CONVERSATION_UNSET_MUTED: 'message-drawer-conversation-unset-muted',\n PREFERENCES_UPDATED: 'message-drawer-preferences-updated',\n READY: 'message-drawer-ready',\n ROUTE_CHANGED: 'message-drawer-route-change',\n SHOW: 'message-drawer-show',\n HIDE: 'message-drawer-hide',\n TOGGLE_VISIBILITY: 'message-drawer-toggle',\n SHOW_CONVERSATION: 'message-drawer-show-conversation',\n SHOW_SETTINGS: 'message-drawer-show-settings',\n };\n});\n"],"names":["define","CREATE_CONVERSATION_WITH_USER","CONTACT_BLOCKED","CONTACT_UNBLOCKED","CONTACT_ADDED","CONTACT_REMOVED","CONTACT_REQUEST_ACCEPTED","CONTACT_REQUEST_DECLINED","CONVERSATION_CREATED","CONVERSATION_NEW_LAST_MESSAGE","CONVERSATION_DELETED","CONVERSATION_READ","CONVERSATION_SET_FAVOURITE","CONVERSATION_SET_MUTED","CONVERSATION_UNSET_FAVOURITE","CONVERSATION_UNSET_MUTED","PREFERENCES_UPDATED","READY","ROUTE_CHANGED","SHOW","HIDE","TOGGLE_VISIBILITY","SHOW_CONVERSATION","SHOW_SETTINGS"],"mappings":";;;;;;;AAsBAA,4CAAO,IAAI,iBACA,CACHC,8BAA+B,+CAC/BC,gBAAiB,iCACjBC,kBAAmB,mCACnBC,cAAe,+BACfC,gBAAiB,iCACjBC,yBAA0B,0CAC1BC,yBAA0B,0CAC1BC,qBAAsB,sCACtBC,8BAA+B,+CAC/BC,qBAAsB,sCACtBC,kBAAmB,mCACnBC,2BAA4B,4CAC5BC,uBAAwB,wCACxBC,6BAA8B,8CAC9BC,yBAA0B,0CAC1BC,oBAAqB,qCACrBC,MAAO,uBACPC,cAAe,8BACfC,KAAM,sBACNC,KAAM,sBACNC,kBAAmB,wBACnBC,kBAAmB,mCACnBC,cAAe"} \ No newline at end of file +{"version":3,"file":"message_drawer_events.min.js","sources":["../src/message_drawer_events.js"],"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 * Events for the message drawer.\n *\n * @module core_message/message_drawer_events\n * @copyright 2018 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default {\n CREATE_CONVERSATION_WITH_USER: 'message-drawer-create-conversation-with-user',\n CONTACT_BLOCKED: 'message-drawer-contact-blocked',\n CONTACT_UNBLOCKED: 'message-drawer-contact-unblocked',\n CONTACT_ADDED: 'message-drawer-contact-added',\n CONTACT_REMOVED: 'message-drawer-contact-removed',\n CONTACT_REQUEST_ACCEPTED: 'message-drawer-contact-request-accepted',\n CONTACT_REQUEST_DECLINED: 'message-drawer-contact-request-declined',\n CONVERSATION_CREATED: 'message-drawer-conversation-created',\n CONVERSATION_NEW_LAST_MESSAGE: 'message-drawer-conversation-new-last-message',\n CONVERSATION_DELETED: 'message-drawer-conversation-deleted',\n CONVERSATION_READ: 'message-drawer-conversation-read',\n CONVERSATION_SET_FAVOURITE: 'message-drawer-conversation-set-favourite',\n CONVERSATION_SET_MUTED: 'message-drawer-conversation-set-muted',\n CONVERSATION_UNSET_FAVOURITE: 'message-drawer-conversation-unset-favourite',\n CONVERSATION_UNSET_MUTED: 'message-drawer-conversation-unset-muted',\n PREFERENCES_UPDATED: 'message-drawer-preferences-updated',\n READY: 'message-drawer-ready',\n ROUTE_CHANGED: 'message-drawer-route-change',\n SHOW: 'message-drawer-show',\n HIDE: 'message-drawer-hide',\n TOGGLE_VISIBILITY: 'message-drawer-toggle',\n SHOW_CONVERSATION: 'message-drawer-show-conversation',\n SHOW_SETTINGS: 'message-drawer-show-settings',\n};\n"],"names":["CREATE_CONVERSATION_WITH_USER","CONTACT_BLOCKED","CONTACT_UNBLOCKED","CONTACT_ADDED","CONTACT_REMOVED","CONTACT_REQUEST_ACCEPTED","CONTACT_REQUEST_DECLINED","CONVERSATION_CREATED","CONVERSATION_NEW_LAST_MESSAGE","CONVERSATION_DELETED","CONVERSATION_READ","CONVERSATION_SET_FAVOURITE","CONVERSATION_SET_MUTED","CONVERSATION_UNSET_FAVOURITE","CONVERSATION_UNSET_MUTED","PREFERENCES_UPDATED","READY","ROUTE_CHANGED","SHOW","HIDE","TOGGLE_VISIBILITY","SHOW_CONVERSATION","SHOW_SETTINGS"],"mappings":"oLAsBe,CACXA,8BAA+B,+CAC/BC,gBAAiB,iCACjBC,kBAAmB,mCACnBC,cAAe,+BACfC,gBAAiB,iCACjBC,yBAA0B,0CAC1BC,yBAA0B,0CAC1BC,qBAAsB,sCACtBC,8BAA+B,+CAC/BC,qBAAsB,sCACtBC,kBAAmB,mCACnBC,2BAA4B,4CAC5BC,uBAAwB,wCACxBC,6BAA8B,8CAC9BC,yBAA0B,0CAC1BC,oBAAqB,qCACrBC,MAAO,uBACPC,cAAe,8BACfC,KAAM,sBACNC,KAAM,sBACNC,kBAAmB,wBACnBC,kBAAmB,mCACnBC,cAAe"} \ No newline at end of file diff --git a/message/amd/build/message_drawer_helper.min.js b/message/amd/build/message_drawer_helper.min.js index 57b8163bf9860..db82a23f9c06b 100644 --- a/message/amd/build/message_drawer_helper.min.js +++ b/message/amd/build/message_drawer_helper.min.js @@ -1,10 +1,10 @@ +define("core_message/message_drawer_helper",["exports","core/pubsub","core_message/message_drawer_events"],(function(_exports,_pubsub,_message_drawer_events){var obj; /** - * Provides some helper functions to trigger actions in the message drawer. - * - * @module core_message/message_drawer_helper - * @copyright 2018 Ryan Wyllie - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -define("core_message/message_drawer_helper",["core/pubsub","core_message/message_drawer_events"],(function(PubSub,MessageDrawerEvents){var drawerMarkedReady=!1,waitForDrawerToLoad=function(){return new Promise((function(resolve){drawerMarkedReady?resolve():PubSub.subscribe(MessageDrawerEvents.READY,resolve)}))};return{createConversationWithUser:function(args){waitForDrawerToLoad().then((function(){PubSub.publish(MessageDrawerEvents.CREATE_CONVERSATION_WITH_USER,args)})).catch()},hide:function(){waitForDrawerToLoad().then((function(){PubSub.publish(MessageDrawerEvents.HIDE)})).catch()},show:function(){waitForDrawerToLoad().then((function(){PubSub.publish(MessageDrawerEvents.SHOW)})).catch()},showConversation:function(args){waitForDrawerToLoad().then((function(){PubSub.publish(MessageDrawerEvents.SHOW_CONVERSATION,args)})).catch()},showSettings:function(){waitForDrawerToLoad().then((function(){PubSub.publish(MessageDrawerEvents.SHOW_SETTINGS)})).catch()},markDrawerReady:function(){drawerMarkedReady=!0,PubSub.publish(MessageDrawerEvents.READY)}}})); + * Provides some helper functions to trigger actions in the message drawer. + * + * @module core_message/message_drawer_helper + * @copyright 2018 Ryan Wyllie + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.waitForDrawerToLoad=_exports.showSettings=_exports.showConversation=_exports.show=_exports.markDrawerReady=_exports.hide=_exports.createConversationWithUser=void 0,_message_drawer_events=(obj=_message_drawer_events)&&obj.__esModule?obj:{default:obj};let drawerMarkedReady=!1;_exports.createConversationWithUser=async args=>{await waitForDrawerToLoad(),(0,_pubsub.publish)(_message_drawer_events.default.CREATE_CONVERSATION_WITH_USER,args)};_exports.hide=async()=>{await waitForDrawerToLoad(),(0,_pubsub.publish)(_message_drawer_events.default.HIDE)};_exports.show=async()=>{await waitForDrawerToLoad(),(0,_pubsub.publish)(_message_drawer_events.default.SHOW)};_exports.showConversation=async args=>{await waitForDrawerToLoad(),(0,_pubsub.publish)(_message_drawer_events.default.SHOW_CONVERSATION,args)};_exports.showSettings=async()=>{await waitForDrawerToLoad(),(0,_pubsub.publish)(_message_drawer_events.default.SHOW_SETTINGS)};const waitForDrawerToLoad=()=>new Promise((resolve=>{drawerMarkedReady?resolve():(0,_pubsub.subscribe)(_message_drawer_events.default.READY,resolve)}));_exports.waitForDrawerToLoad=waitForDrawerToLoad;_exports.markDrawerReady=()=>{drawerMarkedReady=!0,(0,_pubsub.publish)(_message_drawer_events.default.READY)}})); //# sourceMappingURL=message_drawer_helper.min.js.map \ No newline at end of file diff --git a/message/amd/build/message_drawer_helper.min.js.map b/message/amd/build/message_drawer_helper.min.js.map index d3a7d92016527..37f7acf75f464 100644 --- a/message/amd/build/message_drawer_helper.min.js.map +++ b/message/amd/build/message_drawer_helper.min.js.map @@ -1 +1 @@ -{"version":3,"file":"message_drawer_helper.min.js","sources":["../src/message_drawer_helper.js"],"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 * Provides some helper functions to trigger actions in the message drawer.\n *\n * @module core_message/message_drawer_helper\n * @copyright 2018 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(\n[\n 'core/pubsub',\n 'core_message/message_drawer_events'\n],\nfunction(\n PubSub,\n MessageDrawerEvents\n) {\n\n /** @property {boolean} Whether the drawer is ready or not */\n var drawerMarkedReady = false;\n\n /**\n * Trigger an event to create a new conversation in the message drawer.\n *\n * @param {object} args\n * @param {Number} args.userId The user id to start a conversation.\n */\n var createConversationWithUser = function(args) {\n waitForDrawerToLoad().then(function () {\n PubSub.publish(MessageDrawerEvents.CREATE_CONVERSATION_WITH_USER, args);\n return;\n }).catch();\n };\n\n /**\n * Trigger an event to hide the message drawer.\n */\n var hide = function() {\n waitForDrawerToLoad().then(function () {\n PubSub.publish(MessageDrawerEvents.HIDE);\n return;\n }).catch();\n };\n\n /**\n * Trigger an event to show the message drawer.\n */\n var show = function() {\n waitForDrawerToLoad().then(function () {\n PubSub.publish(MessageDrawerEvents.SHOW);\n return;\n }).catch();\n };\n\n /**\n * Trigger an event to show the given conversation.\n *\n * @param {object} args\n * @param {int} args.conversationId Id for the conversation to show.\n */\n var showConversation = function(args) {\n waitForDrawerToLoad().then(function () {\n PubSub.publish(MessageDrawerEvents.SHOW_CONVERSATION, args);\n return;\n }).catch();\n };\n\n /**\n * Trigger an event to show messaging settings.\n */\n var showSettings = function() {\n waitForDrawerToLoad().then(function() {\n PubSub.publish(MessageDrawerEvents.SHOW_SETTINGS);\n return;\n }).catch();\n };\n\n /**\n * Helper to wait for the drawer to be ready before performing an action.\n *\n * @returns {Promise}\n */\n var waitForDrawerToLoad = function() {\n return new Promise(function(resolve) {\n if (drawerMarkedReady) {\n resolve();\n } else {\n PubSub.subscribe(MessageDrawerEvents.READY, resolve);\n }\n });\n };\n\n /**\n * Helper to allow the drawer to mark itself as ready.\n */\n var markDrawerReady = function() {\n drawerMarkedReady = true;\n PubSub.publish(MessageDrawerEvents.READY);\n };\n\n return {\n createConversationWithUser: createConversationWithUser,\n hide: hide,\n show: show,\n showConversation: showConversation,\n showSettings: showSettings,\n markDrawerReady: markDrawerReady,\n };\n});\n"],"names":["define","PubSub","MessageDrawerEvents","drawerMarkedReady","waitForDrawerToLoad","Promise","resolve","subscribe","READY","createConversationWithUser","args","then","publish","CREATE_CONVERSATION_WITH_USER","catch","hide","HIDE","show","SHOW","showConversation","SHOW_CONVERSATION","showSettings","SHOW_SETTINGS","markDrawerReady"],"mappings":";;;;;;;AAsBAA,4CACA,CACI,cACA,uCAEJ,SACIC,OACAC,yBAIIC,mBAAoB,EA+DpBC,oBAAsB,kBACf,IAAIC,SAAQ,SAASC,SACpBH,kBACAG,UAEAL,OAAOM,UAAUL,oBAAoBM,MAAOF,mBAajD,CACHG,2BA1E6B,SAASC,MACtCN,sBAAsBO,MAAK,WACvBV,OAAOW,QAAQV,oBAAoBW,8BAA+BH,SAEnEI,SAuEHC,KAjEO,WACPX,sBAAsBO,MAAK,WACvBV,OAAOW,QAAQV,oBAAoBc,SAEpCF,SA8DHG,KAxDO,WACPb,sBAAsBO,MAAK,WACvBV,OAAOW,QAAQV,oBAAoBgB,SAEpCJ,SAqDHK,iBA5CmB,SAAST,MAC5BN,sBAAsBO,MAAK,WACvBV,OAAOW,QAAQV,oBAAoBkB,kBAAmBV,SAEvDI,SAyCHO,aAnCe,WACfjB,sBAAsBO,MAAK,WACvBV,OAAOW,QAAQV,oBAAoBoB,kBAEpCR,SAgCHS,gBAXkB,WAClBpB,mBAAoB,EACpBF,OAAOW,QAAQV,oBAAoBM"} \ No newline at end of file +{"version":3,"file":"message_drawer_helper.min.js","sources":["../src/message_drawer_helper.js"],"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 * Provides some helper functions to trigger actions in the message drawer.\n *\n * @module core_message/message_drawer_helper\n * @copyright 2018 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {publish, subscribe} from 'core/pubsub';\nimport MessageDrawerEvents from 'core_message/message_drawer_events';\n\n/** @property {boolean} Whether the drawer is ready or not */\nlet drawerMarkedReady = false;\n\n/**\n * Trigger an event to create a new conversation in the message drawer.\n *\n * @param {object} args\n * @param {Number} args.userId The user id to start a conversation.\n */\nexport const createConversationWithUser = async(args) => {\n await waitForDrawerToLoad();\n publish(MessageDrawerEvents.CREATE_CONVERSATION_WITH_USER, args);\n};\n\n/**\n * Trigger an event to hide the message drawer.\n */\nexport const hide = async() => {\n await waitForDrawerToLoad();\n publish(MessageDrawerEvents.HIDE);\n};\n\n/**\n * Trigger an event to show the message drawer.\n */\nexport const show = async() => {\n await waitForDrawerToLoad();\n publish(MessageDrawerEvents.SHOW);\n};\n\n/**\n * Trigger an event to show the given conversation.\n *\n * @param {object} args\n * @param {int} args.conversationId Id for the conversation to show.\n */\nexport const showConversation = async(args) => {\n await waitForDrawerToLoad();\n publish(MessageDrawerEvents.SHOW_CONVERSATION, args);\n};\n\n/**\n * Trigger an event to show messaging settings.\n */\nexport const showSettings = async() => {\n await waitForDrawerToLoad();\n publish(MessageDrawerEvents.SHOW_SETTINGS);\n};\n\n/**\n * Helper to wait for the drawer to be ready before performing an action.\n *\n * @returns {Promise}\n */\nexport const waitForDrawerToLoad = () => new Promise((resolve) => {\n if (drawerMarkedReady) {\n resolve();\n } else {\n subscribe(MessageDrawerEvents.READY, resolve);\n }\n});\n\n/**\n * Helper to allow the drawer to mark itself as ready.\n */\nexport const markDrawerReady = () => {\n drawerMarkedReady = true;\n publish(MessageDrawerEvents.READY);\n};\n"],"names":["drawerMarkedReady","async","waitForDrawerToLoad","MessageDrawerEvents","CREATE_CONVERSATION_WITH_USER","args","HIDE","SHOW","SHOW_CONVERSATION","SHOW_SETTINGS","Promise","resolve","READY"],"mappings":";;;;;;;oUA2BIA,mBAAoB,sCAQkBC,MAAAA,aAChCC,0CACEC,+BAAoBC,8BAA+BC,qBAM3CJ,gBACVC,0CACEC,+BAAoBG,qBAMZL,gBACVC,0CACEC,+BAAoBI,iCASAN,MAAAA,aACtBC,0CACEC,+BAAoBK,kBAAmBH,6BAMvBJ,gBAClBC,0CACEC,+BAAoBM,sBAQnBP,oBAAsB,IAAM,IAAIQ,SAASC,UAC9CX,kBACAW,gCAEUR,+BAAoBS,MAAOD,sFAOd,KAC3BX,mBAAoB,sBACZG,+BAAoBS"} \ No newline at end of file diff --git a/message/amd/src/message_drawer_events.js b/message/amd/src/message_drawer_events.js index dba9a5d676bc3..dfb0580dcca5f 100644 --- a/message/amd/src/message_drawer_events.js +++ b/message/amd/src/message_drawer_events.js @@ -20,30 +20,28 @@ * @copyright 2018 Ryan Wyllie * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -define([], function() { - return { - CREATE_CONVERSATION_WITH_USER: 'message-drawer-create-conversation-with-user', - CONTACT_BLOCKED: 'message-drawer-contact-blocked', - CONTACT_UNBLOCKED: 'message-drawer-contact-unblocked', - CONTACT_ADDED: 'message-drawer-contact-added', - CONTACT_REMOVED: 'message-drawer-contact-removed', - CONTACT_REQUEST_ACCEPTED: 'message-drawer-contact-request-accepted', - CONTACT_REQUEST_DECLINED: 'message-drawer-contact-request-declined', - CONVERSATION_CREATED: 'message-drawer-conversation-created', - CONVERSATION_NEW_LAST_MESSAGE: 'message-drawer-conversation-new-last-message', - CONVERSATION_DELETED: 'message-drawer-conversation-deleted', - CONVERSATION_READ: 'message-drawer-conversation-read', - CONVERSATION_SET_FAVOURITE: 'message-drawer-conversation-set-favourite', - CONVERSATION_SET_MUTED: 'message-drawer-conversation-set-muted', - CONVERSATION_UNSET_FAVOURITE: 'message-drawer-conversation-unset-favourite', - CONVERSATION_UNSET_MUTED: 'message-drawer-conversation-unset-muted', - PREFERENCES_UPDATED: 'message-drawer-preferences-updated', - READY: 'message-drawer-ready', - ROUTE_CHANGED: 'message-drawer-route-change', - SHOW: 'message-drawer-show', - HIDE: 'message-drawer-hide', - TOGGLE_VISIBILITY: 'message-drawer-toggle', - SHOW_CONVERSATION: 'message-drawer-show-conversation', - SHOW_SETTINGS: 'message-drawer-show-settings', - }; -}); +export default { + CREATE_CONVERSATION_WITH_USER: 'message-drawer-create-conversation-with-user', + CONTACT_BLOCKED: 'message-drawer-contact-blocked', + CONTACT_UNBLOCKED: 'message-drawer-contact-unblocked', + CONTACT_ADDED: 'message-drawer-contact-added', + CONTACT_REMOVED: 'message-drawer-contact-removed', + CONTACT_REQUEST_ACCEPTED: 'message-drawer-contact-request-accepted', + CONTACT_REQUEST_DECLINED: 'message-drawer-contact-request-declined', + CONVERSATION_CREATED: 'message-drawer-conversation-created', + CONVERSATION_NEW_LAST_MESSAGE: 'message-drawer-conversation-new-last-message', + CONVERSATION_DELETED: 'message-drawer-conversation-deleted', + CONVERSATION_READ: 'message-drawer-conversation-read', + CONVERSATION_SET_FAVOURITE: 'message-drawer-conversation-set-favourite', + CONVERSATION_SET_MUTED: 'message-drawer-conversation-set-muted', + CONVERSATION_UNSET_FAVOURITE: 'message-drawer-conversation-unset-favourite', + CONVERSATION_UNSET_MUTED: 'message-drawer-conversation-unset-muted', + PREFERENCES_UPDATED: 'message-drawer-preferences-updated', + READY: 'message-drawer-ready', + ROUTE_CHANGED: 'message-drawer-route-change', + SHOW: 'message-drawer-show', + HIDE: 'message-drawer-hide', + TOGGLE_VISIBILITY: 'message-drawer-toggle', + SHOW_CONVERSATION: 'message-drawer-show-conversation', + SHOW_SETTINGS: 'message-drawer-show-settings', +}; diff --git a/message/amd/src/message_drawer_helper.js b/message/amd/src/message_drawer_helper.js index 578cc00582545..411ae65609f88 100644 --- a/message/amd/src/message_drawer_helper.js +++ b/message/amd/src/message_drawer_helper.js @@ -20,104 +20,76 @@ * @copyright 2018 Ryan Wyllie * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -define( -[ - 'core/pubsub', - 'core_message/message_drawer_events' -], -function( - PubSub, - MessageDrawerEvents -) { - /** @property {boolean} Whether the drawer is ready or not */ - var drawerMarkedReady = false; +import {publish, subscribe} from 'core/pubsub'; +import MessageDrawerEvents from 'core_message/message_drawer_events'; - /** - * Trigger an event to create a new conversation in the message drawer. - * - * @param {object} args - * @param {Number} args.userId The user id to start a conversation. - */ - var createConversationWithUser = function(args) { - waitForDrawerToLoad().then(function () { - PubSub.publish(MessageDrawerEvents.CREATE_CONVERSATION_WITH_USER, args); - return; - }).catch(); - }; +/** @property {boolean} Whether the drawer is ready or not */ +let drawerMarkedReady = false; - /** - * Trigger an event to hide the message drawer. - */ - var hide = function() { - waitForDrawerToLoad().then(function () { - PubSub.publish(MessageDrawerEvents.HIDE); - return; - }).catch(); - }; - - /** - * Trigger an event to show the message drawer. - */ - var show = function() { - waitForDrawerToLoad().then(function () { - PubSub.publish(MessageDrawerEvents.SHOW); - return; - }).catch(); - }; +/** + * Trigger an event to create a new conversation in the message drawer. + * + * @param {object} args + * @param {Number} args.userId The user id to start a conversation. + */ +export const createConversationWithUser = async(args) => { + await waitForDrawerToLoad(); + publish(MessageDrawerEvents.CREATE_CONVERSATION_WITH_USER, args); +}; - /** - * Trigger an event to show the given conversation. - * - * @param {object} args - * @param {int} args.conversationId Id for the conversation to show. - */ - var showConversation = function(args) { - waitForDrawerToLoad().then(function () { - PubSub.publish(MessageDrawerEvents.SHOW_CONVERSATION, args); - return; - }).catch(); - }; +/** + * Trigger an event to hide the message drawer. + */ +export const hide = async() => { + await waitForDrawerToLoad(); + publish(MessageDrawerEvents.HIDE); +}; - /** - * Trigger an event to show messaging settings. - */ - var showSettings = function() { - waitForDrawerToLoad().then(function() { - PubSub.publish(MessageDrawerEvents.SHOW_SETTINGS); - return; - }).catch(); - }; +/** + * Trigger an event to show the message drawer. + */ +export const show = async() => { + await waitForDrawerToLoad(); + publish(MessageDrawerEvents.SHOW); +}; - /** - * Helper to wait for the drawer to be ready before performing an action. - * - * @returns {Promise} - */ - var waitForDrawerToLoad = function() { - return new Promise(function(resolve) { - if (drawerMarkedReady) { - resolve(); - } else { - PubSub.subscribe(MessageDrawerEvents.READY, resolve); - } - }); - }; +/** + * Trigger an event to show the given conversation. + * + * @param {object} args + * @param {int} args.conversationId Id for the conversation to show. + */ +export const showConversation = async(args) => { + await waitForDrawerToLoad(); + publish(MessageDrawerEvents.SHOW_CONVERSATION, args); +}; - /** - * Helper to allow the drawer to mark itself as ready. - */ - var markDrawerReady = function() { - drawerMarkedReady = true; - PubSub.publish(MessageDrawerEvents.READY); - }; +/** + * Trigger an event to show messaging settings. + */ +export const showSettings = async() => { + await waitForDrawerToLoad(); + publish(MessageDrawerEvents.SHOW_SETTINGS); +}; - return { - createConversationWithUser: createConversationWithUser, - hide: hide, - show: show, - showConversation: showConversation, - showSettings: showSettings, - markDrawerReady: markDrawerReady, - }; +/** + * Helper to wait for the drawer to be ready before performing an action. + * + * @returns {Promise} + */ +export const waitForDrawerToLoad = () => new Promise((resolve) => { + if (drawerMarkedReady) { + resolve(); + } else { + subscribe(MessageDrawerEvents.READY, resolve); + } }); + +/** + * Helper to allow the drawer to mark itself as ready. + */ +export const markDrawerReady = () => { + drawerMarkedReady = true; + publish(MessageDrawerEvents.READY); +};