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