|
|
@ -2345,6 +2345,7 @@ export class AppMessagesManager { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(message._ === 'messageEmpty') { |
|
|
|
if(message._ === 'messageEmpty') { |
|
|
|
|
|
|
|
message.deleted = true; |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2977,17 +2978,37 @@ export class AppMessagesManager { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case 'messageActionPinMessage': { |
|
|
|
case 'messageActionPinMessage': { |
|
|
|
const pinnedMessage = this.getMessageByPeer(message.peerId, message.reply_to_mid); |
|
|
|
const peerId = message.peerId; |
|
|
|
|
|
|
|
const pinnedMessage = this.getMessageByPeer(peerId, message.reply_to_mid); |
|
|
|
|
|
|
|
|
|
|
|
args = [ |
|
|
|
args = [ |
|
|
|
getNameDivHTML(message.fromId, plain), |
|
|
|
getNameDivHTML(message.fromId, plain), |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
if(pinnedMessage.deleted || true) { |
|
|
|
if(pinnedMessage.deleted/* || true */) { |
|
|
|
langPackKey = 'ActionPinnedNoText'; |
|
|
|
langPackKey = 'ActionPinnedNoText'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(message.reply_to_mid) { // refresh original message
|
|
|
|
|
|
|
|
this.fetchMessageReplyTo(message).then(originalMessage => { |
|
|
|
|
|
|
|
if(!originalMessage.deleted && !message.deleted) { |
|
|
|
|
|
|
|
rootScope.dispatchEvent('message_edit', { |
|
|
|
|
|
|
|
storage: this.getMessagesStorage(peerId), |
|
|
|
|
|
|
|
peerId: peerId, |
|
|
|
|
|
|
|
mid: message.mid |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(this.isMessageIsTopMessage(message)) { |
|
|
|
|
|
|
|
rootScope.dispatchEvent('dialogs_multiupdate', { |
|
|
|
|
|
|
|
[peerId]: this.getDialogOnly(peerId) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
const a = document.createElement('a'); |
|
|
|
const a = document.createElement('i'); |
|
|
|
a.dataset.savedFrom = pinnedMessage.peerId + '_' + pinnedMessage.mid; |
|
|
|
a.dataset.savedFrom = pinnedMessage.peerId + '_' + pinnedMessage.mid; |
|
|
|
|
|
|
|
a.dir = 'auto'; |
|
|
|
a.append(this.wrapMessageForReply(pinnedMessage, undefined, undefined, plain as any)); |
|
|
|
a.append(this.wrapMessageForReply(pinnedMessage, undefined, undefined, plain as any)); |
|
|
|
args.push(a); |
|
|
|
args.push(a); |
|
|
|
} |
|
|
|
} |
|
|
@ -4836,12 +4857,16 @@ export class AppMessagesManager { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
public setDialogToStateIfMessageIsTop(message: MyMessage) { |
|
|
|
public setDialogToStateIfMessageIsTop(message: MyMessage) { |
|
|
|
const dialog = this.getDialogOnly(message.peerId); |
|
|
|
if(this.isMessageIsTopMessage(message)) { |
|
|
|
if(dialog && dialog.top_message === message.mid) { |
|
|
|
this.dialogsStorage.setDialogToState(this.getDialogOnly(message.peerId)); |
|
|
|
this.dialogsStorage.setDialogToState(dialog); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public isMessageIsTopMessage(message: MyMessage) { |
|
|
|
|
|
|
|
const dialog = this.getDialogOnly(message.peerId); |
|
|
|
|
|
|
|
return dialog && dialog.top_message === message.mid; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private updateMessageRepliesIfNeeded(threadMessage: MyMessage) { |
|
|
|
private updateMessageRepliesIfNeeded(threadMessage: MyMessage) { |
|
|
|
try { // * на всякий случай, скорее всего это не понадобится
|
|
|
|
try { // * на всякий случай, скорее всего это не понадобится
|
|
|
|
const threadKey = this.getThreadKey(threadMessage); |
|
|
|
const threadKey = this.getThreadKey(threadMessage); |
|
|
@ -5562,6 +5587,18 @@ export class AppMessagesManager { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public fetchMessageReplyTo(message: MyMessage): Promise<Message> { |
|
|
|
|
|
|
|
if(!message.reply_to_mid) return Promise.resolve(this.generateEmptyMessage(0)); |
|
|
|
|
|
|
|
const replyToPeerId = message.reply_to.reply_to_peer_id ? appPeersManager.getPeerId(message.reply_to.reply_to_peer_id) : message.peerId; |
|
|
|
|
|
|
|
return this.wrapSingleMessage(replyToPeerId, message.reply_to_mid).then(originalMessage => { |
|
|
|
|
|
|
|
if(originalMessage.deleted) { // ! чтобы не пыталось бесконечно загрузить удалённое сообщение
|
|
|
|
|
|
|
|
delete message.reply_to_mid; // ! WARNING!
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return originalMessage; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public setTyping(peerId: PeerId, action: SendMessageAction): Promise<boolean> { |
|
|
|
public setTyping(peerId: PeerId, action: SendMessageAction): Promise<boolean> { |
|
|
|
let typing = this.typings[peerId]; |
|
|
|
let typing = this.typings[peerId]; |
|
|
|
if(!rootScope.myId || |
|
|
|
if(!rootScope.myId || |
|
|
|