Файловый менеджер - Редактировать - /var/www/axolotl/data/www/axolotls.ru/www/bitrix/js/im/controller/dist/controller.bundle.js
Назад
this.BX = this.BX || {}; (function (exports,promise,ui_vue_vuex,im_model,im_provider_pull,im_provider_rest,im_lib_timer,im_lib_utils,ui_vue,im_const,im_lib_logger) { 'use strict'; /** * Bitrix Messenger * Application controller * * @package bitrix * @subpackage im * @copyright 2001-2020 Bitrix */ var ApplicationController = /*#__PURE__*/ function () { function ApplicationController() { babelHelpers.classCallCheck(this, ApplicationController); this.controller = null; this.timer = new im_lib_timer.Timer(); this._prepareFilesBeforeSave = function (params) { return params; }; this.defaultMessageLimit = 20; this.requestMessageLimit = this.getDefaultMessageLimit(); this.messageLastReadId = {}; this.messageReadQueue = {}; } babelHelpers.createClass(ApplicationController, [{ key: "setCoreController", value: function setCoreController(controller) { this.controller = controller; } }, { key: "getSiteId", value: function getSiteId() { return this.controller.getStore().state.application.common.siteId; } }, { key: "getUserId", value: function getUserId() { return this.controller.getStore().state.application.common.userId; } }, { key: "getLanguageId", value: function getLanguageId() { return this.controller.getStore().state.application.common.languageId; } }, { key: "getCurrentUser", value: function getCurrentUser() { return this.controller.getStore().getters['users/get'](this.controller.getStore().state.application.common.userId, true); } }, { key: "getChatId", value: function getChatId() { return this.controller.getStore().state.application.dialog.chatId; } }, { key: "getDialogId", value: function getDialogId() { return this.controller.getStore().state.application.dialog.dialogId; } }, { key: "getDialogData", value: function getDialogData() { var dialogId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getDialogId(); if (this.controller.getStore().state.dialogues.collection[dialogId]) { return this.controller.getStore().state.dialogues.collection[dialogId]; } return this.controller.getStore().getters['dialogues/getBlank'](); } }, { key: "getDialogCrmData", value: function getDialogCrmData() { var dialogId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getDialogId(); var result = { enabled: false, entityType: im_const.DialogCrmType.none, entityId: 0 }; var dialogData = this.getDialogData(dialogId); if (dialogData.type === im_const.DialogType.call) { if (dialogData.entityData1 && typeof dialogData.entityData1 === 'string') { var _dialogData$entityDat = dialogData.entityData1.split('|'), _dialogData$entityDat2 = babelHelpers.slicedToArray(_dialogData$entityDat, 3), enabled = _dialogData$entityDat2[0], entityType = _dialogData$entityDat2[1], entityId = _dialogData$entityDat2[2]; if (enabled) { entityType = entityType ? entityType.toString().toLowerCase() : im_const.DialogCrmType.none; result = { enabled: enabled, entityType: entityType, entityId: entityId }; } } } else if (dialogData.type === im_const.DialogType.crm) { var _dialogData$entityId$ = dialogData.entityId.split('|'), _dialogData$entityId$2 = babelHelpers.slicedToArray(_dialogData$entityId$, 2), _entityType = _dialogData$entityId$2[0], _entityId = _dialogData$entityId$2[1]; _entityType = _entityType ? _entityType.toString().toLowerCase() : im_const.DialogCrmType.none; result = { enabled: true, entityType: _entityType, entityId: _entityId }; } return result; } }, { key: "getDialogIdByChatId", value: function getDialogIdByChatId(chatId) { if (this.getDialogId() === 'chat' + chatId) { return this.getDialogId(); } var dialog = this.controller.getStore().getters['dialogues/getByChatId'](chatId); if (!dialog) { return 0; } return dialog.dialogId; } }, { key: "getDiskFolderId", value: function getDiskFolderId() { return this.controller.getStore().state.application.dialog.diskFolderId; } }, { key: "getDefaultMessageLimit", value: function getDefaultMessageLimit() { return this.defaultMessageLimit; } }, { key: "getRequestMessageLimit", value: function getRequestMessageLimit() { return this.requestMessageLimit; } }, { key: "muteDialog", value: function muteDialog() { var _this = this; var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; var dialogId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getDialogId(); if (im_lib_utils.Utils.dialog.isEmptyDialogId(dialogId)) { return false; } if (action === null) { action = !this.isDialogMuted(); } this.timer.start('muteDialog', dialogId, .3, function (id) { _this.controller.restClient.callMethod(im_const.RestMethod.imChatMute, { 'DIALOG_ID': dialogId, 'ACTION': action ? 'Y' : 'N' }); }); var muteList = []; if (action) { muteList = this.getDialogData().muteList; muteList.push(this.getUserId()); } else { muteList = this.getDialogData().muteList.filter(function (userId) { return userId !== _this.getUserId(); }); } this.controller.getStore().dispatch('dialogues/update', { dialogId: dialogId, fields: { muteList: muteList } }); return true; } }, { key: "isDialogMuted", value: function isDialogMuted() { var dialogId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getDialogId(); return this.getDialogData().muteList.includes(this.getUserId()); } }, { key: "isUnreadMessagesLoaded", value: function isUnreadMessagesLoaded() { var dialog = this.controller.getStore().state.dialogues.collection[this.getDialogId()]; if (!dialog) { return true; } if (dialog.unreadLastId <= 0) { return true; } var collection = this.controller.getStore().state.messages.collection[this.getChatId()]; if (!collection || collection.length <= 0) { return true; } var lastElementId = 0; for (var index = collection.length - 1; index >= 0; index--) { var lastElement = collection[index]; if (typeof lastElement.id === "number") { lastElementId = lastElement.id; break; } } return lastElementId >= dialog.unreadLastId; } }, { key: "prepareFilesBeforeSave", value: function prepareFilesBeforeSave(files) { return this._prepareFilesBeforeSave(files); } }, { key: "setPrepareFilesBeforeSaveFunction", value: function setPrepareFilesBeforeSaveFunction(func) { this._prepareFilesBeforeSave = func.bind(this); } }, { key: "showSmiles", value: function showSmiles() { this.store.dispatch('application/showSmiles'); } }, { key: "hideSmiles", value: function hideSmiles() { this.store.dispatch('application/hideSmiles'); } }, { key: "startOpponentWriting", value: function startOpponentWriting(params) { var _this2 = this; var dialogId = params.dialogId, userId = params.userId, userName = params.userName; this.controller.getStore().dispatch('dialogues/updateWriting', { dialogId: dialogId, userId: userId, userName: userName, action: true }); this.timer.start('writingEnd', dialogId + '|' + userId, 35, function (id, params) { var dialogId = params.dialogId, userId = params.userId; _this2.controller.getStore().dispatch('dialogues/updateWriting', { dialogId: dialogId, userId: userId, action: false }); }, { dialogId: dialogId, userId: userId }); return true; } }, { key: "stopOpponentWriting", value: function stopOpponentWriting() { var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var dialogId = params.dialogId, userId = params.userId, userName = params.userName; this.timer.stop('writingStart', dialogId + '|' + userId, true); this.timer.stop('writingEnd', dialogId + '|' + userId); return true; } }, { key: "startWriting", value: function startWriting() { var _this3 = this; var dialogId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getDialogId(); if (im_lib_utils.Utils.dialog.isEmptyDialogId(dialogId) || this.timer.has('writes', dialogId)) { return false; } this.timer.start('writes', dialogId, 28); this.timer.start('writesSend', dialogId, 5, function (id) { _this3.controller.restClient.callMethod(im_const.RestMethod.imDialogWriting, { 'DIALOG_ID': dialogId }).catch(function () { _this3.timer.stop('writes', dialogId); }); }); } }, { key: "stopWriting", value: function stopWriting() { var dialogId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getDialogId(); this.timer.stop('writes', dialogId, true); this.timer.stop('writesSend', dialogId, true); } }, { key: "joinParentChat", value: function joinParentChat(messageId, dialogId) { var _this4 = this; return new Promise(function (resolve, reject) { if (!messageId || !dialogId) { return reject(); } if (typeof _this4.tempJoinChat === 'undefined') { _this4.tempJoinChat = {}; } else if (_this4.tempJoinChat['wait']) { return reject(); } _this4.tempJoinChat['wait'] = true; _this4.controller.restClient.callMethod(im_const.RestMethod.imChatParentJoin, { 'DIALOG_ID': dialogId, 'MESSAGE_ID': messageId }).then(function () { _this4.tempJoinChat['wait'] = false; _this4.tempJoinChat[dialogId] = true; return resolve(dialogId); }).catch(function () { _this4.tempJoinChat['wait'] = false; return reject(); }); }); } }, { key: "setTextareaMessage", value: function setTextareaMessage(params) { var _params$message = params.message, message = _params$message === void 0 ? '' : _params$message, _params$dialogId = params.dialogId, dialogId = _params$dialogId === void 0 ? this.getDialogId() : _params$dialogId; this.controller.getStore().dispatch('dialogues/update', { dialogId: dialogId, fields: { textareaMessage: message } }); } }, { key: "setSendingMessageFlag", value: function setSendingMessageFlag(messageId) { this.controller.getStore().dispatch('messages/actionStart', { id: messageId, chatId: this.getChatId() }); } }, { key: "reactMessage", value: function reactMessage(messageId) { var action = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'auto'; this.controller.restClient.callMethod(im_const.RestMethod.imMessageLike, { 'MESSAGE_ID': messageId, 'ACTION': action === 'auto' ? 'auto' : action === 'set' ? 'plus' : 'minus' }); } }, { key: "readMessage", value: function readMessage() { var _this5 = this; var messageId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; var skipAjax = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; var chatId = this.getChatId(); if (typeof this.messageLastReadId[chatId] === 'undefined') { this.messageLastReadId[chatId] = null; } if (typeof this.messageReadQueue[chatId] === 'undefined') { this.messageReadQueue[chatId] = []; } if (messageId) { this.messageReadQueue[chatId].push(parseInt(messageId)); } this.timer.stop('readMessage', chatId, true); this.timer.stop('readMessageServer', chatId, true); if (force) { return this.readMessageExecute(chatId, skipAjax); } return new Promise(function (resolve, reject) { _this5.timer.start('readMessage', chatId, .1, function (chatId, params) { return _this5.readMessageExecute(chatId, skipAjax).then(function (result) { return resolve(result); }); }); }); } }, { key: "readMessageExecute", value: function readMessageExecute(chatId) { var _this6 = this; var skipAjax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; return new Promise(function (resolve, reject) { if (_this6.messageReadQueue[chatId]) { _this6.messageReadQueue[chatId] = _this6.messageReadQueue[chatId].filter(function (elementId) { if (!_this6.messageLastReadId[chatId]) { _this6.messageLastReadId[chatId] = elementId; } else if (_this6.messageLastReadId[chatId] < elementId) { _this6.messageLastReadId[chatId] = elementId; } }); } var dialogId = _this6.getDialogIdByChatId(chatId); var lastId = _this6.messageLastReadId[chatId] || 0; if (lastId <= 0) { resolve({ dialogId: dialogId, lastId: 0 }); return true; } _this6.controller.getStore().dispatch('messages/readMessages', { chatId: chatId, readId: lastId }).then(function (result) { _this6.controller.getStore().dispatch('dialogues/decreaseCounter', { dialogId: dialogId, count: result.count }); if (_this6.getChatId() === chatId && _this6.controller.getStore().getters['dialogues/canSaveChat']) { var dialog = _this6.controller.getStore().getters['dialogues/get'](dialogId); if (dialog.counter <= 0) { _this6.controller.getStore().commit('application/clearDialogExtraCount'); } } if (skipAjax) { resolve({ dialogId: dialogId, lastId: lastId }); } else { _this6.timer.start('readMessageServer', chatId, .5, function () { _this6.controller.restClient.callMethod(im_const.RestMethod.imDialogRead, { 'DIALOG_ID': dialogId, 'MESSAGE_ID': lastId }).then(function () { return resolve({ dialogId: dialogId, lastId: lastId }); }).catch(function () { return resolve({ dialogId: dialogId, lastId: lastId }); }); }); } }).catch(function () { resolve(); }); }); } }, { key: "unreadMessage", value: function unreadMessage() { var _this7 = this; var messageId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; var skipAjax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; var chatId = this.getChatId(); if (typeof this.messageLastReadId[chatId] === 'undefined') { this.messageLastReadId[chatId] = null; } if (typeof this.messageReadQueue[chatId] === 'undefined') { this.messageReadQueue[chatId] = []; } if (messageId) { this.messageReadQueue[chatId] = this.messageReadQueue[chatId].filter(function (id) { return id < messageId; }); } this.timer.stop('readMessage', chatId, true); this.timer.stop('readMessageServer', chatId, true); this.messageLastReadId[chatId] = messageId; this.controller.getStore().dispatch('messages/unreadMessages', { chatId: chatId, unreadId: this.messageLastReadId[chatId] }).then(function (result) { var dialogId = _this7.getDialogIdByChatId(chatId); _this7.controller.getStore().dispatch('dialogues/update', { dialogId: dialogId, fields: { unreadId: messageId } }); _this7.controller.getStore().dispatch('dialogues/increaseCounter', { dialogId: dialogId, count: result.count }); if (!skipAjax) { _this7.controller.restClient.callMethod(im_const.RestMethod.imDialogUnread, { 'DIALOG_ID': dialogId, 'MESSAGE_ID': _this7.messageLastReadId[chatId] }); } }).catch(function () {}); } }, { key: "shareMessage", value: function shareMessage(messageId, type) { this.controller.restClient.callMethod(im_const.RestMethod.imMessageShare, { 'DIALOG_ID': this.getDialogId(), 'MESSAGE_ID': messageId, 'TYPE': type }); return true; } }, { key: "emit", value: function emit(eventName) { var _Vue$event; for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } (_Vue$event = ui_vue.Vue.event).$emit.apply(_Vue$event, [eventName].concat(args)); } }, { key: "listen", value: function listen(event, callback) { ui_vue.Vue.event.$on(event, callback); } }]); return ApplicationController; }(); /** * Bitrix Messenger * Recent list controller * * @package bitrix * @subpackage im * @copyright 2001-2020 Bitrix */ var RecentController = /*#__PURE__*/ function () { function RecentController() { babelHelpers.classCallCheck(this, RecentController); this.paginationCount = 50; this.loadingMore = false; this.hasMoreToLoad = true; this.placeholderCount = 0; this.lastMessageDate = null; } babelHelpers.createClass(RecentController, [{ key: "setCoreController", value: function setCoreController(controller) { this.controller = controller; } }, { key: "drawPlaceholders", value: function drawPlaceholders() { var placeholders = this.generatePlaceholders(this.paginationCount); this.controller.getStore().dispatch('recent/set', { general: placeholders }); } }, { key: "getRecentData", value: function getRecentData() { var _this = this; var queryParams = { 'SKIP_OPENLINES': 'Y', 'LIMIT': this.paginationCount }; this.controller.restClient.callMethod(im_const.RestMethod.imRecentList, queryParams, null, null).then(function (result) { _this.lastMessageDate = _this.getLastMessageDate(result.data().items); if (result.data().items.length !== _this.paginationCount) { _this.hasMoreToLoad = false; } _this.controller.getStore().dispatch('recent/clearPlaceholders'); _this.controller.executeRestAnswer(im_const.RestMethodHandler.imRecentList, result); }); } }, { key: "loadMore", value: function loadMore() { var _this2 = this; if (!this.loadingMore && this.hasMoreToLoad) { this.loadingMore = true; var firstMessageToUpdate = this.placeholderCount; var placeholders = this.generatePlaceholders(this.paginationCount); this.controller.getStore().dispatch('recent/set', { general: placeholders }).then(function () { var queryParams = { 'SKIP_OPENLINES': 'Y', 'LIMIT': _this2.paginationCount, 'LAST_MESSAGE_UPDATE': _this2.lastMessageDate }; _this2.controller.restClient.callMethod(im_const.RestMethod.imRecentList, queryParams, null, null).then(function (result) { var items = result.data().items; if (!items || items.length === 0) { _this2.controller.getStore().dispatch('recent/clearPlaceholders'); return false; } if (items.length !== _this2.paginationCount) { _this2.hasMoreToLoad = false; } _this2.lastMessageDate = _this2.getLastMessageDate(items); var data = _this2.prepareDataForModels(items); _this2.controller.getStore().dispatch('users/set', data.users).then(function () { _this2.controller.getStore().dispatch('dialogues/set', data.dialogues).then(function () { _this2.controller.getStore().dispatch('recent/updatePlaceholders', { items: data.recent, firstMessage: firstMessageToUpdate }).then(function () { _this2.loadingMore = false; if (!_this2.hasMoreToLoad) { _this2.controller.getStore().dispatch('recent/clearPlaceholders'); } }); }); }); }); }); } } }, { key: "generatePlaceholders", value: function generatePlaceholders(amount) { var placeholders = []; for (var i = 0; i < amount; i++) { placeholders.push({ id: 'placeholder' + this.placeholderCount, templateId: 'placeholder' + this.placeholderCount, template: 'placeholder', sectionCode: 'general' }); this.placeholderCount++; } return placeholders; } }, { key: "getLastMessageDate", value: function getLastMessageDate(collection) { return collection.slice(-1)[0].date_update; } }, { key: "openOldDialog", value: function openOldDialog(event) { if (event.id !== 'notify') { BXIM.openMessenger(event.id); } else { BXIM.openNotify(); } } }, { key: "openOldContextMenu", value: function openOldContextMenu(event) { event.$event.preventDefault(); var recentItem = this.controller.getStore().getters['recent/get'](event.id); var params = { userId: event.id, userIsChat: typeof event.id === 'string', dialogIsPinned: recentItem.element.pinned }; BXIM.messenger.openPopupMenu(event.$event.target, 'contactList', undefined, params); } }, { key: "prepareDataForModels", value: function prepareDataForModels(items) { var result = { users: [], dialogues: [], recent: [] }; items.forEach(function (item) { var userId = 0; var chatId = 0; if (item.user && item.user.id > 0) { userId = item.user.id; result.users.push(item.user); } if (item.chat) { chatId = item.chat.id; result.dialogues.push(Object.assign(item.chat, { dialogId: item.id })); } else { result.dialogues.push(Object.assign({}, { dialogId: item.id })); } result.recent.push(babelHelpers.objectSpread({}, item, { avatar: item.avatar.url, color: item.avatar.color, userId: userId, chatId: chatId })); }); return result; } }]); return RecentController; }(); /** * Bitrix im dialog mobile * Dialog runtime class * * @package bitrix * @subpackage mobile * @copyright 2001-2019 Bitrix */ var Controller = /*#__PURE__*/ function () { /* region 01. Initialize and store data */ function Controller() { var _this = this; var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; babelHelpers.classCallCheck(this, Controller); this.inited = false; this.initPromise = new BX.Promise(); this.offline = false; this.restAnswerHandler = []; this.vuexAdditionalModel = []; this.store = null; this.storeBuilder = null; this.prepareConstructorParams(params); this.initController().then(function () { return _this.initLocalStorage(); }).then(function () { return _this.initStorage(); }).then(function () { return _this.initRestClient(); }).then(function () { return _this.initPullClient(); }).then(function () { return _this.initEnvironment(); }).then(function () { return _this.initComponent(); }).then(function () { return _this.initComplete(); }); } babelHelpers.createClass(Controller, [{ key: "prepareConstructorParams", value: function prepareConstructorParams(params) { var _this2 = this; if (typeof params.localize !== 'undefined') { this.localize = params.localize; } else { this.localize = babelHelpers.objectSpread({}, BX.message); } if (typeof params.host !== 'undefined') { this.host = params.host; } else { this.host = location.origin; } if (typeof params.userId !== 'undefined') { this.userId = params.userId ? parseInt(params.userId) : 0; } else { var userId = this.getLocalize('USER_ID'); this.userId = userId ? parseInt(userId) : 0; } if (typeof params.siteId !== 'undefined') { this.siteId = params.siteId ? params.userId : 's1'; } else { this.siteId = this.getLocalize('SITE_ID') || 's1'; } if (typeof params.siteDir !== 'undefined') { this.siteDir = params.siteDir ? params.siteDir : 's1'; } else { this.siteDir = this.getLocalize('SITE_DIR') || 's1'; } if (typeof params.languageId !== 'undefined') { this.languageId = params.languageId ? params.languageId : 'en'; } else { this.languageId = this.getLocalize('LANGUAGE_ID') || 'en'; } this.pull = BX.PullClient; this.pullClient = BX.PULL; if (typeof params.pull !== 'undefined') { if (typeof params.pull.instance !== 'undefined') { this.pull = params.pull.instance; } if (typeof params.pull.client !== 'undefined') { this.pullClient = params.pull.client; } } this.rest = BX.RestClient; this.restClient = BX.rest; if (typeof params.rest !== 'undefined') { if (typeof params.rest.instance !== 'undefined') { this.rest = params.rest.instance; } if (typeof params.rest.client !== 'undefined') { this.restClient = params.rest.client; } } this.vuexBuilder = { database: false, databaseName: 'desktop/im', databaseType: ui_vue_vuex.VuexBuilder.DatabaseType.indexedDb }; if (typeof params.vuexBuilder !== 'undefined') { if (typeof params.vuexBuilder.database !== 'undefined') { this.vuexBuilder.database = params.vuexBuilder.database; } if (typeof params.vuexBuilder.databaseName !== 'undefined') { this.vuexBuilder.databaseName = params.vuexBuilder.databaseName; } if (typeof params.vuexBuilder.databaseType !== 'undefined') { this.vuexBuilder.databaseType = params.vuexBuilder.databaseType; } if (typeof params.vuexBuilder.models !== 'undefined') { params.vuexBuilder.models.forEach(function (model) { _this2.addVuexModel(model); }); } } return true; } }, { key: "initConstructorParams", value: function initConstructorParams() { var _this3 = this; return this.paramsPromise.then(function (params) { _this3.prepareConstructorParams(_this3.paramsCallback(params)); return new Promise(function (resolve, reject) { return resolve(); }); }); } }, { key: "initController", value: function initController() { this.application = new ApplicationController(); this.application.setCoreController(this); this.recent = new RecentController(); this.recent.setCoreController(this); return new Promise(function (resolve, reject) { return resolve(); }); } }, { key: "initLocalStorage", value: function initLocalStorage() { return new Promise(function (resolve, reject) { return resolve(); }); } }, { key: "initStorage", value: function initStorage() { var _this4 = this; var applicationVariables = { common: { host: this.getHost(), userId: this.getUserId(), siteId: this.getSiteId(), languageId: this.getLanguageId() }, dialog: { messageLimit: this.application.getDefaultMessageLimit(), enableReadMessages: false // TODO: remove }, device: { type: im_lib_utils.Utils.device.isMobile() ? im_const.DeviceType.mobile : im_const.DeviceType.desktop, orientation: im_lib_utils.Utils.device.getOrientation() } }; var builder = new ui_vue_vuex.VuexBuilder().addModel(im_model.ApplicationModel.create().useDatabase(false).setVariables(applicationVariables)).addModel(im_model.MessagesModel.create().useDatabase(this.vuexBuilder.database).setVariables({ host: this.getHost() })).addModel(im_model.DialoguesModel.create().useDatabase(this.vuexBuilder.database).setVariables({ host: this.getHost() })).addModel(im_model.FilesModel.create().useDatabase(this.vuexBuilder.database).setVariables({ host: this.getHost(), default: { name: 'File is deleted' } })).addModel(im_model.UsersModel.create().useDatabase(this.vuexBuilder.database).setVariables({ host: this.getHost(), default: { name: 'Anonymous' } })).addModel(im_model.RecentModel.create().useDatabase(false).setVariables({ host: this.getHost() })); this.vuexAdditionalModel.forEach(function (model) { builder.addModel(model); }); builder.setDatabaseConfig({ name: this.vuexBuilder.databaseName, type: this.vuexBuilder.databaseType, siteId: this.getSiteId(), userId: this.getUserId() }); return builder.build().then(function (result) { _this4.store = result.store; _this4.storeBuilder = result.builder; return new Promise(function (resolve, reject) { return resolve(); }); }); } }, { key: "initRestClient", value: function initRestClient(result) { this.addRestAnswerHandler(im_provider_rest.CoreRestHandler.create({ store: this.store, controller: this })); return new Promise(function (resolve, reject) { return resolve(); }); } }, { key: "initPullClient", value: function initPullClient() { if (!this.pullClient) { return false; } this.pullClient.subscribe(this.pullCommandHandler = new im_provider_pull.ImPullCommandHandler({ store: this.store, controller: this })); this.pullClient.subscribe({ type: this.pull.SubscriptionType.Status, callback: this.eventStatusInteraction.bind(this) }); this.pullClient.subscribe({ type: this.pull.SubscriptionType.Online, callback: this.eventOnlineInteraction.bind(this) }); return new Promise(function (resolve, reject) { return resolve(); }); } }, { key: "initEnvironment", value: function initEnvironment(result) { var _this5 = this; window.addEventListener('orientationchange', function () { if (!_this5.store) { return; } _this5.store.commit('application/set', { device: { orientation: im_lib_utils.Utils.device.getOrientation() } }); if (_this5.store.state.application.device.type === im_const.DeviceType.mobile && _this5.store.state.application.device.orientation === DeviceOrientation.horizontal) { document.activeElement.blur(); } }); return new Promise(function (resolve, reject) { return resolve(); }); } }, { key: "initComponent", value: function initComponent() { return new Promise(function (resolve, reject) { return resolve(); }); } }, { key: "initComplete", value: function initComplete() { this.inited = true; this.initPromise.resolve(this); } /* endregion 01. Initialize and store data */ /* region 02. Push & Pull */ }, { key: "eventStatusInteraction", value: function eventStatusInteraction(data) { if (data.status === this.pull.PullStatus.Online) { this.offline = false; //this.pullCommandHandler.option.skip = true; // this.getDialogUnread().then(() => { // this.pullCommandHandler.option.skip = false; // this.processSendMessages(); // this.emit(EventType.dialog.sendReadMessages); // }).catch(() => { // this.pullCommandHandler.option.skip = false; // this.processSendMessages(); // }); } else if (data.status === this.pull.PullStatus.Offline) { this.offline = true; } } }, { key: "eventOnlineInteraction", value: function eventOnlineInteraction(data) { if (data.command === 'list' || data.command === 'userStatus') { for (var userId in data.params.users) { if (!data.params.users.hasOwnProperty(userId)) { continue; } this.store.dispatch('users/update', { id: data.params.users[userId].id, fields: data.params.users[userId] }); } } } /* endregion 02. Push & Pull */ /* region 03. Rest */ }, { key: "executeRestAnswer", value: function executeRestAnswer(command, result, extra) { im_lib_logger.Logger.warn('Core.controller.executeRestAnswer', command, result, extra); this.restAnswerHandler.forEach(function (handler) { handler.execute(command, result, extra); }); } /* endregion 03. Rest */ /* region 04. Template engine */ }, { key: "createVue", value: function createVue(application) { var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var controller = this; var restClient = this.restClient; var pullClient = this.pullClient || null; var beforeCreateFunction = function beforeCreateFunction() {}; if (config.beforeCreate) { beforeCreateFunction = config.beforeCreate; } var destroyedFunction = function destroyedFunction() {}; if (config.destroyed) { destroyedFunction = config.destroyed; } var initConfig = { store: this.store, beforeCreate: function beforeCreate() { this.$bitrixApplication = application; this.$bitrixController = controller; this.$bitrixRestClient = restClient; this.$bitrixPullClient = pullClient; this.$bitrixMessages = controller.localize; beforeCreateFunction.bind(this)(); }, destroyed: function destroyed() { this.$bitrixApplication = null; this.$bitrixController = null; this.$bitrixRestClient = null; this.$bitrixPullClient = null; this.$bitrixMessages = null; destroyedFunction.bind(this)(); } }; if (config.el) { initConfig.el = config.el; } if (config.template) { initConfig.template = config.template; } if (config.computed) { initConfig.computed = config.computed; } if (config.created) { initConfig.created = config.created; } if (config.data) { initConfig.data = config.data; } return new Promise(function (resolve, reject) { initConfig.created = function () { resolve(this); }; ui_vue.Vue.create(initConfig); }); } /* endregion 04. Template engine */ /* region 05. Core methods */ }, { key: "getHost", value: function getHost() { return this.host; } }, { key: "getUserId", value: function getUserId() { return this.userId; } }, { key: "getSiteId", value: function getSiteId() { return this.siteId; } }, { key: "getLanguageId", value: function getLanguageId() { return this.languageId; } }, { key: "getStore", value: function getStore() { return this.store; } }, { key: "getStoreBuilder", value: function getStoreBuilder() { return this.storeBuilder; } }, { key: "addRestAnswerHandler", value: function addRestAnswerHandler(handler) { this.restAnswerHandler.push(handler); } }, { key: "addVuexModel", value: function addVuexModel(model) { this.vuexAdditionalModel.push(model); } }, { key: "isOnline", value: function isOnline() { return !this.offline; } }, { key: "ready", value: function ready() { if (this.inited) { var promise$$1 = new BX.Promise(); promise$$1.resolve(this); return promise$$1; } return this.initPromise; } /* endregion 05. Methods */ /* region 06. Interaction and utils */ }, { key: "setError", value: function setError() { var code = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; var description = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; im_lib_logger.Logger.error("Messenger.Application.error: ".concat(code, " (").concat(description, ")")); var localizeDescription = ''; if (code.endsWith('LOCALIZED')) { localizeDescription = description; } this.store.commit('application/set', { error: { active: true, code: code, description: localizeDescription } }); } }, { key: "clearError", value: function clearError() { this.store.commit('application/set', { error: { active: false, code: '', description: '' } }); } }, { key: "addLocalize", value: function addLocalize(phrases) { if (babelHelpers.typeof(phrases) !== "object" || !phrases) { return false; } for (var name in phrases) { if (phrases.hasOwnProperty(name)) { this.localize[name] = phrases[name]; } } return true; } }, { key: "getLocalize", value: function getLocalize(name) { var phrase = ''; if (typeof name === 'undefined') { return this.localize; } else if (typeof this.localize[name.toString()] === 'undefined') { im_lib_logger.Logger.warn("Controller.Core.getLocalize: message with code '".concat(name.toString(), "' is undefined.")); im_lib_logger.Logger.trace(); } else { phrase = this.localize[name]; } return phrase; } /* endregion 06. Interaction and utils */ }]); return Controller; }(); exports.Controller = Controller; }((this.BX.Messenger = this.BX.Messenger || {}),BX,BX,BX.Messenger.Model,BX.Messenger.Provider.Pull,BX.Messenger.Provider.Rest,BX.Messenger.Lib,BX.Messenger.Lib,BX,BX.Messenger.Const,BX.Messenger.Lib)); //# sourceMappingURL=controller.bundle.js.map
| ver. 1.4 |
Github
|
.
| PHP 7.4.8 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка