Unique Gifts: Various fixes (#5437)
This commit is contained in:
parent
a414faa985
commit
a7ebaf3aa8
@ -368,16 +368,20 @@ export function buildApiFactCheck(factCheck: GramJs.FactCheck): ApiFactCheck {
|
|||||||
|
|
||||||
function buildApiMessageActionStarGift(action: GramJs.MessageActionStarGift) : ApiMessageActionStarGift {
|
function buildApiMessageActionStarGift(action: GramJs.MessageActionStarGift) : ApiMessageActionStarGift {
|
||||||
const {
|
const {
|
||||||
nameHidden, saved, converted, gift, message, convertStars,
|
nameHidden, saved, converted, gift, message, convertStars, canUpgrade, upgraded, upgradeMsgId,
|
||||||
} = action;
|
} = action;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
type: 'starGift',
|
||||||
isNameHidden: Boolean(nameHidden),
|
isNameHidden: Boolean(nameHidden),
|
||||||
isSaved: Boolean(saved),
|
isSaved: Boolean(saved),
|
||||||
isConverted: Boolean(converted),
|
isConverted: converted,
|
||||||
gift: buildApiStarGift(gift),
|
gift: buildApiStarGift(gift),
|
||||||
message: message && buildApiFormattedText(message),
|
message: message && buildApiFormattedText(message),
|
||||||
starsToConvert: convertStars?.toJSNumber(),
|
starsToConvert: convertStars?.toJSNumber(),
|
||||||
|
canUpgrade,
|
||||||
|
isUpgraded: upgraded,
|
||||||
|
upgradeMsgId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,6 +393,7 @@ function buildApiMessageActionStarGiftUnique(
|
|||||||
} = action;
|
} = action;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
type: 'starGiftUnique',
|
||||||
gift: buildApiStarGift(gift),
|
gift: buildApiStarGift(gift),
|
||||||
canExportAt,
|
canExportAt,
|
||||||
isRefunded: refunded,
|
isRefunded: refunded,
|
||||||
@ -747,7 +752,13 @@ function buildAction(
|
|||||||
currency = STARS_CURRENCY_CODE;
|
currency = STARS_CURRENCY_CODE;
|
||||||
} else if (action instanceof GramJs.MessageActionStarGiftUnique && action.gift instanceof GramJs.StarGiftUnique) {
|
} else if (action instanceof GramJs.MessageActionStarGiftUnique && action.gift instanceof GramJs.StarGiftUnique) {
|
||||||
type = 'starGiftUnique';
|
type = 'starGiftUnique';
|
||||||
text = isOutgoing ? 'Notification.StarsGift.UpgradeYou' : 'Notification.StarsGift.Upgrade';
|
if (isOutgoing) {
|
||||||
|
text = action.upgrade ? 'Notification.StarsGift.UpgradeYou' : 'ActionUniqueGiftTransferOutbound';
|
||||||
|
} else {
|
||||||
|
text = action.upgrade ? 'Notification.StarsGift.Upgrade' : 'ActionUniqueGiftTransferInbound';
|
||||||
|
translationValues.push('%action_origin%');
|
||||||
|
}
|
||||||
|
|
||||||
starGift = buildApiMessageActionStarGiftUnique(action);
|
starGift = buildApiMessageActionStarGiftUnique(action);
|
||||||
|
|
||||||
if (targetPeerId) {
|
if (targetPeerId) {
|
||||||
|
|||||||
@ -459,15 +459,20 @@ export type ApiNewPoll = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export interface ApiMessageActionStarGift {
|
export interface ApiMessageActionStarGift {
|
||||||
|
type: 'starGift';
|
||||||
isNameHidden: boolean;
|
isNameHidden: boolean;
|
||||||
isSaved: boolean;
|
isSaved: boolean;
|
||||||
isConverted?: boolean;
|
isConverted?: true;
|
||||||
gift: ApiStarGift;
|
gift: ApiStarGift;
|
||||||
message?: ApiFormattedText;
|
message?: ApiFormattedText;
|
||||||
starsToConvert?: number;
|
starsToConvert?: number;
|
||||||
|
canUpgrade?: true;
|
||||||
|
isUpgraded?: true;
|
||||||
|
upgradeMsgId?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ApiMessageActionStarGiftUnique {
|
export interface ApiMessageActionStarGiftUnique {
|
||||||
|
type: 'starGiftUnique';
|
||||||
isUpgrade?: true;
|
isUpgrade?: true;
|
||||||
isTransferred?: true;
|
isTransferred?: true;
|
||||||
isSaved?: true;
|
isSaved?: true;
|
||||||
|
|||||||
@ -265,6 +265,7 @@ export interface ApiUserStarGift {
|
|||||||
messageId?: number;
|
messageId?: number;
|
||||||
starsToConvert?: number;
|
starsToConvert?: number;
|
||||||
isConverted?: boolean; // Local field, used for Action Message
|
isConverted?: boolean; // Local field, used for Action Message
|
||||||
|
upgradeMsgId?: number; // Local field, used for Action Message
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ApiPremiumGiftCodeOption {
|
export interface ApiPremiumGiftCodeOption {
|
||||||
|
|||||||
@ -1357,6 +1357,7 @@
|
|||||||
"GiftInfoOriginalInfoTextSender" = "Gifted by {sender} to {user} on {date} with comment \"{text}\"."
|
"GiftInfoOriginalInfoTextSender" = "Gifted by {sender} to {user} on {date} with comment \"{text}\"."
|
||||||
"GiftInfoStatus" = "Status";
|
"GiftInfoStatus" = "Status";
|
||||||
"GiftInfoStatusNonUnique" = "Non-Unique";
|
"GiftInfoStatusNonUnique" = "Non-Unique";
|
||||||
|
"GiftInfoViewUpgraded" = "View Upgraded Gift";
|
||||||
"StarsAmount" = "⭐️{amount}";
|
"StarsAmount" = "⭐️{amount}";
|
||||||
"StarsAmountText_one" = "{amount} Star";
|
"StarsAmountText_one" = "{amount} Star";
|
||||||
"StarsAmountText_other" = "{amount} Stars";
|
"StarsAmountText_other" = "{amount} Stars";
|
||||||
@ -1377,6 +1378,10 @@
|
|||||||
"ActionStarGiftOutDescription" = "{user} can display this gift on their page or convert it to {count} Stars.";
|
"ActionStarGiftOutDescription" = "{user} can display this gift on their page or convert it to {count} Stars.";
|
||||||
"ActionStarGiftDescription" = "Display this gift on your page or convert it to {count} Stars.";
|
"ActionStarGiftDescription" = "Display this gift on your page or convert it to {count} Stars.";
|
||||||
"ActionStarGiftDisplaying" = "You kept this gift on your page.";
|
"ActionStarGiftDisplaying" = "You kept this gift on your page.";
|
||||||
|
"ActionStarGiftOutDescriptionUpgrade" = "{user} can turn this gift to a unique collectible.";
|
||||||
|
"ActionStarGiftDescriptionUpgrade" = "Tap “Unpack” to turn this gift to a unique collectible.";
|
||||||
|
"ActionStarGiftUpgraded" = "This gift was upgraded.";
|
||||||
|
"ActionStarGiftUnpack" = "Unpack";
|
||||||
"GiftTo" = "Gift to";
|
"GiftTo" = "Gift to";
|
||||||
"GiftFrom" = "Gift from";
|
"GiftFrom" = "Gift from";
|
||||||
"ReceivedGift" = "Received Gift";
|
"ReceivedGift" = "Received Gift";
|
||||||
@ -1474,5 +1479,6 @@
|
|||||||
"ProfileTabVoice" = "Voice";
|
"ProfileTabVoice" = "Voice";
|
||||||
"ProfileTabSharedGroups" = "Groups";
|
"ProfileTabSharedGroups" = "Groups";
|
||||||
"ProfileTabSimilarChannels" = "Similar Channels";
|
"ProfileTabSimilarChannels" = "Similar Channels";
|
||||||
|
"ActionUnsupportedTitle" = "Action not supported yet";
|
||||||
|
"ActionUnsupportedDescription" = "Please, use one of our apps to complete this action.";
|
||||||
"LocationPermissionText" = "**{name}** requests access to set your **location**. You will be able to revoke this access in the profile page of **{name}**.";
|
"LocationPermissionText" = "**{name}** requests access to set your **location**. You will be able to revoke this access in the profile page of **{name}**.";
|
||||||
|
|
||||||
|
|||||||
@ -97,6 +97,11 @@ export function renderActionMessageText(
|
|||||||
unprocessed = unprocessed
|
unprocessed = unprocessed
|
||||||
.replace('%@', '%action_origin%');
|
.replace('%@', '%action_origin%');
|
||||||
}
|
}
|
||||||
|
if (translationKey.startsWith('ActionUniqueGiftTransfer')) {
|
||||||
|
unprocessed = unprocessed
|
||||||
|
.replace('un1', '%action_origin%')
|
||||||
|
.replace(/\*\*/g, '');
|
||||||
|
}
|
||||||
if (translationKey === 'BoostingReceivedPrizeFrom') {
|
if (translationKey === 'BoostingReceivedPrizeFrom') {
|
||||||
unprocessed = unprocessed
|
unprocessed = unprocessed
|
||||||
.replace('**%s**', '%target_chat%')
|
.replace('**%s**', '%target_chat%')
|
||||||
|
|||||||
@ -5,12 +5,12 @@ import React, {
|
|||||||
import { getActions, withGlobal } from '../../../global';
|
import { getActions, withGlobal } from '../../../global';
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
|
ApiBotVerification,
|
||||||
ApiChat,
|
ApiChat,
|
||||||
ApiCountryCode,
|
ApiCountryCode,
|
||||||
ApiUser,
|
ApiUser,
|
||||||
ApiUserFullInfo,
|
ApiUserFullInfo,
|
||||||
ApiUsername,
|
ApiUsername,
|
||||||
ApiBotVerification,
|
|
||||||
} from '../../../api/types';
|
} from '../../../api/types';
|
||||||
import type { BotAppPermissions } from '../../../types';
|
import type { BotAppPermissions } from '../../../types';
|
||||||
import { MAIN_THREAD_ID } from '../../../api/types';
|
import { MAIN_THREAD_ID } from '../../../api/types';
|
||||||
|
|||||||
@ -42,6 +42,7 @@ import {
|
|||||||
selectOutgoingStatus,
|
selectOutgoingStatus,
|
||||||
selectPeer,
|
selectPeer,
|
||||||
selectPeerStory,
|
selectPeerStory,
|
||||||
|
selectSender,
|
||||||
selectTabState,
|
selectTabState,
|
||||||
selectThreadParam,
|
selectThreadParam,
|
||||||
selectTopicFromMessage,
|
selectTopicFromMessage,
|
||||||
@ -452,10 +453,11 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
const lastMessage = previewMessageId
|
const lastMessage = previewMessageId
|
||||||
? selectChatMessage(global, chatId, previewMessageId)
|
? selectChatMessage(global, chatId, previewMessageId)
|
||||||
: selectChatLastMessage(global, chatId, isSavedDialog ? 'saved' : 'all');
|
: selectChatLastMessage(global, chatId, isSavedDialog ? 'saved' : 'all');
|
||||||
const { senderId, isOutgoing, forwardInfo } = lastMessage || {};
|
const { isOutgoing, forwardInfo } = lastMessage || {};
|
||||||
const actualSenderId = isSavedDialog ? forwardInfo?.fromId : senderId;
|
const savedDialogSender = isSavedDialog && forwardInfo?.fromId ? selectPeer(global, forwardInfo.fromId) : undefined;
|
||||||
|
const messageSender = lastMessage ? selectSender(global, lastMessage) : undefined;
|
||||||
|
const lastMessageSender = savedDialogSender || messageSender;
|
||||||
const replyToMessageId = lastMessage && getMessageReplyInfo(lastMessage)?.replyToMsgId;
|
const replyToMessageId = lastMessage && getMessageReplyInfo(lastMessage)?.replyToMsgId;
|
||||||
const lastMessageSender = actualSenderId ? selectPeer(global, actualSenderId) : undefined;
|
|
||||||
const lastMessageAction = lastMessage ? getMessageAction(lastMessage) : undefined;
|
const lastMessageAction = lastMessage ? getMessageAction(lastMessage) : undefined;
|
||||||
const actionTargetMessage = lastMessageAction && replyToMessageId
|
const actionTargetMessage = lastMessageAction && replyToMessageId
|
||||||
? selectChatMessage(global, chat.id, replyToMessageId)
|
? selectChatMessage(global, chat.id, replyToMessageId)
|
||||||
|
|||||||
@ -20,10 +20,10 @@ import {
|
|||||||
selectDraft,
|
selectDraft,
|
||||||
selectOutgoingStatus,
|
selectOutgoingStatus,
|
||||||
selectPeerStory,
|
selectPeerStory,
|
||||||
|
selectSender,
|
||||||
selectThreadInfo,
|
selectThreadInfo,
|
||||||
selectThreadParam,
|
selectThreadParam,
|
||||||
selectTopics,
|
selectTopics,
|
||||||
selectUser,
|
|
||||||
} from '../../../global/selectors';
|
} from '../../../global/selectors';
|
||||||
import buildClassName from '../../../util/buildClassName';
|
import buildClassName from '../../../util/buildClassName';
|
||||||
import { createLocationHash } from '../../../util/routing';
|
import { createLocationHash } from '../../../util/routing';
|
||||||
@ -248,10 +248,9 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
const chat = selectChat(global, chatId);
|
const chat = selectChat(global, chatId);
|
||||||
|
|
||||||
const lastMessage = selectChatMessage(global, chatId, topic.lastMessageId);
|
const lastMessage = selectChatMessage(global, chatId, topic.lastMessageId);
|
||||||
const { senderId, isOutgoing } = lastMessage || {};
|
const { isOutgoing } = lastMessage || {};
|
||||||
const replyToMessageId = lastMessage && getMessageReplyInfo(lastMessage)?.replyToMsgId;
|
const replyToMessageId = lastMessage && getMessageReplyInfo(lastMessage)?.replyToMsgId;
|
||||||
const lastMessageSender = senderId
|
const lastMessageSender = lastMessage && selectSender(global, lastMessage);
|
||||||
? (selectUser(global, senderId) || selectChat(global, senderId)) : undefined;
|
|
||||||
const lastMessageAction = lastMessage ? getMessageAction(lastMessage) : undefined;
|
const lastMessageAction = lastMessage ? getMessageAction(lastMessage) : undefined;
|
||||||
const actionTargetMessage = lastMessageAction && replyToMessageId
|
const actionTargetMessage = lastMessageAction && replyToMessageId
|
||||||
? selectChatMessage(global, chatId, replyToMessageId)
|
? selectChatMessage(global, chatId, replyToMessageId)
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import {
|
|||||||
getMessageVideo,
|
getMessageVideo,
|
||||||
isActionMessage,
|
isActionMessage,
|
||||||
isChatChannel,
|
isChatChannel,
|
||||||
|
isChatGroup,
|
||||||
isExpiredMessage,
|
isExpiredMessage,
|
||||||
} from '../../../../global/helpers';
|
} from '../../../../global/helpers';
|
||||||
import { getMessageReplyInfo } from '../../../../global/helpers/replies';
|
import { getMessageReplyInfo } from '../../../../global/helpers/replies';
|
||||||
@ -154,7 +155,7 @@ export default function useChatListEntry({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isAction) {
|
if (isAction) {
|
||||||
const isChat = chat && (isChatChannel(chat) || lastMessage.senderId === lastMessage.chatId);
|
const isChat = chat && (isChatChannel(chat) || isChatGroup(chat));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<p className="last-message shared-canvas-container" dir={oldLang.isRtl ? 'auto' : 'ltr'}>
|
<p className="last-message shared-canvas-container" dir={oldLang.isRtl ? 'auto' : 'ltr'}>
|
||||||
|
|||||||
@ -127,6 +127,7 @@ const ActionMessage: FC<OwnProps & StateProps> = ({
|
|||||||
getReceipt,
|
getReceipt,
|
||||||
openGiftInfoModalFromMessage,
|
openGiftInfoModalFromMessage,
|
||||||
openPrizeStarsTransactionFromGiveaway,
|
openPrizeStarsTransactionFromGiveaway,
|
||||||
|
showNotification,
|
||||||
} = getActions();
|
} = getActions();
|
||||||
|
|
||||||
const oldLang = useOldLang();
|
const oldLang = useOldLang();
|
||||||
@ -234,6 +235,19 @@ const ActionMessage: FC<OwnProps & StateProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleStarGiftClick = () => {
|
const handleStarGiftClick = () => {
|
||||||
|
const starGift = message.content.action?.starGift;
|
||||||
|
if (!starGift) return;
|
||||||
|
if (starGift.type === 'starGift' && starGift.canUpgrade && !message.isOutgoing) {
|
||||||
|
showNotification({
|
||||||
|
title: {
|
||||||
|
key: 'ActionUnsupportedTitle',
|
||||||
|
},
|
||||||
|
message: {
|
||||||
|
key: 'ActionUnsupportedDescription',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
openGiftInfoModalFromMessage({
|
openGiftInfoModalFromMessage({
|
||||||
chatId: message.chatId,
|
chatId: message.chatId,
|
||||||
messageId: message.id,
|
messageId: message.id,
|
||||||
@ -402,9 +416,10 @@ const ActionMessage: FC<OwnProps & StateProps> = ({
|
|||||||
|
|
||||||
function renderStarGiftUserCaption() {
|
function renderStarGiftUserCaption() {
|
||||||
const targetUser = targetUsers && targetUsers[0];
|
const targetUser = targetUsers && targetUsers[0];
|
||||||
if (!targetUser || !senderUser) return undefined;
|
const starGift = message.content.action?.starGift;
|
||||||
|
if (!targetUser || !senderUser || !starGift) return undefined;
|
||||||
|
|
||||||
if (message.isOutgoing) {
|
if (message.isOutgoing || (starGift.type === 'starGiftUnique' && starGift.isUpgrade)) {
|
||||||
return (
|
return (
|
||||||
<div className="action-message-user-caption">
|
<div className="action-message-user-caption">
|
||||||
<span> {lang('GiftTo')} </span>
|
<span> {lang('GiftTo')} </span>
|
||||||
@ -432,45 +447,65 @@ const ActionMessage: FC<OwnProps & StateProps> = ({
|
|||||||
if (starGiftMessage) {
|
if (starGiftMessage) {
|
||||||
return renderTextWithEntities({ text: starGiftMessage.text, entities: starGiftMessage.entities });
|
return renderTextWithEntities({ text: starGiftMessage.text, entities: starGiftMessage.entities });
|
||||||
}
|
}
|
||||||
const amount = starGift?.starsToConvert;
|
const amountToConvert = starGift?.starsToConvert;
|
||||||
|
|
||||||
if (message.isOutgoing) {
|
if (message.isOutgoing) {
|
||||||
return lang('ActionStarGiftOutDescription', {
|
if (amountToConvert) {
|
||||||
user: targetUser || 'User',
|
return lang('ActionStarGiftOutDescription', {
|
||||||
count: amount,
|
user: targetUser || 'User',
|
||||||
}, { withNodes: true });
|
count: amountToConvert,
|
||||||
|
}, { withNodes: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (starGift.canUpgrade) {
|
||||||
|
return lang('ActionStarGiftOutDescriptionUpgrade', {
|
||||||
|
user: targetUser || 'User',
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (starGift.isSaved) {
|
if (starGift.isSaved) {
|
||||||
return lang('ActionStarGiftDisplaying');
|
return lang('ActionStarGiftDisplaying');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (starGift.isUpgraded) {
|
||||||
|
return lang('ActionStarGiftUpgraded');
|
||||||
|
}
|
||||||
|
|
||||||
if (starGift.isConverted) {
|
if (starGift.isConverted) {
|
||||||
return message.isOutgoing
|
return message.isOutgoing
|
||||||
? lang('GiftInfoDescriptionOutConverted', {
|
? lang('GiftInfoDescriptionOutConverted', {
|
||||||
amount: formatInteger(amount!),
|
amount: formatInteger(amountToConvert!),
|
||||||
user: targetUser || 'User',
|
user: targetUser || 'User',
|
||||||
}, {
|
}, {
|
||||||
pluralValue: amount!,
|
pluralValue: amountToConvert!,
|
||||||
withNodes: true,
|
withNodes: true,
|
||||||
withMarkdown: true,
|
withMarkdown: true,
|
||||||
})
|
})
|
||||||
: lang('GiftInfoDescriptionConverted', {
|
: lang('GiftInfoDescriptionConverted', {
|
||||||
amount: formatInteger(amount!),
|
amount: formatInteger(amountToConvert!),
|
||||||
}, {
|
}, {
|
||||||
pluralValue: amount!,
|
pluralValue: amountToConvert!,
|
||||||
withNodes: true,
|
withNodes: true,
|
||||||
withMarkdown: true,
|
withMarkdown: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return lang('ActionStarGiftDescription', {
|
if (amountToConvert) {
|
||||||
count: amount,
|
return lang('ActionStarGiftDescription', {
|
||||||
}, { withNodes: true });
|
count: amountToConvert,
|
||||||
|
}, { withNodes: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (starGift.canUpgrade) {
|
||||||
|
return lang('ActionStarGiftDescriptionUpgrade');
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderStarGift() {
|
function renderStarGift() {
|
||||||
const starGift = message.content.action?.starGift;
|
const starGift = message.content.action?.starGift as ApiMessageActionStarGift;
|
||||||
if (!starGift || starGift.gift.type !== 'starGift') return undefined;
|
if (!starGift || starGift.gift.type !== 'starGift') return undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -494,12 +529,10 @@ const ActionMessage: FC<OwnProps & StateProps> = ({
|
|||||||
{renderStarGiftUserDescription()}
|
{renderStarGiftUserDescription()}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!message.isOutgoing && (
|
<div className="action-message-button">
|
||||||
<div className="action-message-button">
|
<Sparkles preset="button" />
|
||||||
<Sparkles preset="button" />
|
{starGift.canUpgrade && !message.isOutgoing ? lang('ActionStarGiftUnpack') : oldLang('ActionGiftPremiumView')}
|
||||||
{oldLang('ActionGiftPremiumView')}
|
</div>
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{starGift.gift.availabilityTotal && (
|
{starGift.gift.availabilityTotal && (
|
||||||
<GiftRibbon
|
<GiftRibbon
|
||||||
color={patternColor || 'blue'}
|
color={patternColor || 'blue'}
|
||||||
|
|||||||
@ -113,13 +113,13 @@ function GiftComposer({
|
|||||||
currency: STARS_CURRENCY_CODE,
|
currency: STARS_CURRENCY_CODE,
|
||||||
amount: gift.stars,
|
amount: gift.stars,
|
||||||
starGift: {
|
starGift: {
|
||||||
|
type: 'starGift',
|
||||||
message: giftMessage?.length ? {
|
message: giftMessage?.length ? {
|
||||||
text: giftMessage,
|
text: giftMessage,
|
||||||
} : undefined,
|
} : undefined,
|
||||||
isNameHidden: shouldHideName,
|
isNameHidden: shouldHideName,
|
||||||
starsToConvert: gift.starsToConvert,
|
starsToConvert: gift.starsToConvert,
|
||||||
isSaved: false,
|
isSaved: false,
|
||||||
isConverted: false,
|
|
||||||
gift,
|
gift,
|
||||||
},
|
},
|
||||||
translationValues: ['%action_origin%', '%gift_payment_amount%'],
|
translationValues: ['%action_origin%', '%gift_payment_amount%'],
|
||||||
|
|||||||
@ -47,6 +47,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.125rem;
|
gap: 0.125rem;
|
||||||
|
line-height: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.radialPattern {
|
.radialPattern {
|
||||||
|
|||||||
@ -58,6 +58,7 @@ const GiftInfoModal = ({
|
|||||||
changeGiftVisilibity,
|
changeGiftVisilibity,
|
||||||
convertGiftToStars,
|
convertGiftToStars,
|
||||||
openChatWithInfo,
|
openChatWithInfo,
|
||||||
|
focusMessage,
|
||||||
} = getActions();
|
} = getActions();
|
||||||
|
|
||||||
const [isConvertConfirmOpen, openConvertConfirm, closeConvertConfirm] = useFlag();
|
const [isConvertConfirmOpen, openConvertConfirm, closeConvertConfirm] = useFlag();
|
||||||
@ -70,7 +71,6 @@ const GiftInfoModal = ({
|
|||||||
const { gift: typeGift } = renderingModal || {};
|
const { gift: typeGift } = renderingModal || {};
|
||||||
const isUserGift = typeGift && 'gift' in typeGift;
|
const isUserGift = typeGift && 'gift' in typeGift;
|
||||||
const userGift = isUserGift ? typeGift : undefined;
|
const userGift = isUserGift ? typeGift : undefined;
|
||||||
const canUpdate = Boolean(userGift?.messageId);
|
|
||||||
const isSender = userGift?.fromId === currentUserId;
|
const isSender = userGift?.fromId === currentUserId;
|
||||||
const canConvertDifference = (userGift && starGiftMaxConvertPeriod && (
|
const canConvertDifference = (userGift && starGiftMaxConvertPeriod && (
|
||||||
userGift.date + starGiftMaxConvertPeriod - getServerTime()
|
userGift.date + starGiftMaxConvertPeriod - getServerTime()
|
||||||
@ -80,10 +80,21 @@ const GiftInfoModal = ({
|
|||||||
const gift = isUserGift ? typeGift.gift : typeGift;
|
const gift = isUserGift ? typeGift.gift : typeGift;
|
||||||
const giftSticker = gift && getStickerFromGift(gift);
|
const giftSticker = gift && getStickerFromGift(gift);
|
||||||
|
|
||||||
|
const canFocusUpgrade = Boolean(userGift?.upgradeMsgId);
|
||||||
|
const canUpdate = gift?.type === 'starGiftUnique'
|
||||||
|
? gift.ownerId === currentUserId : Boolean(userGift?.messageId) && !isSender && !canFocusUpgrade;
|
||||||
|
|
||||||
const handleClose = useLastCallback(() => {
|
const handleClose = useLastCallback(() => {
|
||||||
closeGiftInfoModal();
|
closeGiftInfoModal();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const handleFocusUpgraded = useLastCallback(() => {
|
||||||
|
if (!userGift?.upgradeMsgId) return;
|
||||||
|
const { upgradeMsgId, fromId } = userGift;
|
||||||
|
focusMessage({ chatId: fromId!, messageId: upgradeMsgId! });
|
||||||
|
handleClose();
|
||||||
|
});
|
||||||
|
|
||||||
const handleTriggerVisibility = useLastCallback(() => {
|
const handleTriggerVisibility = useLastCallback(() => {
|
||||||
const { fromId, messageId, isUnsaved } = userGift!;
|
const { fromId, messageId, isUnsaved } = userGift!;
|
||||||
changeGiftVisilibity({ userId: fromId!, messageId: messageId!, shouldUnsave: !isUnsaved });
|
changeGiftVisilibity({ userId: fromId!, messageId: messageId!, shouldUnsave: !isUnsaved });
|
||||||
@ -201,7 +212,7 @@ const GiftInfoModal = ({
|
|||||||
<AnimatedIconFromSticker
|
<AnimatedIconFromSticker
|
||||||
className={styles.giftSticker}
|
className={styles.giftSticker}
|
||||||
sticker={giftSticker}
|
sticker={giftSticker}
|
||||||
noLoop
|
noLoop={false}
|
||||||
nonInteractive
|
nonInteractive
|
||||||
size={STICKER_SIZE}
|
size={STICKER_SIZE}
|
||||||
/>
|
/>
|
||||||
@ -429,7 +440,12 @@ const GiftInfoModal = ({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{!canUpdate && (
|
{canFocusUpgrade && (
|
||||||
|
<Button size="smaller" onClick={handleFocusUpgraded}>
|
||||||
|
{lang('GiftInfoViewUpgraded')}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
{!canUpdate && !canFocusUpgrade && (
|
||||||
<Button size="smaller" onClick={handleClose}>
|
<Button size="smaller" onClick={handleClose}>
|
||||||
{lang('OK')}
|
{lang('OK')}
|
||||||
</Button>
|
</Button>
|
||||||
@ -449,7 +465,7 @@ const GiftInfoModal = ({
|
|||||||
};
|
};
|
||||||
}, [
|
}, [
|
||||||
typeGift, userGift, targetUser, giftSticker, lang, canUpdate, canConvertDifference, isSender, oldLang, gift,
|
typeGift, userGift, targetUser, giftSticker, lang, canUpdate, canConvertDifference, isSender, oldLang, gift,
|
||||||
radialPatternBackdrop, giftAttributes,
|
radialPatternBackdrop, giftAttributes, canFocusUpgrade,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -263,6 +263,7 @@ addActionHandler('openGiftInfoModalFromMessage', (global, actions, payload): Act
|
|||||||
fromId: message.isOutgoing ? global.currentUserId : message.chatId,
|
fromId: message.isOutgoing ? global.currentUserId : message.chatId,
|
||||||
messageId: (!message.isOutgoing || chatId === global.currentUserId) ? message.id : undefined,
|
messageId: (!message.isOutgoing || chatId === global.currentUserId) ? message.id : undefined,
|
||||||
isConverted: starGift.isConverted,
|
isConverted: starGift.isConverted,
|
||||||
|
upgradeMsgId: starGift.upgradeMsgId,
|
||||||
} satisfies ApiUserStarGift;
|
} satisfies ApiUserStarGift;
|
||||||
|
|
||||||
actions.openGiftInfoModal({ userId: giftReceiverId, gift, tabId });
|
actions.openGiftInfoModal({ userId: giftReceiverId, gift, tabId });
|
||||||
|
|||||||
15
src/types/language.d.ts
vendored
15
src/types/language.d.ts
vendored
@ -1138,6 +1138,7 @@ export interface LangPair {
|
|||||||
'GiftAttributeSymbol': undefined;
|
'GiftAttributeSymbol': undefined;
|
||||||
'GiftInfoStatus': undefined;
|
'GiftInfoStatus': undefined;
|
||||||
'GiftInfoStatusNonUnique': undefined;
|
'GiftInfoStatusNonUnique': undefined;
|
||||||
|
'GiftInfoViewUpgraded': undefined;
|
||||||
'AllGiftsCategory': undefined;
|
'AllGiftsCategory': undefined;
|
||||||
'LimitedGiftsCategory': undefined;
|
'LimitedGiftsCategory': undefined;
|
||||||
'StockGiftsCategory': undefined;
|
'StockGiftsCategory': undefined;
|
||||||
@ -1145,6 +1146,9 @@ export interface LangPair {
|
|||||||
'StarsReactionLinkText': undefined;
|
'StarsReactionLinkText': undefined;
|
||||||
'StarsReactionLink': undefined;
|
'StarsReactionLink': undefined;
|
||||||
'ActionStarGiftDisplaying': undefined;
|
'ActionStarGiftDisplaying': undefined;
|
||||||
|
'ActionStarGiftDescriptionUpgrade': undefined;
|
||||||
|
'ActionStarGiftUpgraded': undefined;
|
||||||
|
'ActionStarGiftUnpack': undefined;
|
||||||
'GiftTo': undefined;
|
'GiftTo': undefined;
|
||||||
'GiftFrom': undefined;
|
'GiftFrom': undefined;
|
||||||
'ReceivedGift': undefined;
|
'ReceivedGift': undefined;
|
||||||
@ -1212,6 +1216,8 @@ export interface LangPair {
|
|||||||
'ProfileTabVoice': undefined;
|
'ProfileTabVoice': undefined;
|
||||||
'ProfileTabSharedGroups': undefined;
|
'ProfileTabSharedGroups': undefined;
|
||||||
'ProfileTabSimilarChannels': undefined;
|
'ProfileTabSimilarChannels': undefined;
|
||||||
|
'ActionUnsupportedTitle': undefined;
|
||||||
|
'ActionUnsupportedDescription': undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LangPairWithVariables<V extends unknown = LangVariable> {
|
export interface LangPairWithVariables<V extends unknown = LangVariable> {
|
||||||
@ -1612,6 +1618,9 @@ export interface LangPairWithVariables<V extends unknown = LangVariable> {
|
|||||||
'ActionStarGiftDescription': {
|
'ActionStarGiftDescription': {
|
||||||
'count': V;
|
'count': V;
|
||||||
};
|
};
|
||||||
|
'ActionStarGiftOutDescriptionUpgrade': {
|
||||||
|
'user': V;
|
||||||
|
};
|
||||||
'StarGiftInfoDescriptionInbound': {
|
'StarGiftInfoDescriptionInbound': {
|
||||||
'count': V;
|
'count': V;
|
||||||
'link': V;
|
'link': V;
|
||||||
@ -1634,9 +1643,6 @@ export interface LangPairWithVariables<V extends unknown = LangVariable> {
|
|||||||
'EmojiStatusAccessText': {
|
'EmojiStatusAccessText': {
|
||||||
'name': V;
|
'name': V;
|
||||||
};
|
};
|
||||||
'LocationPermissionText': {
|
|
||||||
'name': V;
|
|
||||||
};
|
|
||||||
'BotSuggestedStatusFor': {
|
'BotSuggestedStatusFor': {
|
||||||
'bot': V;
|
'bot': V;
|
||||||
'duration': V;
|
'duration': V;
|
||||||
@ -1671,6 +1677,9 @@ export interface LangPairWithVariables<V extends unknown = LangVariable> {
|
|||||||
'FolderLinkNotificationUpdatedTitle': {
|
'FolderLinkNotificationUpdatedTitle': {
|
||||||
'title': V;
|
'title': V;
|
||||||
};
|
};
|
||||||
|
'LocationPermissionText': {
|
||||||
|
'name': V;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LangPairPlural {
|
export interface LangPairPlural {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user