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/pull/src/ |
Upload File : |
import {Runtime} from 'main.core'; import {Core} from 'im.v2.application.core'; import {UserManager} from 'im.v2.lib.user'; import type {NotifyAddParams} from './types/notification'; export class NotificationPullHandler { constructor() { this.store = Core.getStore(); this.userManager = new UserManager(); this.updateCounterDebounced = Runtime.debounce(this.updateCounter, 1500, this); } getModuleId(): string { return 'im'; } getSubscriptionType(): string { return 'server'; } handleNotifyAdd(params: NotifyAddParams) { if (params.onlyFlash === true) { return; } this.userManager.setUsersToModel(params.users); this.store.dispatch('notifications/set', params); this.updateCounterDebounced(params.counter); } handleNotifyConfirm(params) { this.store.dispatch('notifications/delete', { id: params.id, }); this.updateCounterDebounced(params.counter); } handleNotifyRead(params) { params.list.forEach(id => { this.store.dispatch('notifications/read', {ids: [id], read: true}); }); this.updateCounterDebounced(params.counter); } handleNotifyUnread(params) { params.list.forEach(id => { this.store.dispatch('notifications/read', {ids: [id], read: false}); }); this.updateCounterDebounced(params.counter); } handleNotifyReadAll() { void this.store.dispatch('notifications/readAll'); } handleNotifyDelete(params) { const idsToDelete = Object.keys(params.id).map(id => Number.parseInt(id, 10)); idsToDelete.forEach(id => { this.store.dispatch('notifications/delete', {id}); }); this.updateCounterDebounced(params.counter); } updateCounter(counter: number) { this.store.dispatch('notifications/setCounter', counter); } }