Browse Source

Notifications:

Ignore muted state for mention
Display forwarded message content when it's single
master
Eduard Kuzmenko 3 years ago
parent
commit
7be8a806ab
  1. 23
      src/lib/appManagers/appMessagesManager.ts

23
src/lib/appManagers/appMessagesManager.ts

@ -4483,7 +4483,7 @@ export class AppMessagesManager {
const notifyPeerToHandle = this.notificationsToHandle[peerId]; const notifyPeerToHandle = this.notificationsToHandle[peerId];
this.getNotifyPeerSettings(peerId).then(({muted, peerTypeNotifySettings}) => { this.getNotifyPeerSettings(peerId).then(({muted, peerTypeNotifySettings}) => {
const topMessage = notifyPeerToHandle.topMessage; const topMessage = notifyPeerToHandle.topMessage;
if(muted || !topMessage.pFlags.unread) { if((muted && !topMessage.pFlags.mentioned) || !topMessage.pFlags.unread) {
return; return;
} }
@ -4734,9 +4734,9 @@ export class AppMessagesManager {
) )
) { ) {
this.getNotifyPeerSettings(peerId).then(({muted, peerTypeNotifySettings}) => { this.getNotifyPeerSettings(peerId).then(({muted, peerTypeNotifySettings}) => {
if(muted || !peerTypeNotifySettings.show_previews) return; if(/* muted || */!peerTypeNotifySettings.show_previews) return;
this.notifyAboutMessage(message, { this.notifyAboutMessage(message, {
userReaction: recentReaction, peerReaction: recentReaction,
peerTypeNotifySettings peerTypeNotifySettings
}); });
}); });
@ -5591,7 +5591,7 @@ export class AppMessagesManager {
private notifyAboutMessage(message: MyMessage, options: Partial<{ private notifyAboutMessage(message: MyMessage, options: Partial<{
fwdCount: number, fwdCount: number,
userReaction: MessagePeerReaction, peerReaction: MessagePeerReaction,
peerTypeNotifySettings: PeerNotifySettings peerTypeNotifySettings: PeerNotifySettings
}> = {}) { }> = {}) {
const peerId = this.getMessagePeer(message); const peerId = this.getMessagePeer(message);
@ -5606,15 +5606,15 @@ export class AppMessagesManager {
let notificationMessage: string; let notificationMessage: string;
if(options.peerTypeNotifySettings.show_previews) { if(options.peerTypeNotifySettings.show_previews) {
if(message._ === 'message' && message.fwd_from && options.fwdCount) { if(message._ === 'message' && message.fwd_from && options.fwdCount > 1) {
notificationMessage = I18n.format('Notifications.Forwarded', true, [options.fwdCount]); notificationMessage = I18n.format('Notifications.Forwarded', true, [options.fwdCount]);
} else { } else {
notificationMessage = this.wrapMessageForReply(message, undefined, undefined, true); notificationMessage = this.wrapMessageForReply(message, undefined, undefined, true);
if(options.userReaction) { if(options.peerReaction) {
const langPackKey: LangPackKey = /* isAnyChat ? 'Notification.Group.Reacted' : */'Notification.Contact.Reacted'; const langPackKey: LangPackKey = /* isAnyChat ? 'Notification.Group.Reacted' : */'Notification.Contact.Reacted';
const args: FormatterArguments = [ const args: FormatterArguments = [
RichTextProcessor.fixEmoji(options.userReaction.reaction), // can be plain heart RichTextProcessor.fixEmoji(options.peerReaction.reaction), // can be plain heart
notificationMessage notificationMessage
]; ];
@ -5629,14 +5629,15 @@ export class AppMessagesManager {
notificationMessage = I18n.format('Notifications.New', true); notificationMessage = I18n.format('Notifications.New', true);
} }
if(options.userReaction) { if(options.peerReaction) {
notification.noIncrement = true; notification.noIncrement = true;
notification.silent = true; notification.silent = true;
} }
const notificationFromPeerId = options.peerReaction ? appPeersManager.getPeerId(options.peerReaction.peer_id) : message.fromId;
notification.title = appPeersManager.getPeerTitle(peerId, true); notification.title = appPeersManager.getPeerTitle(peerId, true);
if(isAnyChat && message.fromId !== message.peerId) { if(isAnyChat && notificationFromPeerId !== message.peerId) {
notification.title = appPeersManager.getPeerTitle(message.fromId, true) + notification.title = appPeersManager.getPeerTitle(notificationFromPeerId, true) +
' @ ' + ' @ ' +
notification.title; notification.title;
} }
@ -5655,7 +5656,7 @@ export class AppMessagesManager {
const peerPhoto = appPeersManager.getPeerPhoto(peerId); const peerPhoto = appPeersManager.getPeerPhoto(peerId);
if(peerPhoto) { if(peerPhoto) {
appAvatarsManager.loadAvatar(peerId, peerPhoto, 'photo_small').loadPromise.then(url => { appAvatarsManager.loadAvatar(peerId, peerPhoto, 'photo_small').loadPromise.then(url => {
if(message.pFlags.unread || options.userReaction) { if(message.pFlags.unread || options.peerReaction) {
notification.image = url; notification.image = url;
appNotificationsManager.notify(notification); appNotificationsManager.notify(notification);
} }

Loading…
Cancel
Save