Gifts: Small fixes (#5671)
This commit is contained in:
parent
10f5e628f4
commit
e54989c791
@ -1378,10 +1378,13 @@
|
|||||||
"GiftInfoTitle" = "Gift";
|
"GiftInfoTitle" = "Gift";
|
||||||
"GiftInfoDescription_one" = "You can keep this gift in your Profile or convert it to **{amount}** Star.";
|
"GiftInfoDescription_one" = "You can keep this gift in your Profile or convert it to **{amount}** Star.";
|
||||||
"GiftInfoDescription_other" = "You can keep this gift in your Profile or convert it to **{amount}** Stars.";
|
"GiftInfoDescription_other" = "You can keep this gift in your Profile or convert it to **{amount}** Stars.";
|
||||||
|
"GiftInfoDescriptionRegular" = "You can add this gift to your profile or hide it";
|
||||||
"GiftInfoPeerDescriptionOut_one" = "{peer} can keep this gift in profile or convert it to **{amount}** Star.";
|
"GiftInfoPeerDescriptionOut_one" = "{peer} can keep this gift in profile or convert it to **{amount}** Star.";
|
||||||
"GiftInfoPeerDescriptionOut_other" = "{peer} can keep this gift in profile or convert it to **{amount}** Stars.";
|
"GiftInfoPeerDescriptionOut_other" = "{peer} can keep this gift in profile or convert it to **{amount}** Stars.";
|
||||||
|
"GiftInfoPeerDescriptionOutRegular" = "{peer} can add this gift to their profile or hide it";
|
||||||
"GiftInfoDescriptionUpgrade_one" = "You can keep this gift, upgrade it, or sell it for **{amount}** Star.";
|
"GiftInfoDescriptionUpgrade_one" = "You can keep this gift, upgrade it, or sell it for **{amount}** Star.";
|
||||||
"GiftInfoDescriptionUpgrade_other" = "You can keep this gift, upgrade it, or sell it for **{amount}** Stars.";
|
"GiftInfoDescriptionUpgrade_other" = "You can keep this gift, upgrade it, or sell it for **{amount}** Stars.";
|
||||||
|
"GiftInfoDescriptionUpgradeRegular" = "You can add this gift to your profile or turn it into a unique transferable collectible.";
|
||||||
"GiftInfoDescriptionConverted_one" = "You converted this gift to **{amount}** Star.";
|
"GiftInfoDescriptionConverted_one" = "You converted this gift to **{amount}** Star.";
|
||||||
"GiftInfoDescriptionConverted_other" = "You converted this gift to **{amount}** Stars.";
|
"GiftInfoDescriptionConverted_other" = "You converted this gift to **{amount}** Stars.";
|
||||||
"GiftInfoPeerDescriptionOutConverted_one" = "{peer} converted this gift to **{amount}** Star.";
|
"GiftInfoPeerDescriptionOutConverted_one" = "{peer} converted this gift to **{amount}** Star.";
|
||||||
|
|||||||
@ -19,6 +19,7 @@ type OwnProps = {
|
|||||||
className?: string;
|
className?: string;
|
||||||
children?: TeactNode;
|
children?: TeactNode;
|
||||||
isRtl?: boolean;
|
isRtl?: boolean;
|
||||||
|
shouldSkipModal?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const SafeLink = ({
|
const SafeLink = ({
|
||||||
@ -27,6 +28,7 @@ const SafeLink = ({
|
|||||||
className,
|
className,
|
||||||
children,
|
children,
|
||||||
isRtl,
|
isRtl,
|
||||||
|
shouldSkipModal,
|
||||||
}: OwnProps) => {
|
}: OwnProps) => {
|
||||||
const { openUrl } = getActions();
|
const { openUrl } = getActions();
|
||||||
|
|
||||||
@ -37,7 +39,7 @@ const SafeLink = ({
|
|||||||
if (!url) return true;
|
if (!url) return true;
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
openUrl({ url, shouldSkipModal: isRegularLink });
|
openUrl({ url, shouldSkipModal: shouldSkipModal || isRegularLink });
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -59,7 +59,7 @@ const SavedGift = ({
|
|||||||
if (entry.isIntersecting) play();
|
if (entry.isIntersecting) play();
|
||||||
});
|
});
|
||||||
|
|
||||||
const avatarPeer = (gift.isNameHidden || !fromPeer) ? CUSTOM_PEER_HIDDEN : fromPeer;
|
const avatarPeer = (gift.isNameHidden && !fromPeer) ? CUSTOM_PEER_HIDDEN : fromPeer;
|
||||||
|
|
||||||
const sticker = getStickerFromGift(gift.gift);
|
const sticker = getStickerFromGift(gift.gift);
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
:global(.star-amount-icon) {
|
:global(.star-amount-icon) {
|
||||||
vertical-align: text-bottom;
|
vertical-align: text-bottom;
|
||||||
margin-inline: 0;
|
margin-inline: 0 !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ import {
|
|||||||
getPinnedMediaValue,
|
getPinnedMediaValue,
|
||||||
renderMessageLink,
|
renderMessageLink,
|
||||||
renderPeerLink,
|
renderPeerLink,
|
||||||
translateWithOutgoing,
|
translateWithYou,
|
||||||
} from './helpers/messageActions';
|
} from './helpers/messageActions';
|
||||||
|
|
||||||
import useLang from '../../../hooks/useLang';
|
import useLang from '../../../hooks/useLang';
|
||||||
@ -114,7 +114,7 @@ const ActionMessageText = ({
|
|||||||
asPreview,
|
asPreview,
|
||||||
);
|
);
|
||||||
|
|
||||||
return translateWithOutgoing(
|
return translateWithYou(
|
||||||
lang, 'ActionPinnedText', isOutgoing, { text: textLink, from: senderLink },
|
lang, 'ActionPinnedText', isOutgoing, { text: textLink, from: senderLink },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -122,13 +122,13 @@ const ActionMessageText = ({
|
|||||||
const mediaValue = getPinnedMediaValue(lang, replyMessage);
|
const mediaValue = getPinnedMediaValue(lang, replyMessage);
|
||||||
if (mediaValue) {
|
if (mediaValue) {
|
||||||
const messageLink = renderMessageLink(replyMessage, mediaValue, asPreview);
|
const messageLink = renderMessageLink(replyMessage, mediaValue, asPreview);
|
||||||
return translateWithOutgoing(
|
return translateWithYou(
|
||||||
lang, 'ActionPinnedMedia', isOutgoing, { from: senderLink, media: messageLink },
|
lang, 'ActionPinnedMedia', isOutgoing, { from: senderLink, media: messageLink },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return translateWithOutgoing(
|
return translateWithYou(
|
||||||
lang,
|
lang,
|
||||||
'ActionPinnedNotFound',
|
'ActionPinnedNotFound',
|
||||||
isOutgoing,
|
isOutgoing,
|
||||||
@ -143,7 +143,7 @@ const ActionMessageText = ({
|
|||||||
const gameLink = gameTitle && renderMessageLink(replyMessage, renderText(gameTitle), asPreview);
|
const gameLink = gameTitle && renderMessageLink(replyMessage, renderText(gameTitle), asPreview);
|
||||||
|
|
||||||
if (gameLink) {
|
if (gameLink) {
|
||||||
return translateWithOutgoing(
|
return translateWithYou(
|
||||||
lang,
|
lang,
|
||||||
'ActionGameScore',
|
'ActionGameScore',
|
||||||
isOutgoing,
|
isOutgoing,
|
||||||
@ -152,7 +152,7 @@ const ActionMessageText = ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return translateWithOutgoing(
|
return translateWithYou(
|
||||||
lang, 'ActionGameScoreNoGame', isOutgoing, { from: senderLink, count: score }, { pluralValue: score },
|
lang, 'ActionGameScoreNoGame', isOutgoing, { from: senderLink, count: score }, { pluralValue: score },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -161,7 +161,7 @@ const ActionMessageText = ({
|
|||||||
return lang('ActionUserJoinedByLink', { from: senderLink }, { withNodes: true });
|
return lang('ActionUserJoinedByLink', { from: senderLink }, { withNodes: true });
|
||||||
|
|
||||||
case 'chatJoinedByRequest':
|
case 'chatJoinedByRequest':
|
||||||
return translateWithOutgoing(lang, 'ActionJoinedByRequest', isOutgoing, { from: senderLink });
|
return translateWithYou(lang, 'ActionJoinedByRequest', isOutgoing, { from: senderLink });
|
||||||
|
|
||||||
case 'channelJoined': {
|
case 'channelJoined': {
|
||||||
const { isViaRequest, inviterId } = action;
|
const { isViaRequest, inviterId } = action;
|
||||||
@ -177,16 +177,16 @@ const ActionMessageText = ({
|
|||||||
case 'chatEditTitle': {
|
case 'chatEditTitle': {
|
||||||
const { title } = action;
|
const { title } = action;
|
||||||
if (isChannel) return lang('ActionChangedTitleChannel', { title });
|
if (isChannel) return lang('ActionChangedTitleChannel', { title });
|
||||||
return translateWithOutgoing(lang, 'ActionChangedTitle', isOutgoing, { title, from: senderLink });
|
return translateWithYou(lang, 'ActionChangedTitle', isOutgoing, { title, from: senderLink });
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'chatDeletePhoto':
|
case 'chatDeletePhoto':
|
||||||
return isChannel ? lang('ActionRemovedPhotoChannel')
|
return isChannel ? lang('ActionRemovedPhotoChannel')
|
||||||
: translateWithOutgoing(lang, 'ActionRemovedPhoto', isOutgoing, { from: senderLink });
|
: translateWithYou(lang, 'ActionRemovedPhoto', isOutgoing, { from: senderLink });
|
||||||
|
|
||||||
case 'chatEditPhoto':
|
case 'chatEditPhoto':
|
||||||
return isChannel ? lang('ActionChangedPhotoChannel')
|
return isChannel ? lang('ActionChangedPhotoChannel')
|
||||||
: translateWithOutgoing(lang, 'ActionChangedPhoto', isOutgoing, { from: senderLink });
|
: translateWithYou(lang, 'ActionChangedPhoto', isOutgoing, { from: senderLink });
|
||||||
|
|
||||||
case 'chatCreate': {
|
case 'chatCreate': {
|
||||||
const { title } = action;
|
const { title } = action;
|
||||||
@ -196,7 +196,7 @@ const ActionMessageText = ({
|
|||||||
case 'channelCreate': {
|
case 'channelCreate': {
|
||||||
const { title } = action;
|
const { title } = action;
|
||||||
return isChannel ? lang('ActionCreatedChannel')
|
return isChannel ? lang('ActionCreatedChannel')
|
||||||
: translateWithOutgoing(lang, 'ActionCreatedChat', isOutgoing, { title, from: senderLink });
|
: translateWithYou(lang, 'ActionCreatedChat', isOutgoing, { title, from: senderLink });
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'chatMigrateTo': {
|
case 'chatMigrateTo': {
|
||||||
@ -325,7 +325,7 @@ const ActionMessageText = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'boostApply':
|
case 'boostApply':
|
||||||
return translateWithOutgoing(
|
return translateWithYou(
|
||||||
lang,
|
lang,
|
||||||
'ActionBoostApply',
|
'ActionBoostApply',
|
||||||
isOutgoing,
|
isOutgoing,
|
||||||
@ -337,27 +337,27 @@ const ActionMessageText = ({
|
|||||||
const { userIds } = action;
|
const { userIds } = action;
|
||||||
|
|
||||||
if (sender?.id === userIds[0]) {
|
if (sender?.id === userIds[0]) {
|
||||||
return translateWithOutgoing(lang, 'ActionUserJoined', isOutgoing, { from: senderLink });
|
return translateWithYou(lang, 'ActionUserJoined', isOutgoing, { from: senderLink });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userIds.length === 1) {
|
if (userIds.length === 1) {
|
||||||
const user = selectPeer(global, userIds[0]);
|
const user = selectPeer(global, userIds[0]);
|
||||||
const userTitle = (user && getPeerTitle(lang, user)) || userFallbackText;
|
const userTitle = (user && getPeerTitle(lang, user)) || userFallbackText;
|
||||||
const userLink = renderPeerLink(user?.id, userTitle, asPreview);
|
const userLink = renderPeerLink(user?.id, userTitle, asPreview);
|
||||||
return translateWithOutgoing(lang, 'ActionAddUser', isOutgoing, { from: senderLink, user: userLink });
|
return translateWithYou(lang, 'ActionAddUser', isOutgoing, { from: senderLink, user: userLink });
|
||||||
}
|
}
|
||||||
|
|
||||||
const users = userIds.map((userId) => selectPeer(global, userId)).filter(Boolean);
|
const users = userIds.map((userId) => selectPeer(global, userId)).filter(Boolean);
|
||||||
|
|
||||||
if (!users.length) {
|
if (!users.length) {
|
||||||
return translateWithOutgoing(lang, 'ActionAddUser', isOutgoing, { from: senderLink, user: userFallbackText });
|
return translateWithYou(lang, 'ActionAddUser', isOutgoing, { from: senderLink, user: userFallbackText });
|
||||||
}
|
}
|
||||||
|
|
||||||
const userLinks = users.map((user) => (
|
const userLinks = users.map((user) => (
|
||||||
renderPeerLink(user.id, getPeerTitle(lang, user) || userFallbackText, asPreview)
|
renderPeerLink(user.id, getPeerTitle(lang, user) || userFallbackText, asPreview)
|
||||||
));
|
));
|
||||||
|
|
||||||
return translateWithOutgoing(
|
return translateWithYou(
|
||||||
lang, 'ActionAddUsersMany', isOutgoing, { from: senderLink, users: conjuctionWithNodes(lang, userLinks) },
|
lang, 'ActionAddUsersMany', isOutgoing, { from: senderLink, users: conjuctionWithNodes(lang, userLinks) },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -365,13 +365,13 @@ const ActionMessageText = ({
|
|||||||
case 'chatDeleteUser': {
|
case 'chatDeleteUser': {
|
||||||
const { userId } = action;
|
const { userId } = action;
|
||||||
if (sender?.id === userId) {
|
if (sender?.id === userId) {
|
||||||
return translateWithOutgoing(lang, 'ActionUserLeft', isOutgoing, { from: senderLink });
|
return translateWithYou(lang, 'ActionUserLeft', isOutgoing, { from: senderLink });
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = selectPeer(global, userId);
|
const user = selectPeer(global, userId);
|
||||||
const userTitle = (user && getPeerTitle(lang, user)) || userFallbackText;
|
const userTitle = (user && getPeerTitle(lang, user)) || userFallbackText;
|
||||||
const userLink = renderPeerLink(user?.id, userTitle, asPreview);
|
const userLink = renderPeerLink(user?.id, userTitle, asPreview);
|
||||||
return translateWithOutgoing(lang, 'ActionKickUser', isOutgoing, { from: senderLink, user: userLink });
|
return translateWithYou(lang, 'ActionKickUser', isOutgoing, { from: senderLink, user: userLink });
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'botAllowed': {
|
case 'botAllowed': {
|
||||||
@ -444,7 +444,7 @@ const ActionMessageText = ({
|
|||||||
if (isServiceNotificationsChat) {
|
if (isServiceNotificationsChat) {
|
||||||
return lang('ActionGiftTextCostAnonymous', { cost }, { withNodes: true });
|
return lang('ActionGiftTextCostAnonymous', { cost }, { withNodes: true });
|
||||||
}
|
}
|
||||||
return translateWithOutgoing(
|
return translateWithYou(
|
||||||
lang, 'ActionGiftTextCost', isOutgoing, { from: senderLink, cost: renderStrong(cost) },
|
lang, 'ActionGiftTextCost', isOutgoing, { from: senderLink, cost: renderStrong(cost) },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -485,13 +485,13 @@ const ActionMessageText = ({
|
|||||||
const user = selectPeer(global, userIds[0]);
|
const user = selectPeer(global, userIds[0]);
|
||||||
const userTitle = (user && getPeerTitle(lang, user)) || userFallbackText;
|
const userTitle = (user && getPeerTitle(lang, user)) || userFallbackText;
|
||||||
const userLink = renderPeerLink(user?.id, userTitle, asPreview);
|
const userLink = renderPeerLink(user?.id, userTitle, asPreview);
|
||||||
return translateWithOutgoing(lang, 'ActionVideoInvited', isOutgoing, { from: senderLink, user: userLink });
|
return translateWithYou(lang, 'ActionVideoInvited', isOutgoing, { from: senderLink, user: userLink });
|
||||||
}
|
}
|
||||||
|
|
||||||
const users = userIds.map((userId) => selectPeer(global, userId)).filter(Boolean);
|
const users = userIds.map((userId) => selectPeer(global, userId)).filter(Boolean);
|
||||||
|
|
||||||
if (!users.length) {
|
if (!users.length) {
|
||||||
return translateWithOutgoing(
|
return translateWithYou(
|
||||||
lang, 'ActionVideoInvited', isOutgoing, { from: senderLink, user: userFallbackText },
|
lang, 'ActionVideoInvited', isOutgoing, { from: senderLink, user: userFallbackText },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -500,7 +500,7 @@ const ActionMessageText = ({
|
|||||||
renderPeerLink(user.id, getPeerTitle(lang, user) || userFallbackText, asPreview)
|
renderPeerLink(user.id, getPeerTitle(lang, user) || userFallbackText, asPreview)
|
||||||
));
|
));
|
||||||
|
|
||||||
return translateWithOutgoing(
|
return translateWithYou(
|
||||||
lang, 'ActionVideoInvitedMany', isOutgoing, { from: senderLink, users: conjuctionWithNodes(lang, userLinks) },
|
lang, 'ActionVideoInvitedMany', isOutgoing, { from: senderLink, users: conjuctionWithNodes(lang, userLinks) },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -570,7 +570,7 @@ const ActionMessageText = ({
|
|||||||
|
|
||||||
const channelTitle = (channelPeer && getPeerTitle(lang, channelPeer)) || channelFallbackText;
|
const channelTitle = (channelPeer && getPeerTitle(lang, channelPeer)) || channelFallbackText;
|
||||||
const channelLink = renderPeerLink(peerId, channelTitle, asPreview);
|
const channelLink = renderPeerLink(peerId, channelTitle, asPreview);
|
||||||
return translateWithOutgoing(
|
return translateWithYou(
|
||||||
lang, 'ActionStarGiftSentChannel', isYou, { user: fromLink, channel: channelLink, cost },
|
lang, 'ActionStarGiftSentChannel', isYou, { user: fromLink, channel: channelLink, cost },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -610,7 +610,7 @@ const ActionMessageText = ({
|
|||||||
const channelLink = renderPeerLink(peerId, channelTitle, asPreview);
|
const channelLink = renderPeerLink(peerId, channelTitle, asPreview);
|
||||||
|
|
||||||
if (isUpgrade) {
|
if (isUpgrade) {
|
||||||
return translateWithOutgoing(
|
return translateWithYou(
|
||||||
lang, 'ActionStarGiftUpgradedChannel', isYou, { user: fromLink, channel: channelLink },
|
lang, 'ActionStarGiftUpgradedChannel', isYou, { user: fromLink, channel: channelLink },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -620,7 +620,7 @@ const ActionMessageText = ({
|
|||||||
return lang('ActionStarGiftTransferredUnknownChannel', { channel: channelLink }, { withNodes: true });
|
return lang('ActionStarGiftTransferredUnknownChannel', { channel: channelLink }, { withNodes: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
return translateWithOutgoing(
|
return translateWithYou(
|
||||||
lang, 'ActionStarGiftTransferredChannel', isYou, { user: fromLink, channel: channelLink },
|
lang, 'ActionStarGiftTransferredChannel', isYou, { user: fromLink, channel: channelLink },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -670,7 +670,7 @@ const ActionMessageText = ({
|
|||||||
const actionPeer = (isOutgoing ? chat : sender)!;
|
const actionPeer = (isOutgoing ? chat : sender)!;
|
||||||
const actionPeerLink = renderPeerLink(actionPeer.id, getPeerTitle(lang, actionPeer) || userFallbackText);
|
const actionPeerLink = renderPeerLink(actionPeer.id, getPeerTitle(lang, actionPeer) || userFallbackText);
|
||||||
|
|
||||||
return translateWithOutgoing(lang, 'ActionSuggestedPhoto', isOutgoing, { user: actionPeerLink });
|
return translateWithYou(lang, 'ActionSuggestedPhoto', isOutgoing, { user: actionPeerLink });
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'webViewDataSent':
|
case 'webViewDataSent':
|
||||||
@ -688,7 +688,7 @@ const ActionMessageText = ({
|
|||||||
return lang('ActionHistoryCleared');
|
return lang('ActionHistoryCleared');
|
||||||
|
|
||||||
case 'screenshotTaken':
|
case 'screenshotTaken':
|
||||||
return translateWithOutgoing(lang, 'ActionScreenshotTaken', isOutgoing, { from: senderLink });
|
return translateWithYou(lang, 'ActionScreenshotTaken', isOutgoing, { from: senderLink });
|
||||||
|
|
||||||
case 'contactSignUp':
|
case 'contactSignUp':
|
||||||
return lang('ActionUserRegistered', { from: senderLink }, { withNodes: true });
|
return lang('ActionUserRegistered', { from: senderLink }, { withNodes: true });
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import { getServerTime } from '../../../../util/serverTime';
|
|||||||
import { formatIntegerCompact } from '../../../../util/textFormat';
|
import { formatIntegerCompact } from '../../../../util/textFormat';
|
||||||
import { getStickerFromGift } from '../../../common/helpers/gifts';
|
import { getStickerFromGift } from '../../../common/helpers/gifts';
|
||||||
import { renderTextWithEntities } from '../../../common/helpers/renderTextWithEntities';
|
import { renderTextWithEntities } from '../../../common/helpers/renderTextWithEntities';
|
||||||
import { renderPeerLink, translateWithOutgoing } from '../helpers/messageActions';
|
import { renderPeerLink, translateWithYou } from '../helpers/messageActions';
|
||||||
|
|
||||||
import useDynamicColorListener from '../../../../hooks/stickers/useDynamicColorListener';
|
import useDynamicColorListener from '../../../../hooks/stickers/useDynamicColorListener';
|
||||||
import { type ObserveFn } from '../../../../hooks/useIntersectionObserver';
|
import { type ObserveFn } from '../../../../hooks/useIntersectionObserver';
|
||||||
@ -86,20 +86,20 @@ const StarGiftAction = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (action.alreadyPaidUpgradeStars) {
|
if (action.alreadyPaidUpgradeStars) {
|
||||||
return translateWithOutgoing(
|
return translateWithYou(
|
||||||
lang, 'ActionStarGiftUpgradeText', !isOutgoing, { peer: peerLink },
|
lang, 'ActionStarGiftUpgradeText', !isOutgoing || isSelf, { peer: peerLink },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action.isConverted) {
|
if (action.isConverted) {
|
||||||
return translateWithOutgoing(
|
return translateWithYou(
|
||||||
lang, 'ActionStarGiftConvertedText', !isOutgoing, { peer: peerLink, amount: starsAmount },
|
lang, 'ActionStarGiftConvertedText', !isOutgoing || isSelf, { peer: peerLink, amount: starsAmount },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (starGiftMaxConvertPeriod && getServerTime() < message.date + starGiftMaxConvertPeriod) {
|
if (starGiftMaxConvertPeriod && getServerTime() < message.date + starGiftMaxConvertPeriod) {
|
||||||
return translateWithOutgoing(
|
return translateWithYou(
|
||||||
lang, 'ActionStarGiftConvertText', !isOutgoing, { peer: peerLink, amount: starsAmount },
|
lang, 'ActionStarGiftConvertText', !isOutgoing || isSelf, { peer: peerLink, amount: starsAmount },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,11 +109,12 @@ const StarGiftAction = ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return translateWithOutgoing(
|
return translateWithYou(
|
||||||
lang, 'ActionStarGiftNoConvertText', !isOutgoing, { peer: peerLink },
|
lang, 'ActionStarGiftNoConvertText', !isOutgoing || isSelf, { peer: peerLink },
|
||||||
);
|
);
|
||||||
}, [
|
}, [
|
||||||
action, fallbackPeerTitle, isChannel, isOutgoing, lang, message.date, peer?.id, peerTitle, starGiftMaxConvertPeriod,
|
action, fallbackPeerTitle, isChannel, isOutgoing, lang, message.date, peer?.id, peerTitle, starGiftMaxConvertPeriod,
|
||||||
|
isSelf,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -30,15 +30,15 @@ type VariablesForKey<K extends LangKey> =
|
|||||||
? LangPairPluralWithVariables<TeactNode | undefined>[K] | SuffixKey<LangPairPluralWithVariables, K>
|
? LangPairPluralWithVariables<TeactNode | undefined>[K] | SuffixKey<LangPairPluralWithVariables, K>
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
export function translateWithOutgoing<K extends LangKey>(
|
export function translateWithYou<K extends LangKey>(
|
||||||
lang: LangFn,
|
lang: LangFn,
|
||||||
key: K,
|
key: K,
|
||||||
isOutgoing: boolean,
|
isYou: boolean,
|
||||||
variables: VariablesForKey<K>,
|
variables: VariablesForKey<K>,
|
||||||
options?: { pluralValue?: number; asText?: boolean; isMarkdown?: boolean },
|
options?: { pluralValue?: number; asText?: boolean; isMarkdown?: boolean },
|
||||||
): TeactNode {
|
): TeactNode {
|
||||||
const { pluralValue, asText, isMarkdown } = options || {};
|
const { pluralValue, asText, isMarkdown } = options || {};
|
||||||
const translationKey = isOutgoing ? (`${key}You` as LangKey) : key;
|
const translationKey = isYou ? (`${key}You` as LangKey) : key;
|
||||||
|
|
||||||
return lang(
|
return lang(
|
||||||
// @ts-ignore -- I have no idea if this even possible to type correctly
|
// @ts-ignore -- I have no idea if this even possible to type correctly
|
||||||
|
|||||||
@ -81,7 +81,7 @@ function GiftComposer({
|
|||||||
return {
|
return {
|
||||||
id: -1,
|
id: -1,
|
||||||
chatId: '0',
|
chatId: '0',
|
||||||
isOutgoing: true,
|
isOutgoing: false,
|
||||||
senderId: currentUserId,
|
senderId: currentUserId,
|
||||||
date: Math.floor(Date.now() / 1000),
|
date: Math.floor(Date.now() / 1000),
|
||||||
content: {
|
content: {
|
||||||
@ -99,7 +99,7 @@ function GiftComposer({
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
id: -1,
|
id: -1,
|
||||||
chatId: currentUserId!,
|
chatId: '0',
|
||||||
isOutgoing: false,
|
isOutgoing: false,
|
||||||
senderId: currentUserId,
|
senderId: currentUserId,
|
||||||
date: Math.floor(Date.now() / 1000),
|
date: Math.floor(Date.now() / 1000),
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import { formatDateTimeToString } from '../../../../util/dates/dateFormat';
|
|||||||
import { formatStarsAsIcon, formatStarsAsText } from '../../../../util/localization/format';
|
import { formatStarsAsIcon, formatStarsAsText } from '../../../../util/localization/format';
|
||||||
import { CUSTOM_PEER_HIDDEN } from '../../../../util/objects/customPeer';
|
import { CUSTOM_PEER_HIDDEN } from '../../../../util/objects/customPeer';
|
||||||
import { getServerTime } from '../../../../util/serverTime';
|
import { getServerTime } from '../../../../util/serverTime';
|
||||||
import { formatInteger, formatPercent } from '../../../../util/textFormat';
|
import { formatPercent } from '../../../../util/textFormat';
|
||||||
import { getGiftAttributes, getStickerFromGift } from '../../../common/helpers/gifts';
|
import { getGiftAttributes, getStickerFromGift } from '../../../common/helpers/gifts';
|
||||||
import { renderTextWithEntities } from '../../../common/helpers/renderTextWithEntities';
|
import { renderTextWithEntities } from '../../../common/helpers/renderTextWithEntities';
|
||||||
|
|
||||||
@ -109,6 +109,7 @@ const GiftInfoModal = ({
|
|||||||
|
|
||||||
const gift = isSavedGift ? typeGift.gift : typeGift;
|
const gift = isSavedGift ? typeGift.gift : typeGift;
|
||||||
const giftSticker = gift && getStickerFromGift(gift);
|
const giftSticker = gift && getStickerFromGift(gift);
|
||||||
|
const hasConvertOption = canConvertDifference > 0 && Boolean(savedGift?.starsToConvert);
|
||||||
|
|
||||||
const currenUniqueEmojiStatusSlug = currentUserEmojiStatus?.type === 'collectible'
|
const currenUniqueEmojiStatusSlug = currentUserEmojiStatus?.type === 'collectible'
|
||||||
? currentUserEmojiStatus.slug : undefined;
|
? currentUserEmojiStatus.slug : undefined;
|
||||||
@ -244,8 +245,9 @@ const GiftInfoModal = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
fromId, isNameHidden, starsToConvert, isUnsaved, isConverted,
|
fromId, isNameHidden, starsToConvert, isUnsaved, isConverted, upgradeMsgId,
|
||||||
} = savedGift || {};
|
} = savedGift || {};
|
||||||
|
const canConvert = hasConvertOption && Boolean(starsToConvert);
|
||||||
|
|
||||||
const isVisibleForMe = isNameHidden && renderingTargetPeer;
|
const isVisibleForMe = isNameHidden && renderingTargetPeer;
|
||||||
|
|
||||||
@ -260,17 +262,17 @@ const GiftInfoModal = ({
|
|||||||
: lang('GiftInfoPeerDescriptionFreeUpgradeOut', { peer: getPeerTitle(lang, renderingTargetPeer!)! });
|
: lang('GiftInfoPeerDescriptionFreeUpgradeOut', { peer: getPeerTitle(lang, renderingTargetPeer!)! });
|
||||||
}
|
}
|
||||||
if (!canUpdate && !isSender) return undefined;
|
if (!canUpdate && !isSender) return undefined;
|
||||||
if (isConverted && starsToConvert) {
|
if (isConverted && canConvert) {
|
||||||
return canUpdate
|
return canUpdate
|
||||||
? lang('GiftInfoDescriptionConverted', {
|
? lang('GiftInfoDescriptionConverted', {
|
||||||
amount: formatInteger(starsToConvert!),
|
amount: starsToConvert,
|
||||||
}, {
|
}, {
|
||||||
pluralValue: starsToConvert,
|
pluralValue: starsToConvert,
|
||||||
withNodes: true,
|
withNodes: true,
|
||||||
withMarkdown: true,
|
withMarkdown: true,
|
||||||
})
|
})
|
||||||
: lang('GiftInfoPeerDescriptionOutConverted', {
|
: lang('GiftInfoPeerDescriptionOutConverted', {
|
||||||
amount: formatInteger(starsToConvert!),
|
amount: starsToConvert,
|
||||||
peer: getPeerTitle(lang, renderingTargetPeer!)!,
|
peer: getPeerTitle(lang, renderingTargetPeer!)!,
|
||||||
}, {
|
}, {
|
||||||
pluralValue: starsToConvert,
|
pluralValue: starsToConvert,
|
||||||
@ -280,31 +282,45 @@ const GiftInfoModal = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (savedGift.canUpgrade && canUpdate) {
|
if (savedGift.canUpgrade && canUpdate) {
|
||||||
return lang('GiftInfoDescriptionUpgrade', {
|
if (canConvert) {
|
||||||
amount: formatInteger(starsToConvert!),
|
return lang('GiftInfoDescriptionUpgrade', {
|
||||||
}, {
|
amount: starsToConvert,
|
||||||
pluralValue: starsToConvert!,
|
}, {
|
||||||
withNodes: true,
|
pluralValue: starsToConvert,
|
||||||
withMarkdown: true,
|
withNodes: true,
|
||||||
});
|
withMarkdown: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return lang('GiftInfoDescriptionUpgradeRegular');
|
||||||
}
|
}
|
||||||
|
|
||||||
return canUpdate
|
if (canUpdate) {
|
||||||
? lang('GiftInfoDescription', {
|
if (canConvert) {
|
||||||
amount: starsToConvert,
|
return lang('GiftInfoDescription', {
|
||||||
}, {
|
amount: starsToConvert,
|
||||||
withNodes: true,
|
}, {
|
||||||
withMarkdown: true,
|
withNodes: true,
|
||||||
pluralValue: starsToConvert || 0,
|
withMarkdown: true,
|
||||||
})
|
pluralValue: starsToConvert,
|
||||||
: lang('GiftInfoPeerDescriptionOut', {
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return lang('GiftInfoDescriptionRegular');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canConvert) {
|
||||||
|
return lang('GiftInfoPeerDescriptionOut', {
|
||||||
amount: starsToConvert,
|
amount: starsToConvert,
|
||||||
peer: getPeerTitle(lang, renderingTargetPeer!)!,
|
peer: getPeerTitle(lang, renderingTargetPeer!)!,
|
||||||
}, {
|
}, {
|
||||||
withNodes: true,
|
withNodes: true,
|
||||||
withMarkdown: true,
|
withMarkdown: true,
|
||||||
pluralValue: starsToConvert || 0,
|
pluralValue: starsToConvert,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return lang('GiftInfoPeerDescriptionOutRegular', { peer: getPeerTitle(lang, renderingTargetPeer!)! });
|
||||||
})();
|
})();
|
||||||
|
|
||||||
function getTitle() {
|
function getTitle() {
|
||||||
@ -394,15 +410,17 @@ const GiftInfoModal = ({
|
|||||||
|
|
||||||
const tableData: TableData = [];
|
const tableData: TableData = [];
|
||||||
if (gift.type === 'starGift') {
|
if (gift.type === 'starGift') {
|
||||||
if ((fromId || isNameHidden)) {
|
const hasFrom = fromId || isNameHidden;
|
||||||
|
|
||||||
|
if (hasFrom) {
|
||||||
tableData.push([
|
tableData.push([
|
||||||
lang('GiftInfoFrom'),
|
lang('GiftInfoFrom'),
|
||||||
fromId ? { chatId: fromId } : (
|
!fromId ? (
|
||||||
<>
|
<>
|
||||||
<Avatar size="small" peer={CUSTOM_PEER_HIDDEN} />
|
<Avatar size="small" peer={CUSTOM_PEER_HIDDEN} />
|
||||||
<span className={styles.unknown}>{oldLang(CUSTOM_PEER_HIDDEN.titleKey!)}</span>
|
<span className={styles.unknown}>{oldLang(CUSTOM_PEER_HIDDEN.titleKey!)}</span>
|
||||||
</>
|
</>
|
||||||
),
|
) : { chatId: fromId },
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,7 +451,7 @@ const GiftInfoModal = ({
|
|||||||
lang('GiftInfoValue'),
|
lang('GiftInfoValue'),
|
||||||
<div className={styles.giftValue}>
|
<div className={styles.giftValue}>
|
||||||
{formatStarsAsIcon(lang, starsValue, { className: styles.starAmountIcon })}
|
{formatStarsAsIcon(lang, starsValue, { className: styles.starAmountIcon })}
|
||||||
{canUpdate && canConvertDifference > 0 && Boolean(starsToConvert) && (
|
{canUpdate && hasConvertOption && Boolean(starsToConvert) && (
|
||||||
<BadgeButton onClick={openConvertConfirm}>
|
<BadgeButton onClick={openConvertConfirm}>
|
||||||
{lang('GiftInfoConvert', { amount: starsToConvert }, { pluralValue: starsToConvert })}
|
{lang('GiftInfoConvert', { amount: starsToConvert }, { pluralValue: starsToConvert })}
|
||||||
</BadgeButton>
|
</BadgeButton>
|
||||||
@ -453,7 +471,7 @@ const GiftInfoModal = ({
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gift.upgradeStars && !savedGift?.upgradeMsgId) {
|
if (gift.upgradeStars && !upgradeMsgId) {
|
||||||
tableData.push([
|
tableData.push([
|
||||||
lang('GiftInfoStatus'),
|
lang('GiftInfoStatus'),
|
||||||
<div className={styles.giftValue}>
|
<div className={styles.giftValue}>
|
||||||
@ -613,7 +631,7 @@ const GiftInfoModal = ({
|
|||||||
{tonLink && (
|
{tonLink && (
|
||||||
<div>
|
<div>
|
||||||
{lang('GiftInfoTonText', {
|
{lang('GiftInfoTonText', {
|
||||||
link: <SafeLink url={tonLink} text={lang('GiftInfoTonLinkText')} />,
|
link: <SafeLink url={tonLink} shouldSkipModal text={lang('GiftInfoTonLinkText')} />,
|
||||||
}, { withNodes: true })}
|
}, { withNodes: true })}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@ -649,7 +667,7 @@ const GiftInfoModal = ({
|
|||||||
};
|
};
|
||||||
}, [
|
}, [
|
||||||
typeGift, savedGift, renderingTargetPeer, giftSticker, lang,
|
typeGift, savedGift, renderingTargetPeer, giftSticker, lang,
|
||||||
canUpdate, canConvertDifference, isSender, oldLang, tonExplorerUrl,
|
canUpdate, hasConvertOption, isSender, oldLang, tonExplorerUrl,
|
||||||
gift, giftAttributes, renderFooterButton, isTargetChat,
|
gift, giftAttributes, renderFooterButton, isTargetChat,
|
||||||
SettingsMenuButton, isOpen, isGiftUnique, canWear, canTakeOff,
|
SettingsMenuButton, isOpen, isGiftUnique, canWear, canTakeOff,
|
||||||
]);
|
]);
|
||||||
@ -682,7 +700,7 @@ const GiftInfoModal = ({
|
|||||||
withMarkdown: true,
|
withMarkdown: true,
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
{canConvertDifference > 0 && (
|
{hasConvertOption && (
|
||||||
<div>
|
<div>
|
||||||
{lang('GiftInfoConvertDescriptionPeriod', {
|
{lang('GiftInfoConvertDescriptionPeriod', {
|
||||||
count: conversionLeft,
|
count: conversionLeft,
|
||||||
@ -704,20 +722,21 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
(global, { modal }): StateProps => {
|
(global, { modal }): StateProps => {
|
||||||
const typeGift = modal?.gift;
|
const typeGift = modal?.gift;
|
||||||
const isSavedGift = typeGift && 'gift' in typeGift;
|
const isSavedGift = typeGift && 'gift' in typeGift;
|
||||||
|
const currentUserId = global.currentUserId;
|
||||||
|
|
||||||
const fromId = isSavedGift && typeGift.fromId;
|
const fromId = isSavedGift && typeGift.fromId;
|
||||||
const fromPeer = fromId ? selectPeer(global, fromId) : undefined;
|
const fromPeer = fromId ? selectPeer(global, fromId) : undefined;
|
||||||
const targetPeer = modal?.peerId ? selectPeer(global, modal.peerId) : undefined;
|
const targetPeer = modal?.peerId ? selectPeer(global, modal.peerId) : undefined;
|
||||||
const chat = targetPeer && isApiPeerChat(targetPeer) ? targetPeer : undefined;
|
const chat = targetPeer && isApiPeerChat(targetPeer) ? targetPeer : undefined;
|
||||||
const hasAdminRights = chat && getHasAdminRight(chat, 'postMessages');
|
const hasAdminRights = chat && getHasAdminRight(chat, 'postMessages');
|
||||||
const currentUser = global.currentUserId ? selectUser(global, global.currentUserId) : undefined;
|
const currentUser = selectUser(global, currentUserId!);
|
||||||
const currentUserEmojiStatus = currentUser?.emojiStatus;
|
const currentUserEmojiStatus = currentUser?.emojiStatus;
|
||||||
const collectibleEmojiStatuses = global.collectibleEmojiStatuses?.statuses;
|
const collectibleEmojiStatuses = global.collectibleEmojiStatuses?.statuses;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fromPeer,
|
fromPeer,
|
||||||
targetPeer,
|
targetPeer,
|
||||||
currentUserId: global.currentUserId,
|
currentUserId,
|
||||||
starGiftMaxConvertPeriod: global.appConfig?.starGiftMaxConvertPeriod,
|
starGiftMaxConvertPeriod: global.appConfig?.starGiftMaxConvertPeriod,
|
||||||
tonExplorerUrl: global.appConfig?.tonExplorerUrl,
|
tonExplorerUrl: global.appConfig?.tonExplorerUrl,
|
||||||
hasAdminRights,
|
hasAdminRights,
|
||||||
|
|||||||
@ -219,6 +219,8 @@ addActionHandler('openGiftInfoModalFromMessage', (global, actions, payload): Act
|
|||||||
? { type: 'chat', chatId, savedId: action.savedId }
|
? { type: 'chat', chatId, savedId: action.savedId }
|
||||||
: { type: 'user', messageId };
|
: { type: 'user', messageId };
|
||||||
|
|
||||||
|
const fromId = action.fromId || (message.isOutgoing ? global.currentUserId! : message.chatId);
|
||||||
|
|
||||||
const gift: ApiSavedStarGift = {
|
const gift: ApiSavedStarGift = {
|
||||||
date: message.date,
|
date: message.date,
|
||||||
gift: action.gift,
|
gift: action.gift,
|
||||||
@ -226,7 +228,7 @@ addActionHandler('openGiftInfoModalFromMessage', (global, actions, payload): Act
|
|||||||
starsToConvert: starGift?.starsToConvert,
|
starsToConvert: starGift?.starsToConvert,
|
||||||
isNameHidden: starGift?.isNameHidden,
|
isNameHidden: starGift?.isNameHidden,
|
||||||
isUnsaved: !action.isSaved,
|
isUnsaved: !action.isSaved,
|
||||||
fromId: action.fromId,
|
fromId,
|
||||||
messageId: message.id,
|
messageId: message.id,
|
||||||
isConverted: starGift?.isConverted,
|
isConverted: starGift?.isConverted,
|
||||||
upgradeMsgId: starGift?.upgradeMsgId,
|
upgradeMsgId: starGift?.upgradeMsgId,
|
||||||
|
|||||||
5
src/types/language.d.ts
vendored
5
src/types/language.d.ts
vendored
@ -1169,6 +1169,8 @@ export interface LangPair {
|
|||||||
'GiftInfoSent': undefined;
|
'GiftInfoSent': undefined;
|
||||||
'GiftInfoReceived': undefined;
|
'GiftInfoReceived': undefined;
|
||||||
'GiftInfoTitle': undefined;
|
'GiftInfoTitle': undefined;
|
||||||
|
'GiftInfoDescriptionRegular': undefined;
|
||||||
|
'GiftInfoDescriptionUpgradeRegular': undefined;
|
||||||
'GiftInfoDescriptionFreeUpgrade': undefined;
|
'GiftInfoDescriptionFreeUpgrade': undefined;
|
||||||
'GiftInfoDescriptionUpgraded': undefined;
|
'GiftInfoDescriptionUpgraded': undefined;
|
||||||
'GiftInfoFrom': undefined;
|
'GiftInfoFrom': undefined;
|
||||||
@ -1750,6 +1752,9 @@ export interface LangPairWithVariables<V extends unknown = LangVariable> {
|
|||||||
'title': V;
|
'title': V;
|
||||||
'number': V;
|
'number': V;
|
||||||
};
|
};
|
||||||
|
'GiftInfoPeerDescriptionOutRegular': {
|
||||||
|
'peer': V;
|
||||||
|
};
|
||||||
'GiftInfoPeerDescriptionFreeUpgradeOut': {
|
'GiftInfoPeerDescriptionFreeUpgradeOut': {
|
||||||
'peer': V;
|
'peer': V;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user