From 198a1074ec0119b00d83624b32cafabf3a19ba6d Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Fri, 23 Apr 2021 19:27:23 +0400 Subject: [PATCH] Don't display muted types in folders --- src/components/chat/topbar.ts | 2 +- src/components/dialogsContextMenu.ts | 7 +++---- src/lib/appManagers/appMessagesManager.ts | 2 +- src/lib/storages/filters.ts | 12 +++++++++--- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/components/chat/topbar.ts b/src/components/chat/topbar.ts index 70b712b2..9de7352b 100644 --- a/src/components/chat/topbar.ts +++ b/src/components/chat/topbar.ts @@ -117,7 +117,7 @@ export default class ChatTopbar { }); // delete button - this.menuButtons[this.menuButtons.length - 1].element.firstChild.nodeValue = this.appPeersManager.getDeleteButtonText(this.peerId); + this.menuButtons[this.menuButtons.length - 1].element.lastChild.replaceWith(i18n(this.appPeersManager.getDeleteButtonText(this.peerId))); }); } diff --git a/src/components/dialogsContextMenu.ts b/src/components/dialogsContextMenu.ts index fd4403c3..aea11604 100644 --- a/src/components/dialogsContextMenu.ts +++ b/src/components/dialogsContextMenu.ts @@ -13,6 +13,7 @@ import ButtonMenu, { ButtonMenuItemOptions } from "./buttonMenu"; import PopupDeleteDialog from "./popups/deleteDialog"; import { i18n } from "../lib/langPack"; import findUpTag from "../helpers/dom/findUpTag"; +import appNotificationsManager from "../lib/appManagers/appNotificationsManager"; export default class DialogsContextMenu { private element: HTMLElement; @@ -60,16 +61,14 @@ export default class DialogsContextMenu { text: 'ChatList.Context.Mute', onClick: this.onMuteClick, verify: () => { - const isMuted = this.dialog.notify_settings && this.dialog.notify_settings.mute_until > (Date.now() / 1000 | 0); - return !isMuted && this.selectedId !== rootScope.myId; + return this.selectedId !== rootScope.myId && !appNotificationsManager.isPeerLocalMuted(this.dialog.peerId); } }, { icon: 'unmute', text: 'ChatList.Context.Unmute', onClick: this.onMuteClick, verify: () => { - const isMuted = this.dialog.notify_settings && this.dialog.notify_settings.mute_until > (Date.now() / 1000 | 0); - return isMuted && this.selectedId !== rootScope.myId; + return this.selectedId !== rootScope.myId && appNotificationsManager.isPeerLocalMuted(this.dialog.peerId); } }, { icon: 'archive', diff --git a/src/lib/appManagers/appMessagesManager.ts b/src/lib/appManagers/appMessagesManager.ts index 73fcb8da..22baa13d 100644 --- a/src/lib/appManagers/appMessagesManager.ts +++ b/src/lib/appManagers/appMessagesManager.ts @@ -207,7 +207,7 @@ export class AppMessagesManager { constructor() { this.dialogsStorage = new DialogsStorage(this, appChatsManager, appPeersManager, serverTimeManager); - this.filtersStorage = new FiltersStorage(appPeersManager, appUsersManager, /* apiManager, */ rootScope); + this.filtersStorage = new FiltersStorage(this, appPeersManager, appUsersManager, appNotificationsManager, /* apiManager, */ rootScope); rootScope.on('apiUpdate', (e) => { this.handleUpdate(e); diff --git a/src/lib/storages/filters.ts b/src/lib/storages/filters.ts index 66660f29..71866ad6 100644 --- a/src/lib/storages/filters.ts +++ b/src/lib/storages/filters.ts @@ -11,7 +11,8 @@ import type { AppPeersManager } from "../appManagers/appPeersManager"; import type { AppUsersManager } from "../appManagers/appUsersManager"; //import type { ApiManagerProxy } from "../mtproto/mtprotoworker"; import type _rootScope from "../rootScope"; -import type {Dialog} from '../appManagers/appMessagesManager'; +import type {AppMessagesManager, Dialog} from '../appManagers/appMessagesManager'; +import type {AppNotificationsManager} from "../appManagers/appNotificationsManager"; import apiManager from "../mtproto/mtprotoworker"; import { forEachReverse } from "../../helpers/array"; @@ -29,7 +30,12 @@ export default class FiltersStorage { public filters: {[filterId: string]: MyDialogFilter} = {}; public orderIndex = START_ORDER_INDEX; - constructor(private appPeersManager: AppPeersManager, private appUsersManager: AppUsersManager, /* private apiManager: ApiManagerProxy, */ private rootScope: typeof _rootScope) { + constructor(private appMessagesManager: AppMessagesManager, + private appPeersManager: AppPeersManager, + private appUsersManager: AppUsersManager, + private appNotificationsManager: AppNotificationsManager, + /* private apiManager: ApiManagerProxy, */ + private rootScope: typeof _rootScope) { rootScope.on('apiUpdate', (e) => { this.handleUpdate(e); }); @@ -116,7 +122,7 @@ export default class FiltersStorage { // exclude_muted if(pFlags.exclude_muted) { - const isMuted = (dialog.notify_settings?.mute_until * 1000) > Date.now(); + const isMuted = this.appNotificationsManager.isPeerLocalMuted(dialog.peerId); if(isMuted) { return false; }