Telegram Stars: Follow-up (#4691)
This commit is contained in:
parent
7385d8da2f
commit
7f9ef2aa0f
@ -325,7 +325,7 @@ const MessageList: FC<OwnProps & StateProps> = ({
|
|||||||
if (!messageIds || !messagesById || threadId !== MAIN_THREAD_ID || type === 'scheduled') {
|
if (!messageIds || !messagesById || threadId !== MAIN_THREAD_ID || type === 'scheduled') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const ids = messageIds.filter((id) => messagesById[id].factCheck?.shouldFetch);
|
const ids = messageIds.filter((id) => messagesById[id]?.factCheck?.shouldFetch);
|
||||||
|
|
||||||
if (!ids.length) return;
|
if (!ids.length) return;
|
||||||
|
|
||||||
|
|||||||
@ -77,24 +77,34 @@ const StarsBalanceModal = ({
|
|||||||
}
|
}
|
||||||
}, [isOpen]);
|
}, [isOpen]);
|
||||||
|
|
||||||
const renderingOptions = useMemo(() => {
|
const [renderingOptions, canExtend] = useMemo(() => {
|
||||||
if (!topupOptions) {
|
if (!topupOptions) {
|
||||||
return undefined;
|
return [undefined, false];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const maxOption = topupOptions.reduce((max, option) => (
|
||||||
|
max.stars > option.stars ? max : option
|
||||||
|
));
|
||||||
|
const forceShowAll = starsNeeded && maxOption.stars < starsNeeded;
|
||||||
|
|
||||||
const result: { option: ApiStarTopupOption; starsCount: number }[] = [];
|
const result: { option: ApiStarTopupOption; starsCount: number }[] = [];
|
||||||
let currentStarsCount = 0;
|
let currentStackedStarsCount = 0;
|
||||||
|
let canExtendOptions = false;
|
||||||
topupOptions.forEach((option) => {
|
topupOptions.forEach((option) => {
|
||||||
if (!option.isExtended) currentStarsCount++;
|
if (!option.isExtended) currentStackedStarsCount++;
|
||||||
if (!areOptionsExtended && option.isExtended) return;
|
|
||||||
if (starsNeeded && option.stars < starsNeeded) return;
|
if (starsNeeded && !forceShowAll && option.stars < starsNeeded) return;
|
||||||
|
if (!areOptionsExtended && option.isExtended) {
|
||||||
|
canExtendOptions = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
result.push({
|
result.push({
|
||||||
option,
|
option,
|
||||||
starsCount: currentStarsCount,
|
starsCount: currentStackedStarsCount,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
return [result, canExtendOptions];
|
||||||
}, [areOptionsExtended, topupOptions, starsNeeded]);
|
}, [areOptionsExtended, topupOptions, starsNeeded]);
|
||||||
|
|
||||||
const tosText = useMemo(() => {
|
const tosText = useMemo(() => {
|
||||||
@ -164,8 +174,8 @@ const StarsBalanceModal = ({
|
|||||||
{renderingOptions?.map(({ option, starsCount }) => (
|
{renderingOptions?.map(({ option, starsCount }) => (
|
||||||
<StarTopupOption option={option} starsCount={starsCount} onClick={handleClick} />
|
<StarTopupOption option={option} starsCount={starsCount} onClick={handleClick} />
|
||||||
))}
|
))}
|
||||||
{!areOptionsExtended && (
|
{!areOptionsExtended && canExtend && (
|
||||||
<Button className={styles.moreOptions} noForcedUpperCase isText onClick={markOptionsExtended}>
|
<Button className={styles.moreOptions} isText noForcedUpperCase onClick={markOptionsExtended}>
|
||||||
{lang('Stars.Purchase.ShowMore')}
|
{lang('Stars.Purchase.ShowMore')}
|
||||||
<Icon className={styles.iconDown} name="down" />
|
<Icon className={styles.iconDown} name="down" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user