Browse Source

Don't display muted types in folders

master
Eduard Kuzmenko 4 years ago
parent
commit
198a1074ec
  1. 2
      src/components/chat/topbar.ts
  2. 7
      src/components/dialogsContextMenu.ts
  3. 2
      src/lib/appManagers/appMessagesManager.ts
  4. 12
      src/lib/storages/filters.ts

2
src/components/chat/topbar.ts

@ -117,7 +117,7 @@ export default class ChatTopbar {
}); });
// delete button // 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)));
}); });
} }

7
src/components/dialogsContextMenu.ts

@ -13,6 +13,7 @@ import ButtonMenu, { ButtonMenuItemOptions } from "./buttonMenu";
import PopupDeleteDialog from "./popups/deleteDialog"; import PopupDeleteDialog from "./popups/deleteDialog";
import { i18n } from "../lib/langPack"; import { i18n } from "../lib/langPack";
import findUpTag from "../helpers/dom/findUpTag"; import findUpTag from "../helpers/dom/findUpTag";
import appNotificationsManager from "../lib/appManagers/appNotificationsManager";
export default class DialogsContextMenu { export default class DialogsContextMenu {
private element: HTMLElement; private element: HTMLElement;
@ -60,16 +61,14 @@ export default class DialogsContextMenu {
text: 'ChatList.Context.Mute', text: 'ChatList.Context.Mute',
onClick: this.onMuteClick, onClick: this.onMuteClick,
verify: () => { verify: () => {
const isMuted = this.dialog.notify_settings && this.dialog.notify_settings.mute_until > (Date.now() / 1000 | 0); return this.selectedId !== rootScope.myId && !appNotificationsManager.isPeerLocalMuted(this.dialog.peerId);
return !isMuted && this.selectedId !== rootScope.myId;
} }
}, { }, {
icon: 'unmute', icon: 'unmute',
text: 'ChatList.Context.Unmute', text: 'ChatList.Context.Unmute',
onClick: this.onMuteClick, onClick: this.onMuteClick,
verify: () => { verify: () => {
const isMuted = this.dialog.notify_settings && this.dialog.notify_settings.mute_until > (Date.now() / 1000 | 0); return this.selectedId !== rootScope.myId && appNotificationsManager.isPeerLocalMuted(this.dialog.peerId);
return isMuted && this.selectedId !== rootScope.myId;
} }
}, { }, {
icon: 'archive', icon: 'archive',

2
src/lib/appManagers/appMessagesManager.ts

@ -207,7 +207,7 @@ export class AppMessagesManager {
constructor() { constructor() {
this.dialogsStorage = new DialogsStorage(this, appChatsManager, appPeersManager, serverTimeManager); 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) => { rootScope.on('apiUpdate', (e) => {
this.handleUpdate(e); this.handleUpdate(e);

12
src/lib/storages/filters.ts

@ -11,7 +11,8 @@ import type { AppPeersManager } from "../appManagers/appPeersManager";
import type { AppUsersManager } from "../appManagers/appUsersManager"; import type { AppUsersManager } from "../appManagers/appUsersManager";
//import type { ApiManagerProxy } from "../mtproto/mtprotoworker"; //import type { ApiManagerProxy } from "../mtproto/mtprotoworker";
import type _rootScope from "../rootScope"; 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 apiManager from "../mtproto/mtprotoworker";
import { forEachReverse } from "../../helpers/array"; import { forEachReverse } from "../../helpers/array";
@ -29,7 +30,12 @@ export default class FiltersStorage {
public filters: {[filterId: string]: MyDialogFilter} = {}; public filters: {[filterId: string]: MyDialogFilter} = {};
public orderIndex = START_ORDER_INDEX; 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) => { rootScope.on('apiUpdate', (e) => {
this.handleUpdate(e); this.handleUpdate(e);
}); });
@ -116,7 +122,7 @@ export default class FiltersStorage {
// exclude_muted // exclude_muted
if(pFlags.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) { if(isMuted) {
return false; return false;
} }

Loading…
Cancel
Save