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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -30,6 +30,7 @@ export default function useInnerHandlers(
isTranslatingChat?: boolean,
story?: ApiStory,
isReplyPrivate?: boolean,
isRepliesChat?: boolean,
) {
const {
openChat, showNotification, focusMessage, openMediaViewer, openAudioPlayer,
@ -85,10 +86,10 @@ export default function useInnerHandlers(
focusMessage({
chatId: replyToPeerId || chatId,
threadId: replyToTopId || threadId,
threadId: isRepliesChat ? replyToTopId : threadId, // Open comments from Replies bot, otherwise, keep current thread
messageId: replyToMsgId,
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;
}
const chat = selectChat(global, message.chatId);
if (chat && isChatChannel(chat)) return chat;
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.getPeerMaxIDs#535983c3 id:Vector<InputPeer> = Vector<int>;
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.applyBoost#6b7da746 flags:# slots:flags.0?Vector<int> peer:InputPeer = premium.MyBoosts;
premium.getBoostsStatus#42f1f61 peer:InputPeer = premium.BoostsStatus;`;

View File

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