Follow-ups (#5110)

This commit is contained in:
zubiden 2024-11-02 21:11:24 +04:00 committed by Alexander Zinchuk
parent 75a5fe7716
commit 9831f7c4b0
9 changed files with 67 additions and 33 deletions

View File

@ -179,8 +179,14 @@ export function buildApiMessageWithChatId(
): ApiMessage { ): ApiMessage {
const fromId = mtpMessage.fromId ? getApiChatIdFromMtpPeer(mtpMessage.fromId) : undefined; const fromId = mtpMessage.fromId ? getApiChatIdFromMtpPeer(mtpMessage.fromId) : undefined;
const peerId = mtpMessage.peerId ? getApiChatIdFromMtpPeer(mtpMessage.peerId) : undefined; const peerId = mtpMessage.peerId ? getApiChatIdFromMtpPeer(mtpMessage.peerId) : undefined;
const isChatWithSelf = !fromId && chatId === currentUserId; 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 content = buildMessageContent(mtpMessage);
const action = mtpMessage.action const action = mtpMessage.action
&& buildAction(mtpMessage.action, fromId, peerId, Boolean(mtpMessage.post), isOutgoing); && buildAction(mtpMessage.action, fromId, peerId, Boolean(mtpMessage.post), isOutgoing);
@ -196,7 +202,6 @@ export function buildApiMessageWithChatId(
const { const {
inlineButtons, keyboardButtons, keyboardPlaceholder, isKeyboardSingleUse, isKeyboardSelective, inlineButtons, keyboardButtons, keyboardPlaceholder, isKeyboardSingleUse, isKeyboardSelective,
} = buildReplyButtons(mtpMessage, isInvoiceMedia) || {}; } = buildReplyButtons(mtpMessage, isInvoiceMedia) || {};
const forwardInfo = mtpMessage.fwdFrom && buildApiMessageForwardInfo(mtpMessage.fwdFrom, isChatWithSelf);
const { mediaUnread: isMediaUnread, postAuthor } = mtpMessage; const { mediaUnread: isMediaUnread, postAuthor } = mtpMessage;
const groupedId = mtpMessage.groupedId && String(mtpMessage.groupedId); const groupedId = mtpMessage.groupedId && String(mtpMessage.groupedId);
const isInAlbum = Boolean(groupedId) && !(content.document || content.audio || content.sticker); const isInAlbum = Boolean(groupedId) && !(content.document || content.audio || content.sticker);
@ -296,6 +301,7 @@ function buildApiMessageForwardInfo(fwdFrom: GramJs.MessageFwdHeader, isChatWith
channelPostId: fwdFrom.channelPost, channelPostId: fwdFrom.channelPost,
isLinkedChannelPost: Boolean(fwdFrom.channelPost && savedFromPeerId && !isChatWithSelf), isLinkedChannelPost: Boolean(fwdFrom.channelPost && savedFromPeerId && !isChatWithSelf),
savedFromPeerId, savedFromPeerId,
isSavedOutgoing: fwdFrom.savedOut,
fromId, fromId,
fromChatId: fromId || savedFromPeerId, fromChatId: fromId || savedFromPeerId,
fromMessageId: fwdFrom.savedFromMsgId || fwdFrom.channelPost, fromMessageId: fwdFrom.savedFromMsgId || fwdFrom.channelPost,

View File

@ -571,6 +571,7 @@ export interface ApiMessageForwardInfo {
fromChatId?: string; fromChatId?: string;
fromId?: string; fromId?: string;
savedFromPeerId?: string; savedFromPeerId?: string;
isSavedOutgoing?: boolean;
fromMessageId?: number; fromMessageId?: number;
hiddenUserName?: string; hiddenUserName?: string;
postAuthorTitle?: string; postAuthorTitle?: string;

View File

@ -113,8 +113,10 @@ export default function getViewableMedia(params?: MediaViewerItem): ViewableMedi
} }
if (webPage) { if (webPage) {
const { photo: webPagePhoto, video: webPageVideo } = webPage; const { photo: webPagePhoto, video: webPageVideo, document: webPageDocument } = webPage;
const media = webPageVideo || webPagePhoto; const isDocumentMedia = webPageDocument && (isDocumentPhoto(webPageDocument) || isDocumentVideo(webPageDocument));
const mediaDocument = isDocumentMedia ? webPageDocument : undefined;
const media = webPageVideo || mediaDocument || webPagePhoto;
if (media) { if (media) {
return { return {
media, media,

View File

@ -545,7 +545,7 @@ const Message: FC<OwnProps & StateProps> = ({
const canForward = isChannel && !isScheduled && message.isForwardingAllowed && !isChatProtected; const canForward = isChannel && !isScheduled && message.isForwardingAllowed && !isChatProtected;
const canFocus = Boolean(isPinnedList const canFocus = Boolean(isPinnedList
|| (forwardInfo || (forwardInfo
&& (forwardInfo.isChannelPost || (isChatWithSelf && !isOwn) || isRepliesChat || isAnonymousForwards) && (forwardInfo.isChannelPost || isChatWithSelf || isRepliesChat || isAnonymousForwards)
&& forwardInfo.fromMessageId && forwardInfo.fromMessageId
)); ));
@ -625,7 +625,7 @@ const Message: FC<OwnProps & StateProps> = ({
handleDocumentGroupSelectAll, handleDocumentGroupSelectAll,
handleTopicChipClick, handleTopicChipClick,
handleStoryClick, handleStoryClick,
} = useInnerHandlers( } = useInnerHandlers({
lang, lang,
selectMessage, selectMessage,
message, message,
@ -639,11 +639,12 @@ const Message: FC<OwnProps & StateProps> = ({
senderPeer, senderPeer,
botSender, botSender,
messageTopic, messageTopic,
Boolean(requestedChatTranslationLanguage), isTranslatingChat: Boolean(requestedChatTranslationLanguage),
replyStory && 'content' in replyStory ? replyStory : undefined, story: replyStory && 'content' in replyStory ? replyStory : undefined,
isReplyPrivate, isReplyPrivate,
isRepliesChat, isRepliesChat,
); isSavedMessages: isChatWithSelf,
});
const handleEffectClick = useLastCallback((e: React.MouseEvent<HTMLDivElement>) => { const handleEffectClick = useLastCallback((e: React.MouseEvent<HTMLDivElement>) => {
e.stopPropagation(); e.stopPropagation();

View File

@ -13,25 +13,45 @@ import { getMessageReplyInfo } from '../../../../global/helpers/replies';
import useLastCallback from '../../../../hooks/useLastCallback'; import useLastCallback from '../../../../hooks/useLastCallback';
export default function useInnerHandlers( export default function useInnerHandlers({
lang: LangFn, lang,
selectMessage: (e: React.MouseEvent<HTMLDivElement, MouseEvent>, groupedId?: string) => void, selectMessage,
message: ApiMessage, message,
chatId: string, chatId,
threadId: ThreadId, threadId,
isInDocumentGroup: boolean, isInDocumentGroup,
asForwarded?: boolean, asForwarded,
isScheduled?: boolean, isScheduled,
album?: IAlbum, album,
avatarPeer?: ApiPeer, avatarPeer,
senderPeer?: ApiPeer, senderPeer,
botSender?: ApiUser, botSender,
messageTopic?: ApiTopic, messageTopic,
isTranslatingChat?: boolean, isTranslatingChat,
story?: ApiStory, story,
isReplyPrivate?: boolean, isReplyPrivate,
isRepliesChat?: boolean, isRepliesChat,
) { isSavedMessages,
}: {
lang: LangFn;
selectMessage: (e: React.MouseEvent<HTMLDivElement, 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 { const {
openChat, showNotification, focusMessage, openMediaViewer, openAudioPlayer, openChat, showNotification, focusMessage, openMediaViewer, openAudioPlayer,
markMessagesRead, cancelUploadMedia, sendPollVote, openForwardMenu, markMessagesRead, cancelUploadMedia, sendPollVote, openForwardMenu,
@ -175,9 +195,11 @@ export default function useInnerHandlers(
}); });
const handleFocusForwarded = useLastCallback(() => { const handleFocusForwarded = useLastCallback(() => {
const originalChatId = (isSavedMessages && forwardInfo!.savedFromPeerId) || forwardInfo!.fromChatId!;
if (isInDocumentGroup) { if (isInDocumentGroup) {
focusMessage({ focusMessage({
chatId: forwardInfo!.fromChatId!, groupedId, groupedChatId: chatId, messageId: forwardInfo!.fromMessageId!, chatId: originalChatId, groupedId, groupedChatId: chatId, messageId: forwardInfo!.fromMessageId!,
}); });
return; return;
} }
@ -190,7 +212,7 @@ export default function useInnerHandlers(
}); });
} else { } else {
focusMessage({ focusMessage({
chatId: forwardInfo!.fromChatId!, messageId: forwardInfo!.fromMessageId!, chatId: originalChatId, messageId: forwardInfo!.fromMessageId!,
}); });
} }
}); });

View File

@ -660,7 +660,6 @@ async function saveDraft<T extends GlobalState>({
isLocal: true, isLocal: true,
} : undefined; } : undefined;
global = getGlobal();
global = replaceThreadParam(global, chatId, threadId, 'draft', newDraft); global = replaceThreadParam(global, chatId, threadId, 'draft', newDraft);
if (!noLocalTimeUpdate) { if (!noLocalTimeUpdate) {
global = updateChat(global, chatId, { draftDate: newDraft?.date }); global = updateChat(global, chatId, { draftDate: newDraft?.date });
@ -1833,6 +1832,7 @@ addActionHandler('openChatOrTopicWithReplyInDraft', (global, actions, payload):
replyingMessage: {}, replyingMessage: {},
}, tabId); }, tabId);
setGlobal(global); setGlobal(global);
global = getGlobal();
const currentChat = selectCurrentChat(global, tabId); const currentChat = selectCurrentChat(global, tabId);
const currentThreadId = selectCurrentMessageList(global, tabId)?.threadId; const currentThreadId = selectCurrentMessageList(global, tabId)?.threadId;

View File

@ -115,6 +115,7 @@ addActionHandler('resetLocalPaidReactions', (global, actions, payload): ActionRe
return { return {
...reaction, ...reaction,
localAmount: undefined, localAmount: undefined,
localPreviousChosenOrder: undefined,
chosenOrder: reaction.localPreviousChosenOrder, chosenOrder: reaction.localPreviousChosenOrder,
}; };
} }

View File

@ -127,7 +127,8 @@ body.cursor-ew-resize {
} }
.svg-definitions { .svg-definitions {
display: none; position: fixed; // Firefox requires definition to be visible
top: -99999px;
} }
.allow-selection { .allow-selection {

View File

@ -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() { export default function preloadFonts() {
if ('fonts' in document) { if ('fonts' in document) {