moodle/message/amd/build/message_drawer_helper.min.js

10 lines
1.8 KiB
JavaScript

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 <ryan@moodle.com>
* @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