Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/im/v2/application/messenger/src/ |
Upload File : |
import { Core } from 'im.v2.application.core'; import { Messenger as MessengerComponent } from 'im.v2.component.messenger'; import { SidebarPullHandler } from 'im.v2.provider.pull'; type MessengerApplicationParams = { node?: string | HTMLElement } export class MessengerApplication { params: MessengerApplicationParams; inited: boolean = false; initPromise: Promise = null; initPromiseResolver: Function = null; rootNode: string | HTMLElement = null; vueInstance: Object = null; controller: Object = null; bitrixVue: Object = null; #applicationName = 'Messenger'; constructor(params: MessengerApplicationParams = {}) { this.initPromise = new Promise((resolve) => { this.initPromiseResolver = resolve; }); this.params = params; this.rootNode = this.params.node || document.createElement('div'); // eslint-disable-next-line promise/catch-or-return this.initCore() .then(() => this.initPullHandlers()) .then(() => this.initComplete()) ; } async initCore(): Promise { Core.setApplicationData(this.params); this.controller = await Core.ready(); return true; } initPullHandlers(): Promise { this.controller.pullClient.subscribe(new SidebarPullHandler()); return Promise.resolve(); } initComplete() { this.inited = true; this.initPromiseResolver(this); } async initComponent(node): Promise { this.unmountComponent(); this.vueInstance = await this.controller.createVue(this, { name: this.#applicationName, el: node || this.rootNode, components: { MessengerComponent }, template: '<MessengerComponent />', }); return true; } unmountComponent() { if (!this.vueInstance) { return; } this.bitrixVue.unmount(); this.vueInstance = null; } ready(): Promise { if (this.inited) { return Promise.resolve(this); } return this.initPromise; } }