Fix showing notifications on muted types
This commit is contained in:
parent
198a1074ec
commit
be1cd0d3bf
@ -1,4 +1,4 @@
|
||||
import { ColorHsla, hexaToHsla, hslaToRgba, rgbaToHexa as rgbaToHexa, rgbaToHsla } from "../helpers/color";
|
||||
import { ColorHsla, ColorRgba, hexaToHsla, hslaToRgba, rgbaToHexa as rgbaToHexa, rgbaToHsla } from "../helpers/color";
|
||||
import attachGrabListeners from "../helpers/dom/attachGrabListeners";
|
||||
import { clamp } from "../helpers/number";
|
||||
import InputField, { InputState } from "./inputField";
|
||||
@ -10,7 +10,7 @@ export type ColorPickerColor = {
|
||||
hsla: string;
|
||||
rgba: string;
|
||||
hexa: string;
|
||||
rgbaArray: import("f:/tweb/src/helpers/color").ColorRgba;
|
||||
rgbaArray: ColorRgba;
|
||||
};
|
||||
|
||||
export default class ColorPicker {
|
||||
|
@ -66,7 +66,7 @@ export default class DialogsContextMenu {
|
||||
}, {
|
||||
icon: 'unmute',
|
||||
text: 'ChatList.Context.Unmute',
|
||||
onClick: this.onMuteClick,
|
||||
onClick: this.onUnmuteClick,
|
||||
verify: () => {
|
||||
return this.selectedId !== rootScope.myId && appNotificationsManager.isPeerLocalMuted(this.dialog.peerId);
|
||||
}
|
||||
@ -104,8 +104,12 @@ export default class DialogsContextMenu {
|
||||
appMessagesManager.toggleDialogPin(this.selectedId, this.filterId);
|
||||
};
|
||||
|
||||
private onUnmuteClick = () => {
|
||||
appMessagesManager.mutePeer(this.selectedId, false);
|
||||
};
|
||||
|
||||
private onMuteClick = () => {
|
||||
appMessagesManager.mutePeer(this.selectedId);
|
||||
appMessagesManager.mutePeer(this.selectedId, true);
|
||||
};
|
||||
|
||||
private onUnreadClick = () => {
|
||||
|
@ -74,7 +74,7 @@ export class AppChatsManager {
|
||||
case 'updateChatUserTyping':
|
||||
case 'updateChannelUserTyping': {
|
||||
const fromId = (update as Update.updateUserTyping).user_id || appPeersManager.getPeerId((update as Update.updateChatUserTyping).from_id);
|
||||
if(rootScope.myId === fromId) {
|
||||
if(rootScope.myId === fromId || update.action._ === 'speakingInGroupCallAction') {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -498,10 +498,7 @@ export class AppDialogsManager {
|
||||
//selectTab(0);
|
||||
(this.folders.menu.firstElementChild as HTMLElement).click();
|
||||
appStateManager.getState().then((state) => {
|
||||
(['inputNotifyBroadcasts', 'inputNotifyUsers', 'inputNotifyChats'] as Exclude<InputNotifyPeer['_'], 'inputNotifyPeer'>[])
|
||||
.forEach((inputKey) => {
|
||||
appNotificationsManager.getNotifySettings({_: inputKey});
|
||||
});
|
||||
appNotificationsManager.getNotifyPeerTypeSettings();
|
||||
|
||||
const getFiltersPromise = appMessagesManager.filtersStorage.getDialogFilters();
|
||||
getFiltersPromise.then((filters) => {
|
||||
|
@ -3905,11 +3905,11 @@ export class AppMessagesManager {
|
||||
const notifyPeerToHandle = this.notificationsToHandle[peerId];
|
||||
|
||||
Promise.all([
|
||||
appNotificationsManager.getPeerMuted(peerId),
|
||||
appNotificationsManager.getNotifyPeerTypeSettings(),
|
||||
appNotificationsManager.getNotifySettings(appPeersManager.getInputNotifyPeerById(peerId, true))
|
||||
]).then(([muted, peerTypeNotifySettings]) => {
|
||||
]).then(([_, peerTypeNotifySettings]) => {
|
||||
const topMessage = notifyPeerToHandle.topMessage;
|
||||
if(muted || !topMessage.pFlags.unread) {
|
||||
if(appNotificationsManager.isPeerLocalMuted(peerId, true) || !topMessage.pFlags.unread) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -4787,20 +4787,20 @@ export class AppMessagesManager {
|
||||
return pendingMessage;
|
||||
}
|
||||
|
||||
public mutePeer(peerId: number) {
|
||||
public mutePeer(peerId: number, mute?: boolean) {
|
||||
const settings: InputPeerNotifySettings = {
|
||||
_: 'inputPeerNotifySettings'
|
||||
};
|
||||
|
||||
const dialog = appMessagesManager.getDialogByPeerId(peerId)[0];
|
||||
let muted = true;
|
||||
if(dialog && dialog.notify_settings) {
|
||||
muted = dialog.notify_settings.mute_until > (Date.now() / 1000 | 0);
|
||||
if(mute === undefined) {
|
||||
mute = false;
|
||||
const dialog = appMessagesManager.getDialogByPeerId(peerId)[0];
|
||||
if(dialog && dialog.notify_settings) {
|
||||
mute = (dialog.notify_settings.mute_until || 0) <= (Date.now() / 1000 | 0);
|
||||
}
|
||||
}
|
||||
|
||||
if(!muted) {
|
||||
settings.mute_until = 2147483647;
|
||||
}
|
||||
settings.mute_until = mute ? 0xFFFFFFFF : 0;
|
||||
|
||||
return appNotificationsManager.updateNotifySettings({
|
||||
_: 'inputNotifyPeer',
|
||||
|
@ -82,6 +82,8 @@ export class AppNotificationsManager {
|
||||
|
||||
private notifySoundEl: HTMLElement;
|
||||
|
||||
private getNotifyPeerTypePromise: Promise<any>;
|
||||
|
||||
constructor() {
|
||||
// @ts-ignore
|
||||
navigator.vibrate = navigator.vibrate || navigator.mozVibrate || navigator.webkitVibrate;
|
||||
@ -322,6 +324,17 @@ export class AppNotificationsManager {
|
||||
});
|
||||
}
|
||||
|
||||
public getNotifyPeerTypeSettings() {
|
||||
if(this.getNotifyPeerTypePromise) return this.getNotifyPeerTypePromise;
|
||||
|
||||
const promises = (['inputNotifyBroadcasts', 'inputNotifyUsers', 'inputNotifyChats'] as Exclude<InputNotifyPeer['_'], 'inputNotifyPeer'>[])
|
||||
.map((inputKey) => {
|
||||
return this.getNotifySettings({_: inputKey});
|
||||
});
|
||||
|
||||
return this.getNotifyPeerTypePromise = Promise.all(promises);
|
||||
}
|
||||
|
||||
public updateNotifySettings(peer: InputNotifyPeer, settings: InputPeerNotifySettings) {
|
||||
//this.savePeerSettings(peerId, settings);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user