moodle/message/amd/build/message_drawer_helper.min.js.map
2023-03-09 09:53:19 +08:00

1 line
3.4 KiB
Plaintext

{"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 <http://www.gnu.org/licenses/>.\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 <ryan@moodle.com>\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<void>}\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"}