From 9636876aad8fc136b193dda8aba892c266814a56 Mon Sep 17 00:00:00 2001 From: zubiden <19638254+zubiden@users.noreply.github.com> Date: Wed, 23 Apr 2025 18:58:58 +0200 Subject: [PATCH] Saved Gifts: Show number on pinned (#5826) --- src/assets/localization/fallback.strings | 1 + src/components/common/gift/SavedGift.tsx | 17 +++++++++++------ src/types/language.d.ts | 3 +++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/assets/localization/fallback.strings b/src/assets/localization/fallback.strings index d20f1bdbf..6ac2d9207 100644 --- a/src/assets/localization/fallback.strings +++ b/src/assets/localization/fallback.strings @@ -1459,6 +1459,7 @@ "GiftInfoOwner" = "Owner"; "GiftInfoIssued" = "{issued}/{total} issued"; "GiftInfoCollectible" = "Collectible #{number}"; +"GiftSavedNumber" = "#{number}"; "GiftAttributeModel" = "Model"; "GiftAttributeBackdrop" = "Backdrop"; "GiftAttributeSymbol" = "Symbol"; diff --git a/src/components/common/gift/SavedGift.tsx b/src/components/common/gift/SavedGift.tsx index 5621eff3e..e5d88cad8 100644 --- a/src/components/common/gift/SavedGift.tsx +++ b/src/components/common/gift/SavedGift.tsx @@ -13,8 +13,8 @@ import { getGiftAttributes, getStickerFromGift, getTotalGiftAvailability } from import useContextMenuHandlers from '../../../hooks/useContextMenuHandlers'; import useFlag from '../../../hooks/useFlag'; import { type ObserveFn, useOnIntersect } from '../../../hooks/useIntersectionObserver'; +import useLang from '../../../hooks/useLang'; import useLastCallback from '../../../hooks/useLastCallback'; -import useOldLang from '../../../hooks/useOldLang'; import Menu from '../../ui/Menu'; import AnimatedIconFromSticker from '../AnimatedIconFromSticker'; @@ -61,10 +61,17 @@ const SavedGift = ({ const [shouldPlay, play] = useFlag(); - const oldLang = useOldLang(); + const lang = useLang(); const canManage = peerId === currentUserId || hasAdminRights; + const totalIssued = getTotalGiftAvailability(gift.gift); + const ribbonText = gift.isPinned && gift.gift.type === 'starGiftUnique' + ? lang('GiftSavedNumber', { number: gift.gift.number }) + : totalIssued + ? lang('ActionStarGiftLimitedRibbon', { total: formatIntegerCompact(totalIssued) }) + : undefined; + const { isContextMenuOpen, contextMenuAnchor, handleBeforeContextMenu, handleContextMenu, @@ -117,8 +124,6 @@ const SavedGift = ({ if (!sticker) return undefined; - const totalIssued = getTotalGiftAvailability(gift.gift); - return (
)} - {totalIssued && ( + {ribbonText && (