diff --git a/src/api/gramjs/apiBuilders/messages.ts b/src/api/gramjs/apiBuilders/messages.ts index be6b239f4..997d8a84f 100644 --- a/src/api/gramjs/apiBuilders/messages.ts +++ b/src/api/gramjs/apiBuilders/messages.ts @@ -179,8 +179,14 @@ export function buildApiMessageWithChatId( ): ApiMessage { const fromId = mtpMessage.fromId ? getApiChatIdFromMtpPeer(mtpMessage.fromId) : undefined; const peerId = mtpMessage.peerId ? getApiChatIdFromMtpPeer(mtpMessage.peerId) : undefined; + const isChatWithSelf = !fromId && chatId === currentUserId; - const isOutgoing = (mtpMessage.out && !mtpMessage.post) || (isChatWithSelf && !mtpMessage.fwdFrom); + const forwardInfo = mtpMessage.fwdFrom && buildApiMessageForwardInfo(mtpMessage.fwdFrom, isChatWithSelf); + + const isSavedOutgoing = Boolean(!forwardInfo || forwardInfo.fromId === currentUserId || forwardInfo.isSavedOutgoing); + + const isOutgoing = !isChatWithSelf ? Boolean(mtpMessage.out && !mtpMessage.post) + : isSavedOutgoing; const content = buildMessageContent(mtpMessage); const action = mtpMessage.action && buildAction(mtpMessage.action, fromId, peerId, Boolean(mtpMessage.post), isOutgoing); @@ -196,7 +202,6 @@ export function buildApiMessageWithChatId( const { inlineButtons, keyboardButtons, keyboardPlaceholder, isKeyboardSingleUse, isKeyboardSelective, } = buildReplyButtons(mtpMessage, isInvoiceMedia) || {}; - const forwardInfo = mtpMessage.fwdFrom && buildApiMessageForwardInfo(mtpMessage.fwdFrom, isChatWithSelf); const { mediaUnread: isMediaUnread, postAuthor } = mtpMessage; const groupedId = mtpMessage.groupedId && String(mtpMessage.groupedId); const isInAlbum = Boolean(groupedId) && !(content.document || content.audio || content.sticker); @@ -296,6 +301,7 @@ function buildApiMessageForwardInfo(fwdFrom: GramJs.MessageFwdHeader, isChatWith channelPostId: fwdFrom.channelPost, isLinkedChannelPost: Boolean(fwdFrom.channelPost && savedFromPeerId && !isChatWithSelf), savedFromPeerId, + isSavedOutgoing: fwdFrom.savedOut, fromId, fromChatId: fromId || savedFromPeerId, fromMessageId: fwdFrom.savedFromMsgId || fwdFrom.channelPost, diff --git a/src/api/types/messages.ts b/src/api/types/messages.ts index c6d430bd0..1f4e89a96 100644 --- a/src/api/types/messages.ts +++ b/src/api/types/messages.ts @@ -571,6 +571,7 @@ export interface ApiMessageForwardInfo { fromChatId?: string; fromId?: string; savedFromPeerId?: string; + isSavedOutgoing?: boolean; fromMessageId?: number; hiddenUserName?: string; postAuthorTitle?: string; diff --git a/src/components/mediaViewer/helpers/getViewableMedia.ts b/src/components/mediaViewer/helpers/getViewableMedia.ts index 66c304ba5..98478434d 100644 --- a/src/components/mediaViewer/helpers/getViewableMedia.ts +++ b/src/components/mediaViewer/helpers/getViewableMedia.ts @@ -113,8 +113,10 @@ export default function getViewableMedia(params?: MediaViewerItem): ViewableMedi } if (webPage) { - const { photo: webPagePhoto, video: webPageVideo } = webPage; - const media = webPageVideo || webPagePhoto; + const { photo: webPagePhoto, video: webPageVideo, document: webPageDocument } = webPage; + const isDocumentMedia = webPageDocument && (isDocumentPhoto(webPageDocument) || isDocumentVideo(webPageDocument)); + const mediaDocument = isDocumentMedia ? webPageDocument : undefined; + const media = webPageVideo || mediaDocument || webPagePhoto; if (media) { return { media, diff --git a/src/components/middle/message/Message.tsx b/src/components/middle/message/Message.tsx index 673d78a91..fc7c895d8 100644 --- a/src/components/middle/message/Message.tsx +++ b/src/components/middle/message/Message.tsx @@ -545,7 +545,7 @@ const Message: FC = ({ const canForward = isChannel && !isScheduled && message.isForwardingAllowed && !isChatProtected; const canFocus = Boolean(isPinnedList || (forwardInfo - && (forwardInfo.isChannelPost || (isChatWithSelf && !isOwn) || isRepliesChat || isAnonymousForwards) + && (forwardInfo.isChannelPost || isChatWithSelf || isRepliesChat || isAnonymousForwards) && forwardInfo.fromMessageId )); @@ -625,7 +625,7 @@ const Message: FC = ({ handleDocumentGroupSelectAll, handleTopicChipClick, handleStoryClick, - } = useInnerHandlers( + } = useInnerHandlers({ lang, selectMessage, message, @@ -639,11 +639,12 @@ const Message: FC = ({ senderPeer, botSender, messageTopic, - Boolean(requestedChatTranslationLanguage), - replyStory && 'content' in replyStory ? replyStory : undefined, + isTranslatingChat: Boolean(requestedChatTranslationLanguage), + story: replyStory && 'content' in replyStory ? replyStory : undefined, isReplyPrivate, isRepliesChat, - ); + isSavedMessages: isChatWithSelf, + }); const handleEffectClick = useLastCallback((e: React.MouseEvent) => { e.stopPropagation(); diff --git a/src/components/middle/message/hooks/useInnerHandlers.ts b/src/components/middle/message/hooks/useInnerHandlers.ts index 7501e823d..7c16a6789 100644 --- a/src/components/middle/message/hooks/useInnerHandlers.ts +++ b/src/components/middle/message/hooks/useInnerHandlers.ts @@ -13,25 +13,45 @@ import { getMessageReplyInfo } from '../../../../global/helpers/replies'; import useLastCallback from '../../../../hooks/useLastCallback'; -export default function useInnerHandlers( - lang: LangFn, - selectMessage: (e: React.MouseEvent, groupedId?: string) => void, - message: ApiMessage, - chatId: string, - threadId: ThreadId, - isInDocumentGroup: boolean, - asForwarded?: boolean, - isScheduled?: boolean, - album?: IAlbum, - avatarPeer?: ApiPeer, - senderPeer?: ApiPeer, - botSender?: ApiUser, - messageTopic?: ApiTopic, - isTranslatingChat?: boolean, - story?: ApiStory, - isReplyPrivate?: boolean, - isRepliesChat?: boolean, -) { +export default function useInnerHandlers({ + lang, + selectMessage, + message, + chatId, + threadId, + isInDocumentGroup, + asForwarded, + isScheduled, + album, + avatarPeer, + senderPeer, + botSender, + messageTopic, + isTranslatingChat, + story, + isReplyPrivate, + isRepliesChat, + isSavedMessages, +}: { + lang: LangFn; + selectMessage: (e: React.MouseEvent, groupedId?: string) => void; + message: ApiMessage; + chatId: string; + threadId: ThreadId; + isInDocumentGroup: boolean; + asForwarded?: boolean; + isScheduled?: boolean; + album?: IAlbum; + avatarPeer?: ApiPeer; + senderPeer?: ApiPeer; + botSender?: ApiUser; + messageTopic?: ApiTopic; + isTranslatingChat?: boolean; + story?: ApiStory; + isReplyPrivate?: boolean; + isRepliesChat?: boolean; + isSavedMessages?: boolean; +}) { const { openChat, showNotification, focusMessage, openMediaViewer, openAudioPlayer, markMessagesRead, cancelUploadMedia, sendPollVote, openForwardMenu, @@ -175,9 +195,11 @@ export default function useInnerHandlers( }); const handleFocusForwarded = useLastCallback(() => { + const originalChatId = (isSavedMessages && forwardInfo!.savedFromPeerId) || forwardInfo!.fromChatId!; + if (isInDocumentGroup) { focusMessage({ - chatId: forwardInfo!.fromChatId!, groupedId, groupedChatId: chatId, messageId: forwardInfo!.fromMessageId!, + chatId: originalChatId, groupedId, groupedChatId: chatId, messageId: forwardInfo!.fromMessageId!, }); return; } @@ -190,7 +212,7 @@ export default function useInnerHandlers( }); } else { focusMessage({ - chatId: forwardInfo!.fromChatId!, messageId: forwardInfo!.fromMessageId!, + chatId: originalChatId, messageId: forwardInfo!.fromMessageId!, }); } }); diff --git a/src/global/actions/api/messages.ts b/src/global/actions/api/messages.ts index f52400cb3..c9c68bea8 100644 --- a/src/global/actions/api/messages.ts +++ b/src/global/actions/api/messages.ts @@ -660,7 +660,6 @@ async function saveDraft({ isLocal: true, } : undefined; - global = getGlobal(); global = replaceThreadParam(global, chatId, threadId, 'draft', newDraft); if (!noLocalTimeUpdate) { global = updateChat(global, chatId, { draftDate: newDraft?.date }); @@ -1833,6 +1832,7 @@ addActionHandler('openChatOrTopicWithReplyInDraft', (global, actions, payload): replyingMessage: {}, }, tabId); setGlobal(global); + global = getGlobal(); const currentChat = selectCurrentChat(global, tabId); const currentThreadId = selectCurrentMessageList(global, tabId)?.threadId; diff --git a/src/global/actions/ui/reactions.ts b/src/global/actions/ui/reactions.ts index 9577bd7d4..6ae36d495 100644 --- a/src/global/actions/ui/reactions.ts +++ b/src/global/actions/ui/reactions.ts @@ -115,6 +115,7 @@ addActionHandler('resetLocalPaidReactions', (global, actions, payload): ActionRe return { ...reaction, localAmount: undefined, + localPreviousChosenOrder: undefined, chosenOrder: reaction.localPreviousChosenOrder, }; } diff --git a/src/styles/index.scss b/src/styles/index.scss index 99cf337ad..80bcc6d26 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -127,7 +127,8 @@ body.cursor-ew-resize { } .svg-definitions { - display: none; + position: fixed; // Firefox requires definition to be visible + top: -99999px; } .allow-selection { diff --git a/src/util/fonts.ts b/src/util/fonts.ts index 3254d3c2b..260c9004f 100644 --- a/src/util/fonts.ts +++ b/src/util/fonts.ts @@ -1,4 +1,4 @@ -const SITE_FONTS = ['400 1em Roboto', '500 1em Roboto', "500 1em 'Roboto Round'"]; +const SITE_FONTS = ['400 1em Roboto', '500 1em Roboto', "500 1em 'Numbers Rounded'"]; export default function preloadFonts() { if ('fonts' in document) {