Skip to content

Commit 41ce007

Browse files
committed
fixes
1 parent ed4bfa4 commit 41ce007

File tree

12 files changed

+91
-37
lines changed

12 files changed

+91
-37
lines changed

‎src/components/chat/bubbles.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5564,7 +5564,7 @@ export default class ChatBubbles {
55645564
this.wrapSomeSolid(() => StarGiftBubble({
55655565
gift,
55665566
fromId: getPeerId(gift.saved.from_id),
5567-
asUpgrade: gift.isUpgradedBySender && !(action._ === 'messageActionStarGift' && action.pFlags.upgraded),
5567+
asUpgrade: gift.isIncoming && gift.isUpgradedBySender && !(action._ === 'messageActionStarGift' && action.pFlags.upgraded),
55685568
ownerId: gift.isIncoming ? undefined : message.peerId,
55695569
wrapStickerOptions: {
55705570
middleware,

‎src/components/chat/bubbles/chatBackground.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async function getBackgroundParameters(options: {
3434
const full = await managers.appProfileManager.getCachedFullUser(peerId.toUserId())
3535
if(full?.wallpaper) {
3636
wallPaper = full.wallpaper as WallPaper.wallPaper;
37-
} else if(full.theme_emoticon) {
37+
} else if(full?.theme_emoticon) {
3838
const acctTheme = appState.accountThemes.themes?.find((theme) => theme.emoticon === full.theme_emoticon);
3939
if(acctTheme) {
4040
theme = acctTheme;

‎src/components/peerProfile.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,6 @@ export default class PeerProfile {
790790

791791
const callbacks = await Promise.all([
792792
this.setAvatar(true),
793-
this.fillPinnedGifts(),
794793
this.fillRows(deferred)
795794
]);
796795

@@ -1002,6 +1001,10 @@ export default class PeerProfile {
10021001

10031002
this.setMoreDetailsTimeout = window.setTimeout(() => this.setMoreDetails(true), 60e3);
10041003

1004+
if((peerFull._ === 'userFull' || peerFull._ === 'channelFull') && peerFull.stargifts_count > 0) {
1005+
callbacks.push(await m(this.fillPinnedGifts()));
1006+
}
1007+
10051008
return () => {
10061009
callbacks.forEach((callback) => callback());
10071010
};

‎src/components/popups/sendGift.tsx

+46-18
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import lottieLoader from '../../lib/rlottie/lottieLoader';
1313
import classNames from '../../helpers/string/classNames';
1414
import sortLongsArray from '../../helpers/long/sortLongsArray';
1515
import {StarGiftsGrid} from '../stargifts/stargiftsGrid';
16-
import {fastRaf} from '../../helpers/schedulers';
16+
import {doubleRaf, fastRaf} from '../../helpers/schedulers';
1717
import PopupStarGiftInfo from './starGiftInfo';
1818
import {FakeBubbles} from '../chat/bubbles/fakeBubbles';
1919
import {ServiceBubble} from '../chat/bubbles/service';
@@ -37,6 +37,11 @@ import maybe2x from '../../helpers/maybe2x';
3737
import {I18nTsx} from '../../helpers/solid/i18n';
3838
import {StarGiftBadge} from '../stargifts/stargiftBadge';
3939
import Scrollable from '../scrollable2';
40+
import {PeerTitleTsx} from '../wrappers/peerTitle';
41+
import {approxEquals} from '../../helpers/number/approxEquals';
42+
import getVisibleRect from '../../helpers/dom/getVisibleRect';
43+
import fastSmoothScroll from '../../helpers/fastSmoothScroll';
44+
import clamp from '../../helpers/number/clamp';
4045

4146
type GiftOption = MyStarGift | MyPremiumGiftOption;
4247

@@ -63,6 +68,7 @@ function GiftOptionsPage(props: {
6368
const [category, setCategory] = createSignal<string>('All');
6469

6570
let categoriesContainer!: HTMLDivElement;
71+
let categoriesScrollable!: HTMLDivElement
6672
let container!: HTMLDivElement;
6773

6874
const giftPremiumSection = props.peer._ === 'user' && (
@@ -71,7 +77,10 @@ function GiftOptionsPage(props: {
7177
{i18n('GiftPremium')}
7278
</div>
7379
<div class="popup-send-gift-subtitle">
74-
{i18n('GiftTelegramPremiumDescription', [props.peer.first_name])}
80+
<I18nTsx
81+
key="GiftTelegramPremiumDescription"
82+
args={<PeerTitleTsx peerId={props.peerId} onlyFirstName={props.peer._ === 'user'} />}
83+
/>
7584
</div>
7685
<div class="popup-send-gift-premium-options">
7786
<For each={props.premiumOptions}>
@@ -124,11 +133,25 @@ function GiftOptionsPage(props: {
124133
<div
125134
class={classNames('popup-send-gift-category', category() === it && 'active')}
126135
onClick={(event: MouseEvent) => {
127-
if(!categoriesContainer.classList.contains('is-pinned')) {
128-
container.scrollTo({top: categoriesContainer.offsetTop, behavior: 'smooth'});
129-
}
130-
(event.target as HTMLElement).scrollIntoView({behavior: 'smooth'});
136+
const wasPinned = categoriesContainer.classList.contains('is-pinned');
131137
setCategory(it)
138+
const categoryEl = (event.target as HTMLElement).closest('.popup-send-gift-category') as HTMLElement;
139+
fastRaf(() => {
140+
if(!categoriesContainer.classList.contains('is-pinned')) {
141+
container.scrollTo({top: categoriesContainer.offsetTop - 56, behavior: wasPinned ? 'instant' : 'smooth'});
142+
}
143+
144+
const categoryRect = categoryEl.getBoundingClientRect();
145+
const visibleRect = getVisibleRect(categoryEl, categoriesScrollable, false, categoryRect);
146+
if(!visibleRect || visibleRect.overflow.horizontal) {
147+
fastSmoothScroll({
148+
element: categoryEl,
149+
container: categoriesScrollable,
150+
position: 'center',
151+
axis: 'x'
152+
})
153+
}
154+
})
132155
}}
133156
>
134157
{it in STATIC_CATEGORIES ? i18n(STATIC_CATEGORIES[it]) : (
@@ -172,7 +195,7 @@ function GiftOptionsPage(props: {
172195

173196
const containerRect = container.getBoundingClientRect();
174197
const rect = categoriesContainer.getBoundingClientRect();
175-
const isPinned = rect.top - containerRect.top === 56
198+
const isPinned = approxEquals(rect.top - containerRect.top, 56, 0.1)
176199

177200
categoriesContainer.classList.toggle('is-pinned', isPinned);
178201
container.classList.toggle('has-pinned-categories', isPinned);
@@ -200,11 +223,14 @@ function GiftOptionsPage(props: {
200223
{i18n('Chat.Menu.SendGift')}
201224
</div>
202225
<div class="popup-send-gift-subtitle">
203-
{i18n('SendStarGiftSubtitle', [props.peer._ === 'user' ? props.peer.first_name : props.peer.title])}
226+
<I18nTsx
227+
key="SendStarGiftSubtitle"
228+
args={<PeerTitleTsx peerId={props.peerId} onlyFirstName={props.peer._ === 'user'} />}
229+
/>
204230
</div>
205231

206232
<div class="popup-send-gift-categories" ref={categoriesContainer}>
207-
<Scrollable axis="x">
233+
<Scrollable axis="x" ref={categoriesScrollable}>
208234
{wrapCategory('All')}
209235
{wrapCategory('Limited')}
210236
{wrapCategory('InStock')}
@@ -214,13 +240,15 @@ function GiftOptionsPage(props: {
214240
</Scrollable>
215241
</div>
216242

217-
<StarGiftsGrid
218-
class="popup-send-gift-gifts"
219-
items={filteredGiftOptions()}
220-
view="list"
221-
scrollParent={container}
222-
onClick={handleGiftClick}
223-
/>
243+
<div class="popup-send-gift-gifts">
244+
<StarGiftsGrid
245+
class="popup-send-gift-gifts-grid"
246+
items={filteredGiftOptions()}
247+
view="list"
248+
scrollParent={container}
249+
onClick={handleGiftClick}
250+
/>
251+
</div>
224252
</div>
225253
</Scrollable>
226254
)
@@ -359,11 +387,11 @@ function ChosenGiftPage(props: {
359387
/>
360388
) : (
361389
<PremiumGiftBubble
362-
title={i18n('ActionGiftPremiumTitle', [formatMonthsDuration(props.chosenGift.months, false)])}
390+
title={i18n('ActionGiftPremiumTitle2', [formatMonthsDuration(props.chosenGift.months, false)])}
363391
subtitle={
364392
textWithEntities() ?
365393
wrapRichText(textWithEntities().text, {entities: textWithEntities().entities}) :
366-
i18n('ActionGiftPremiumSubtitle')
394+
i18n('ActionGiftPremiumSubtitle2')
367395
}
368396
buttonText={i18n('ActionGiftPremiumView')}
369397
assetName={`Gift${props.chosenGift.months}`}

‎src/components/scrollable2.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ export default function Scrollable(props: {
6464
const [isScrolledToStart, setIsScrolledToStart] = createSignal(true);
6565
const [isScrolledToEnd, setIsScrolledToEnd] = createSignal(true);
6666

67+
let onScrollMeasure = 0;
68+
6769
const removeHeavyAnimationListener = useHeavyAnimationCheck(() => {
6870
isHeavyAnimationInProgress = true;
6971

@@ -82,7 +84,6 @@ export default function Scrollable(props: {
8284

8385
onCleanup(removeHeavyAnimationListener);
8486

85-
let onScrollMeasure = 0;
8687
const onScroll = () => {
8788
// if(this.debug) {
8889
// this.log('onScroll call', this.onScrollMeasure);

‎src/components/stargifts/stargiftsGrid.module.scss

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
padding: 1rem;
88
gap: 0.625rem;
99
flex: 1 0 auto;
10+
height: min-content;
1011

1112
&.viewProfile {
1213
@include respond-to(handhelds) {

‎src/components/stargifts/stargiftsGrid.tsx

+17-7
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function StarGiftGridItem(props: {
3939
props.renderer.observeAnimated(stickerRef);
4040

4141
if(props.view === 'profile') {
42-
const {raw, saved, input} = props.item;
42+
const {raw, saved, input, isIncoming} = props.item;
4343
const isOwnedUniqueGift = raw._ === 'starGiftUnique' && getPeerId(raw.owner_id) === rootScope.myId && saved !== undefined
4444

4545
createContextMenu({
@@ -88,6 +88,14 @@ function StarGiftGridItem(props: {
8888
onClick: () => {
8989
wearStarGift(raw.id)
9090
}
91+
},
92+
{
93+
icon: saved.pFlags.unsaved ? 'eye' : 'eyecross_outline',
94+
text: saved.pFlags.unsaved ? 'Show' : 'Hide',
95+
verify: () => isOwnedUniqueGift || isIncoming,
96+
onClick: () => {
97+
rootScope.managers.appGiftsManager.toggleGiftHidden(input, !saved.pFlags.unsaved)
98+
}
9199
}
92100
]
93101
})
@@ -160,7 +168,7 @@ function StarGiftGridItem(props: {
160168
class={/* @once */ styles.badgeUnique}
161169
backdropAttr={props.item.collectibleAttributes.backdrop}
162170
>
163-
{isPinned() ? `#${gift.num}` : i18n('StarGiftLimitedBadgeNum', [formatNumber(gift.num, 1)])}
171+
{isPinned() ? `#${gift.num}` : i18n('StarGiftLimitedBadgeNum', [formatNumber(gift.availability_total, 1)])}
164172
</StarGiftBadge>
165173
);
166174
};
@@ -173,11 +181,13 @@ function StarGiftGridItem(props: {
173181
)
174182
}
175183

176-
return props.item.raw.availability_total && (
177-
<StarGiftBadge>
178-
{i18n('StarGiftLimitedBadge')}
179-
</StarGiftBadge>
180-
)
184+
if(props.item.raw.availability_total) {
185+
return (
186+
<StarGiftBadge>
187+
{props.view === 'list' ? i18n('StarGiftLimitedBadge') : i18n('StarGiftLimitedBadgeNum', [formatNumber(gift.availability_total, 1)])}
188+
</StarGiftBadge>
189+
)
190+
}
181191
})()}
182192
</div>
183193
);

‎src/config/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const App = {
2222
version: import.meta.env.VITE_VERSION,
2323
versionFull: import.meta.env.VITE_VERSION_FULL,
2424
build: +import.meta.env.VITE_BUILD,
25-
langPackVersion: '6.2.8',
25+
langPackVersion: '6.2.9',
2626
langPack: 'webk',
2727
langPackCode: 'en',
2828
domains: MAIN_DOMAINS,

‎src/helpers/number/approxEquals.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function approxEquals(a: number, b: number, epsilon = 0.001) {
2+
return Math.abs(a - b) < epsilon;
3+
}

‎src/lang.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1709,8 +1709,8 @@ const lang = {
17091709
'ActionGiftUpgradedOutbound': 'You turned the gift from %s into a unique collectible',
17101710
'ActionGiftTransferredInbound': '%s transferred a gift to you',
17111711
'ActionGiftTransferredOutbound': 'You transferred a gift to %s',
1712-
'ActionGiftPremiumTitle': '%s Premium',
1713-
'ActionGiftPremiumSubtitle': 'Subscription for exclusive Telegram features.',
1712+
'ActionGiftPremiumTitle2': '%s Premium',
1713+
'ActionGiftPremiumSubtitle2': 'Subscription for exclusive Telegram features.',
17141714
'ChatAdmin': 'admin',
17151715
'BotRequestAttachPermission': '**%1$s** requests to be added as an option to your attachment menu so you can access it from any chat.',
17161716
'BotCantAddToAttachMenu': 'This bot can\'t be added to the attachment menu.',

‎src/scss/partials/_row.scss

+5
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ $row-border-radius: $border-radius-medium;
150150
white-space: nowrap;
151151
min-width: 0;
152152
flex: 1 1 auto;
153+
154+
.peer-title {
155+
overflow: hidden;
156+
text-overflow: ellipsis;
157+
}
153158
}
154159
}
155160

‎src/scss/partials/popups/_sendGift.scss

+8-5
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77
background: var(--light-filled-secondary-text-color);
88
margin-top: 3.625rem;
99
height: calc(100vh - 6.5rem);
10-
transition: height var(--transition-standard-out), margin-top var(--transition-standard-out);
10+
transition: var(--transition-standard-out);
11+
transition-property: height, margin-top, max-height;
1112
padding: 0;
1213
overflow: visible;
1314
border-radius: 14px;
15+
max-height: 100%;
1416

1517
&.is-chosen-gift {
1618
margin-top: 0rem;
1719
height: calc(100vh - 2.875rem);
20+
max-height: 800px;
1821
}
1922
}
2023
}
@@ -274,8 +277,7 @@
274277

275278
.popup-send-gift-gifts {
276279
width: 100%;
277-
min-height: calc(var(--height) - 4.75rem);
278-
grid-template-rows: max-content;
280+
min-height: calc(var(--height) - 5.75rem);
279281
margin-top: -0.25rem;
280282
}
281283

@@ -307,6 +309,7 @@
307309
gap: 1.5rem;
308310
border-top-right-radius: 14px;
309311
border-top-left-radius: 14px;
312+
background: var(--surface-color);
310313
}
311314

312315
.popup-send-gift-bubbles {
@@ -318,7 +321,6 @@
318321
.popup-send-gift-form-sheet {
319322
padding: 0.5rem;
320323
background-color: var(--surface-color);
321-
border-radius: 14px;
322324

323325
.i18n {
324326
display: flex;
@@ -328,7 +330,6 @@
328330
.currency-star-icon {
329331
width: 1rem;
330332
height: 1rem;
331-
margin-inline-end: .25rem;
332333
}
333334
}
334335
}
@@ -388,7 +389,9 @@
388389
.popup-send-gift-form-send {
389390
margin: 1rem;
390391
width: auto;
392+
height: 3rem;
391393
flex-shrink: 0;
394+
text-transform: uppercase;
392395

393396
.i18n, .xtr {
394397
white-space: pre-wrap;

0 commit comments

Comments
 (0)