Skip to content

Commit 9636876

Browse files
zubidenAjaxy
authored andcommitted
Saved Gifts: Show number on pinned (#5826)
1 parent e69a589 commit 9636876

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

‎src/assets/localization/fallback.strings

+1
Original file line numberDiff line numberDiff line change
@@ -1459,6 +1459,7 @@
14591459
"GiftInfoOwner" = "Owner";
14601460
"GiftInfoIssued" = "{issued}/{total} issued";
14611461
"GiftInfoCollectible" = "Collectible #{number}";
1462+
"GiftSavedNumber" = "#{number}";
14621463
"GiftAttributeModel" = "Model";
14631464
"GiftAttributeBackdrop" = "Backdrop";
14641465
"GiftAttributeSymbol" = "Symbol";

‎src/components/common/gift/SavedGift.tsx

+11-6
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import { getGiftAttributes, getStickerFromGift, getTotalGiftAvailability } from
1313
import useContextMenuHandlers from '../../../hooks/useContextMenuHandlers';
1414
import useFlag from '../../../hooks/useFlag';
1515
import { type ObserveFn, useOnIntersect } from '../../../hooks/useIntersectionObserver';
16+
import useLang from '../../../hooks/useLang';
1617
import useLastCallback from '../../../hooks/useLastCallback';
17-
import useOldLang from '../../../hooks/useOldLang';
1818

1919
import Menu from '../../ui/Menu';
2020
import AnimatedIconFromSticker from '../AnimatedIconFromSticker';
@@ -61,10 +61,17 @@ const SavedGift = ({
6161

6262
const [shouldPlay, play] = useFlag();
6363

64-
const oldLang = useOldLang();
64+
const lang = useLang();
6565

6666
const canManage = peerId === currentUserId || hasAdminRights;
6767

68+
const totalIssued = getTotalGiftAvailability(gift.gift);
69+
const ribbonText = gift.isPinned && gift.gift.type === 'starGiftUnique'
70+
? lang('GiftSavedNumber', { number: gift.gift.number })
71+
: totalIssued
72+
? lang('ActionStarGiftLimitedRibbon', { total: formatIntegerCompact(totalIssued) })
73+
: undefined;
74+
6875
const {
6976
isContextMenuOpen, contextMenuAnchor,
7077
handleBeforeContextMenu, handleContextMenu,
@@ -117,8 +124,6 @@ const SavedGift = ({
117124

118125
if (!sticker) return undefined;
119126

120-
const totalIssued = getTotalGiftAvailability(gift.gift);
121-
122127
return (
123128
<div
124129
ref={ref}
@@ -143,10 +148,10 @@ const SavedGift = ({
143148
<Icon name="eye-crossed-outline" />
144149
</div>
145150
)}
146-
{totalIssued && (
151+
{ribbonText && (
147152
<GiftRibbon
148153
color="blue"
149-
text={oldLang('Gift2Limited1OfRibbon', formatIntegerCompact(totalIssued))}
154+
text={ribbonText}
150155
/>
151156
)}
152157
{contextMenuAnchor !== undefined && (

‎src/types/language.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1856,6 +1856,9 @@ export interface LangPairWithVariables<V extends unknown = LangVariable> {
18561856
'GiftInfoCollectible': {
18571857
'number': V;
18581858
};
1859+
'GiftSavedNumber': {
1860+
'number': V;
1861+
};
18591862
'GiftInfoPeerOriginalInfo': {
18601863
'peer': V;
18611864
'date': V;

0 commit comments

Comments
 (0)