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/cvetdv.ru/bitrix/js/im/v2/provider/service/chat/src/classes/ |
Upload File : |
import { Logger } from 'im.v2.lib.logger'; import { RestMethod } from 'im.v2.const'; import { runAction } from 'im.v2.lib.rest'; import { Notifier } from 'im.v2.lib.notifier'; import { Core } from 'im.v2.application.core'; import type { Store } from 'ui.vue3.vuex'; type RestResult = { result: boolean, }; export class DeleteService { #store: Store; constructor() { this.#store = Core.getStore(); } async deleteChat(dialogId: string): Promise<RestResult> { Logger.warn(`ChatService: deleteChat, dialogId: ${dialogId}`); const deleteResult = await runAction(RestMethod.imV2ChatDelete, { data: { dialogId }, }).catch(([error]) => { console.error('ChatService: deleteChat error:', error); Notifier.chat.onDeleteError(); }); await this.#updateModels(dialogId); return deleteResult; } async deleteCollab(dialogId: string): Promise { Logger.warn(`ChatService: deleteCollab, dialogId: ${dialogId}`); try { await runAction(RestMethod.socialnetworkCollabDelete, { data: { dialogId }, }); await this.#updateModels(dialogId); return Promise.resolve(); } catch (errors) { const [firstError] = errors; console.error('ChatService: deleteCollab error:', firstError); Notifier.collab.handleDeleteError(firstError); return Promise.resolve(); } } #updateModels(dialogId: string): Promise { void this.#store.dispatch('chats/update', { dialogId, fields: { inited: false }, }); void this.#store.dispatch('recent/delete', { id: dialogId }); const chat = this.#store.getters['chats/get'](dialogId, true); void this.#store.dispatch('messages/clearChatCollection', { chatId: chat.chatId }); } }