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 {
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,

View File

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

View File

@ -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,

View File

@ -545,7 +545,7 @@ const Message: FC<OwnProps & StateProps> = ({
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<OwnProps & StateProps> = ({
handleDocumentGroupSelectAll,
handleTopicChipClick,
handleStoryClick,
} = useInnerHandlers(
} = useInnerHandlers({
lang,
selectMessage,
message,
@ -639,11 +639,12 @@ const Message: FC<OwnProps & StateProps> = ({
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<HTMLDivElement>) => {
e.stopPropagation();

View File

@ -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<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,
) {
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<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 {
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!,
});
}
});

View File

@ -660,7 +660,6 @@ async function saveDraft<T extends GlobalState>({
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;

View File

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

View File

@ -127,7 +127,8 @@ body.cursor-ew-resize {
}
.svg-definitions {
display: none;
position: fixed; // Firefox requires definition to be visible
top: -99999px;
}
.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() {
if ('fonts' in document) {