Various fixes for quotes and giveaways (#3964)

This commit is contained in:
Alexander Zinchuk 2023-11-12 12:49:10 +04:00
parent 3904c313c8
commit 51f606760c
11 changed files with 34 additions and 21 deletions

View File

@ -338,6 +338,7 @@ function buildAction(
let isTopicAction: boolean | undefined; let isTopicAction: boolean | undefined;
let slug: string | undefined; let slug: string | undefined;
let isGiveaway: boolean | undefined; let isGiveaway: boolean | undefined;
let isUnclaimed: boolean | undefined;
const targetUserIds = 'users' in action const targetUserIds = 'users' in action
? action.users && action.users.map((id) => buildApiPeerId(id, 'user')) ? action.users && action.users.map((id) => buildApiPeerId(id, 'user'))
@ -533,6 +534,7 @@ function buildAction(
slug = action.slug; slug = action.slug;
months = action.months; months = action.months;
isGiveaway = Boolean(action.viaGiveaway); isGiveaway = Boolean(action.viaGiveaway);
isUnclaimed = Boolean(action.unclaimed);
if (action.boostPeer) { if (action.boostPeer) {
targetChatId = getApiChatIdFromMtpPeer(action.boostPeer); targetChatId = getApiChatIdFromMtpPeer(action.boostPeer);
} }
@ -563,6 +565,7 @@ function buildAction(
months, months,
topicEmojiIconId, topicEmojiIconId,
isTopicAction, isTopicAction,
isUnclaimed,
}; };
} }

View File

