diff --git a/src/components/chat/bubbles.ts b/src/components/chat/bubbles.ts index cb8d3dd5..1bfc2988 100644 --- a/src/components/chat/bubbles.ts +++ b/src/components/chat/bubbles.ts @@ -817,8 +817,17 @@ export default class ChatBubbles { } else if(target.classList.contains('name')) { const peerId = +target.dataset.peerId; - if(peerId) { - this.chat.appImManager.setInnerPeer(peerId); + const savedFrom = target.dataset.savedFrom; + if(savedFrom) { + const splitted = savedFrom.split('_'); + const peerId = +splitted[0]; + const msgId = +splitted[1]; + + this.chat.appImManager.setInnerPeer(peerId, msgId); + } else { + if(peerId) { + this.chat.appImManager.setInnerPeer(peerId); + } } return; @@ -2357,6 +2366,10 @@ export default class ChatBubbles { /* const fromTitle = message.fromId == this.myID || appPeersManager.isBroadcast(message.fwdFromId || message.fromId) ? '' : `
${appPeersManager.getPeerTitle(message.fromId)}
`; nameDiv.innerHTML = fromTitle + 'Forwarded from ' + title; */ nameDiv.innerHTML = 'Forwarded from ' + title; + + if(savedFrom) { + nameDiv.dataset.savedFrom = savedFrom; + } } nameContainer.append(nameDiv); @@ -2418,7 +2431,7 @@ export default class ChatBubbles { bubble.classList.add('is-thread-starter', 'is-group-last'); } - if(savedFrom && this.peerId !== REPLIES_PEER_ID) { + if(savedFrom && this.peerId === rootScope.myId && this.peerId !== REPLIES_PEER_ID) { const goto = document.createElement('div'); goto.classList.add('bubble-beside-button', 'goto-original', 'tgico-arrow_next'); bubbleContainer.append(goto); diff --git a/src/components/chat/messageRender.ts b/src/components/chat/messageRender.ts index ce31381a..af93e24b 100644 --- a/src/components/chat/messageRender.ts +++ b/src/components/chat/messageRender.ts @@ -20,7 +20,7 @@ export namespace MessageRender { bubble.classList.add('channel-post'); time = formatNumber(message.views, 1) + ' ' + (postAuthor ? RichTextProcessor.wrapEmojiText(postAuthor) + ', ' : '') + time; - if(!message.savedFrom) { + if(chat.peerId !== chat.appImManager.myId) { const forward = document.createElement('div'); forward.classList.add('bubble-beside-button', 'forward'); forward.innerHTML = ` diff --git a/src/lib/appManagers/appMessagesManager.ts b/src/lib/appManagers/appMessagesManager.ts index 56ba41de..ab7d3051 100644 --- a/src/lib/appManagers/appMessagesManager.ts +++ b/src/lib/appManagers/appMessagesManager.ts @@ -6,7 +6,7 @@ import { createPosterForVideo } from "../../helpers/files"; import { copy, defineNotNumerableProperties, getObjectKeysAndSort } from "../../helpers/object"; import { randomLong } from "../../helpers/random"; import { splitStringByLength, limitSymbols } from "../../helpers/string"; -import { Dialog as MTDialog, DialogPeer, DocumentAttribute, InputMedia, InputMessage, InputNotifyPeer, InputPeerNotifySettings, InputSingleMedia, Message, MessageAction, MessageEntity, MessageMedia, MessageReplies, MessageReplyHeader, MessagesDialogs, MessagesFilter, MessagesMessages, MessagesPeerDialogs, MethodDeclMap, NotifyPeer, PhotoSize, SendMessageAction, Update } from "../../layer"; +import { Dialog as MTDialog, DialogPeer, DocumentAttribute, InputMedia, InputMessage, InputNotifyPeer, InputPeerNotifySettings, InputSingleMedia, Message, MessageAction, MessageEntity, MessageFwdHeader, MessageMedia, MessageReplies, MessageReplyHeader, MessagesDialogs, MessagesFilter, MessagesMessages, MessagesPeerDialogs, MethodDeclMap, NotifyPeer, PhotoSize, SendMessageAction, Update } from "../../layer"; import { InvokeApiOptions } from "../../types"; import { langPack } from "../langPack"; import { logger, LogLevels } from "../logger"; @@ -19,7 +19,6 @@ import serverTimeManager from "../mtproto/serverTimeManager"; import { RichTextProcessor } from "../richtextprocessor"; import rootScope from "../rootScope"; import searchIndexManager from '../searchIndexManager'; -import sessionStorage from '../sessionStorage'; import DialogsStorage from "../storages/dialogs"; import FiltersStorage from "../storages/filters"; //import { telegramMeWebService } from "../mtproto/mtproto"; @@ -2140,13 +2139,17 @@ export class AppMessagesManager { message.fromId = message.pFlags.post || !message.from_id ? peerId : appPeersManager.getPeerId(message.from_id); } - const fwdHeader = message.fwd_from; + const fwdHeader = message.fwd_from as MessageFwdHeader; if(fwdHeader) { //if(peerId == myID) { - if(fwdHeader.saved_from_peer && fwdHeader.saved_from_msg_id) { - const savedFromPeerId = appPeersManager.getPeerId(fwdHeader.saved_from_peer); - //const savedFromMid = fwdHeader.saved_from_msg_id; - const savedFromMid = fwdHeader.saved_from_msg_id = this.generateMessageId(fwdHeader.saved_from_msg_id); + if(fwdHeader.saved_from_msg_id) fwdHeader.saved_from_msg_id = this.generateMessageId(fwdHeader.saved_from_msg_id); + if(fwdHeader.channel_post) fwdHeader.channel_post = this.generateMessageId(fwdHeader.channel_post); + + const peer = fwdHeader.saved_from_peer || fwdHeader.from_id; + const msgId = fwdHeader.saved_from_msg_id || fwdHeader.channel_post; + if(peer && msgId) { + const savedFromPeerId = appPeersManager.getPeerId(peer); + const savedFromMid = this.generateMessageId(msgId); message.savedFrom = savedFromPeerId + '_' + savedFromMid; }