Browse Source

Fix showing notifications on muted types

master
morethanwords 3 years ago
parent
commit
be1cd0d3bf
  1. 4
      src/components/colorPicker.ts
  2. 8
      src/components/dialogsContextMenu.ts
  3. 2
      src/lib/appManagers/appChatsManager.ts
  4. 5
      src/lib/appManagers/appDialogsManager.ts
  5. 22
      src/lib/appManagers/appMessagesManager.ts
  6. 13
      src/lib/appManagers/appNotificationsManager.ts

4
src/components/colorPicker.ts

@ -1,4 +1,4 @@ @@ -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 = { @@ -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 {

8
src/components/dialogsContextMenu.ts

@ -66,7 +66,7 @@ export default class DialogsContextMenu { @@ -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);
}
@ -103,9 +103,13 @@ export default class DialogsContextMenu { @@ -103,9 +103,13 @@ export default class DialogsContextMenu {
private onPinClick = () => {
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 = () => {

2
src/lib/appManagers/appChatsManager.ts

@ -74,7 +74,7 @@ export class AppChatsManager { @@ -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;
}

5
src/lib/appManagers/appDialogsManager.ts

@ -498,10 +498,7 @@ export class AppDialogsManager { @@ -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) => {

22
src/lib/appManagers/appMessagesManager.ts

@ -3905,11 +3905,11 @@ export class AppMessagesManager { @@ -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 { @@ -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',

13
src/lib/appManagers/appNotificationsManager.ts

@ -82,6 +82,8 @@ export class AppNotificationsManager { @@ -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 { @@ -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…
Cancel
Save