@ -292,6 +292,7 @@ export interface ApiAction {
isTopicAction?: boolean; isTopicAction?: boolean;
slug?: string; slug?: string;
isGiveaway?: boolean; isGiveaway?: boolean;
isUnclaimed?: boolean;
} }
export interface ApiWebPage { export interface ApiWebPage {

View File

@ -148,15 +148,6 @@ const EmbeddedMessage: FC<OwnProps> = ({
} }
function renderSender() { function renderSender() {
if (forwardSenderTitle && !areSendersSame) {
return (
<>
<Icon name={forwardSender ? 'share-filled' : 'forward'} className="embedded-origin-icon" />
{renderText(forwardSenderTitle)}
</>
);
}
if (title) { if (title) {
return renderText(title); return renderText(title);
} }
@ -165,11 +156,9 @@ const EmbeddedMessage: FC<OwnProps> = ({
return NBSP; return NBSP;
} }
let shouldIgnoreSender = false;
let icon: IconName | undefined; let icon: IconName | undefined;
if (senderChat) { if (senderChat) {
if (isChatChannel(senderChat)) { if (isChatChannel(senderChat)) {
shouldIgnoreSender = true;
icon = 'channel-filled'; icon = 'channel-filled';
} }
@ -178,11 +167,13 @@ const EmbeddedMessage: FC<OwnProps> = ({
} }
} }
const isChatSender = senderChat?.id === sender?.id;
return ( return (
<> <>
{!shouldIgnoreSender && <span className="embedded-sender">{renderText(senderTitle)}</span>} {!isChatSender && <span className="embedded-sender">{renderText(senderTitle)}</span>}
{icon && <Icon name={icon} className="embedded-chat-icon" />} {icon && <Icon name={icon} className="embedded-chat-icon" />}
{senderChatTitle && renderText(senderChatTitle)} {icon && senderChatTitle && renderText(senderChatTitle)}
</> </>
); );
} }
@ -211,6 +202,12 @@ const EmbeddedMessage: FC<OwnProps> = ({
</p> </p>
<div className="message-title"> <div className="message-title">
{renderSender()} {renderSender()}
{forwardSenderTitle && !areSendersSame && (
<>
<Icon name={forwardSender ? 'share-filled' : 'forward'} className="embedded-origin-icon" />
{renderText(forwardSenderTitle)}
</>
)}
</div> </div>
</div> </div>
</div> </div>

View File

@ -392,9 +392,11 @@ function processEntity({
return <strong data-entity-type={entity.type}>{renderNestedMessagePart()}</strong>; return <strong data-entity-type={entity.type}>{renderNestedMessagePart()}</strong>;
case ApiMessageEntityTypes.Blockquote: case ApiMessageEntityTypes.Blockquote:
return ( return (
<blockquote data-entity-type={entity.type}> <div className="text-entity-blockquote-wrapper">
{renderNestedMessagePart()} <blockquote data-entity-type={entity.type}>
</blockquote> {renderNestedMessagePart()}
</blockquote>
</div>
); );
case ApiMessageEntityTypes.BotCommand: case ApiMessageEntityTypes.BotCommand:
return ( return (

View File

@ -236,6 +236,7 @@ const ActionMessage: FC<OwnProps & StateProps> = ({
function renderGiftCode() { function renderGiftCode() {
const isFromGiveaway = message.content.action?.isGiveaway; const isFromGiveaway = message.content.action?.isGiveaway;
const isUnclaimed = message.content.action?.isUnclaimed;
return ( return (
<span <span
className="action-message-gift action-message-gift-code" className="action-message-gift action-message-gift-code"
@ -250,10 +251,11 @@ const ActionMessage: FC<OwnProps & StateProps> = ({
noLoop noLoop
nonInteractive nonInteractive
/> />
<strong>{lang('BoostingUnclaimedPrize')}</strong> <strong>{lang(isUnclaimed ? 'BoostingUnclaimedPrize' : 'BoostingCongratulations')}</strong>
<span className="action-message-subtitle"> <span className="action-message-subtitle">
{renderText(lang(isFromGiveaway ? 'BoostingReceivedGiftFrom' : 'BoostingYouHaveUnclaimedPrize', {renderText(lang(isFromGiveaway ? 'BoostingReceivedGiftFrom' : isUnclaimed
getChatTitle(lang, targetChat!)), ? 'BoostingReceivedPrizeFrom' : 'BoostingYouHaveUnclaimedPrize',
getChatTitle(lang, targetChat!)),
['simple_markdown'])} ['simple_markdown'])}
</span> </span>
<span className="action-message-subtitle"> <span className="action-message-subtitle">

View File

@ -11,6 +11,7 @@
.gift { .gift {
position: relative; position: relative;
margin-top: -3rem;
} }
.count { .count {

View File

@ -585,6 +585,7 @@ const Message: FC<OwnProps & StateProps> = ({
Boolean(requestedChatTranslationLanguage), Boolean(requestedChatTranslationLanguage),
replyStory && 'content' in replyStory ? replyStory : undefined, replyStory && 'content' in replyStory ? replyStory : undefined,
isReplyPrivate, isReplyPrivate,
isRepliesChat,
); );
useEffect(() => { useEffect(() => {

View File

@ -30,6 +30,7 @@ export default function useInnerHandlers(
isTranslatingChat?: boolean, isTranslatingChat?: boolean,
story?: ApiStory, story?: ApiStory,
isReplyPrivate?: boolean, isReplyPrivate?: boolean,
isRepliesChat?: boolean,
) { ) {
const { const {
openChat, showNotification, focusMessage, openMediaViewer, openAudioPlayer, openChat, showNotification, focusMessage, openMediaViewer, openAudioPlayer,
@ -85,10 +86,10 @@ export default function useInnerHandlers(
focusMessage({ focusMessage({
chatId: replyToPeerId || chatId, chatId: replyToPeerId || chatId,
threadId: replyToTopId || threadId, threadId: isRepliesChat ? replyToTopId : threadId, // Open comments from Replies bot, otherwise, keep current thread
messageId: replyToMsgId, messageId: replyToMsgId,
replyMessageId: replyToPeerId ? undefined : messageId, replyMessageId: replyToPeerId ? undefined : messageId,
noForumTopicPanel: !replyToPeerId ? true : undefined, // Open topic panel for cross-chat replies noForumTopicPanel: !replyToPeerId, // Open topic panel for cross-chat replies
}); });
}); });

View File

@ -421,6 +421,9 @@ export function selectSender<T extends GlobalState>(global: T, message: ApiMessa
return undefined; return undefined;
} }
const chat = selectChat(global, message.chatId);
if (chat && isChatChannel(chat)) return chat;
return selectPeer(global, senderId); return selectPeer(global, senderId);
} }

View File

@ -1489,6 +1489,7 @@ stories.sendReaction#7fd736b2 flags:# add_to_recent:flags.0?true peer:InputPeer
stories.getPeerStories#2c4ada50 peer:InputPeer = stories.PeerStories; stories.getPeerStories#2c4ada50 peer:InputPeer = stories.PeerStories;
stories.getPeerMaxIDs#535983c3 id:Vector<InputPeer> = Vector<int>; stories.getPeerMaxIDs#535983c3 id:Vector<InputPeer> = Vector<int>;
stories.togglePeerStoriesHidden#bd0415c4 peer:InputPeer hidden:Bool = Bool; stories.togglePeerStoriesHidden#bd0415c4 peer:InputPeer hidden:Bool = Bool;
premium.getBoostsList#60f67660 flags:# gifts:flags.0?true peer:InputPeer offset:string limit:int = premium.BoostsList;
premium.getMyBoosts#be77b4a = premium.MyBoosts; premium.getMyBoosts#be77b4a = premium.MyBoosts;
premium.applyBoost#6b7da746 flags:# slots:flags.0?Vector<int> peer:InputPeer = premium.MyBoosts; premium.applyBoost#6b7da746 flags:# slots:flags.0?Vector<int> peer:InputPeer = premium.MyBoosts;
premium.getBoostsStatus#42f1f61 peer:InputPeer = premium.BoostsStatus;`; premium.getBoostsStatus#42f1f61 peer:InputPeer = premium.BoostsStatus;`;

View File

@ -319,6 +319,7 @@
"premium.getBoostersList", "premium.getBoostersList",
"premium.applyBoost", "premium.applyBoost",
"premium.getMyBoosts", "premium.getMyBoosts",
"premium.getBoostsList",
"payments.checkGiftCode", "payments.checkGiftCode",
"payments.applyGiftCode", "payments.applyGiftCode",
"payments.getGiveawayInfo" "payments.getGiveawayInfo"