Paid Messages: Follow up (#5823)
This commit is contained in:
parent
e29302cbbc
commit
500b8e3f26
@ -691,6 +691,8 @@
|
|||||||
|
|
||||||
.placeholder-star-icon {
|
.placeholder-star-icon {
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
|
margin-inline-end: 0.0625rem;
|
||||||
|
margin-inline-start: 0.25rem;
|
||||||
}
|
}
|
||||||
.forced-placeholder,
|
.forced-placeholder,
|
||||||
.placeholder-text {
|
.placeholder-text {
|
||||||
|
|||||||
@ -12,7 +12,5 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.checked .lock-icon {
|
.checked .lock-icon {
|
||||||
left: 1.25rem;
|
|
||||||
font-size: 1rem;
|
|
||||||
color: var(--color-primary);
|
color: var(--color-primary);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import useLang from '../../../hooks/useLang';
|
|||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useOldLang from '../../../hooks/useOldLang';
|
import useOldLang from '../../../hooks/useOldLang';
|
||||||
|
|
||||||
|
import Icon from '../../common/icons/Icon';
|
||||||
import ListItem from '../../ui/ListItem';
|
import ListItem from '../../ui/ListItem';
|
||||||
import RadioGroup from '../../ui/RadioGroup';
|
import RadioGroup from '../../ui/RadioGroup';
|
||||||
import RangeSlider from '../../ui/RangeSlider';
|
import RangeSlider from '../../ui/RangeSlider';
|
||||||
@ -130,8 +131,13 @@ function PrivacyMessages({
|
|||||||
}, [setChargeForMessages, updateGlobalPrivacySettingsWithDebounced]);
|
}, [setChargeForMessages, updateGlobalPrivacySettingsWithDebounced]);
|
||||||
|
|
||||||
const renderValueForStarsRange = useCallback((value: number) => {
|
const renderValueForStarsRange = useCallback((value: number) => {
|
||||||
return formatStarsAsText(lang, value);
|
return (
|
||||||
}, [lang]);
|
<span className="settings-range-value">
|
||||||
|
{!canChangeChargeForMessages && (<Icon name="lock-badge" />)}
|
||||||
|
{formatStarsAsText(lang, value)}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}, [lang, canChangeChargeForMessages]);
|
||||||
|
|
||||||
function renderSectionStarsAmountForPaidMessages() {
|
function renderSectionStarsAmountForPaidMessages() {
|
||||||
return (
|
return (
|
||||||
@ -146,6 +152,7 @@ function PrivacyMessages({
|
|||||||
value={chargeForMessages}
|
value={chargeForMessages}
|
||||||
onChange={handleChargeForMessagesChange}
|
onChange={handleChargeForMessagesChange}
|
||||||
renderValue={renderValueForStarsRange}
|
renderValue={renderValueForStarsRange}
|
||||||
|
readOnly={!canChangeChargeForMessages}
|
||||||
/>
|
/>
|
||||||
<p className="settings-item-description-larger" dir={oldLang.isRtl ? 'rtl' : undefined}>
|
<p className="settings-item-description-larger" dir={oldLang.isRtl ? 'rtl' : undefined}>
|
||||||
{lang('SectionDescriptionStarsForForMessages', {
|
{lang('SectionDescriptionStarsForForMessages', {
|
||||||
@ -219,8 +226,7 @@ function PrivacyMessages({
|
|||||||
{privacyDescription}
|
{privacyDescription}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{canChangeChargeForMessages
|
{selectedValue === 'charge_for_messages' && renderSectionStarsAmountForPaidMessages()}
|
||||||
&& selectedValue === 'charge_for_messages' && renderSectionStarsAmountForPaidMessages()}
|
|
||||||
{canChangeChargeForMessages && selectedValue === 'charge_for_messages' && renderSectionNoPaidMessagesForUsers()}
|
{canChangeChargeForMessages && selectedValue === 'charge_for_messages' && renderSectionNoPaidMessagesForUsers()}
|
||||||
{!isCurrentUserPremium && <PremiumStatusItem premiumSection="message_privacy" />}
|
{!isCurrentUserPremium && <PremiumStatusItem premiumSection="message_privacy" />}
|
||||||
</>
|
</>
|
||||||
|
|||||||
@ -121,6 +121,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.settings-range-value {
|
||||||
|
color: var(--color-primary);
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
.settings-item-simple,
|
.settings-item-simple,
|
||||||
.settings-item {
|
.settings-item {
|
||||||
text-align: initial;
|
text-align: initial;
|
||||||
|
|||||||
@ -226,6 +226,10 @@ const MessageList: FC<OwnProps & StateProps> = ({
|
|||||||
|
|
||||||
const areMessagesLoaded = Boolean(messageIds);
|
const areMessagesLoaded = Boolean(messageIds);
|
||||||
|
|
||||||
|
const isPrivate = isUserId(chatId);
|
||||||
|
const withUsers = Boolean((!isPrivate && !isChannelChat)
|
||||||
|
|| isChatWithSelf || isSystemBotChat || isAnonymousForwards || isChannelWithAvatars);
|
||||||
|
|
||||||
useSyncEffect(() => {
|
useSyncEffect(() => {
|
||||||
// We only need it first time when message list appears
|
// We only need it first time when message list appears
|
||||||
if (areMessagesLoaded) {
|
if (areMessagesLoaded) {
|
||||||
@ -329,9 +333,13 @@ const MessageList: FC<OwnProps & StateProps> = ({
|
|||||||
memoUnreadDividerBeforeIdRef.current,
|
memoUnreadDividerBeforeIdRef.current,
|
||||||
!isForum ? Number(threadId) : undefined,
|
!isForum ? Number(threadId) : undefined,
|
||||||
isChatWithSelf,
|
isChatWithSelf,
|
||||||
|
withUsers,
|
||||||
)
|
)
|
||||||
: undefined;
|
: undefined;
|
||||||
}, [messageIds, messagesById, type, isServiceNotificationsChat, isForum, threadId, isChatWithSelf, channelJoinInfo]);
|
}, [withUsers,
|
||||||
|
messageIds, messagesById, type,
|
||||||
|
isServiceNotificationsChat, isForum,
|
||||||
|
threadId, isChatWithSelf, channelJoinInfo]);
|
||||||
|
|
||||||
useInterval(() => {
|
useInterval(() => {
|
||||||
if (!messageIds || !messagesById || type === 'scheduled') return;
|
if (!messageIds || !messagesById || type === 'scheduled') return;
|
||||||
@ -635,9 +643,6 @@ const MessageList: FC<OwnProps & StateProps> = ({
|
|||||||
}
|
}
|
||||||
}, [isSelectModeActive]);
|
}, [isSelectModeActive]);
|
||||||
|
|
||||||
const isPrivate = isUserId(chatId);
|
|
||||||
const withUsers = Boolean((!isPrivate && !isChannelChat)
|
|
||||||
|| isChatWithSelf || isSystemBotChat || isAnonymousForwards || isChannelWithAvatars);
|
|
||||||
const noAvatars = Boolean(!withUsers || (isChannelChat && !isChannelWithAvatars));
|
const noAvatars = Boolean(!withUsers || (isChannelChat && !isChannelWithAvatars));
|
||||||
const shouldRenderGreeting = isUserId(chatId) && !isChatWithSelf && !isBot && !isAnonymousForwards
|
const shouldRenderGreeting = isUserId(chatId) && !isChatWithSelf && !isBot && !isAnonymousForwards
|
||||||
&& type === 'thread'
|
&& type === 'thread'
|
||||||
|
|||||||
@ -19,7 +19,7 @@ export function isAlbum(messageOrAlbum: ApiMessage | IAlbum): messageOrAlbum is
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function groupMessages(
|
export function groupMessages(
|
||||||
messages: ApiMessage[], firstUnreadId?: number, topMessageId?: number, isChatWithSelf?: boolean,
|
messages: ApiMessage[], firstUnreadId?: number, topMessageId?: number, isChatWithSelf?: boolean, withUsers?: boolean,
|
||||||
) {
|
) {
|
||||||
const initDateGroup: MessageDateGroup = {
|
const initDateGroup: MessageDateGroup = {
|
||||||
originalDate: messages[0].date,
|
originalDate: messages[0].date,
|
||||||
@ -90,7 +90,7 @@ export function groupMessages(
|
|||||||
} else if (
|
} else if (
|
||||||
nextMessage.id === firstUnreadId
|
nextMessage.id === firstUnreadId
|
||||||
|| message.senderId !== nextMessage.senderId
|
|| message.senderId !== nextMessage.senderId
|
||||||
|| message.paidMessageStars
|
|| (!withUsers && message.paidMessageStars)
|
||||||
|| message.isOutgoing !== nextMessage.isOutgoing
|
|| message.isOutgoing !== nextMessage.isOutgoing
|
||||||
|| message.postAuthorTitle !== nextMessage.postAuthorTitle
|
|| message.postAuthorTitle !== nextMessage.postAuthorTitle
|
||||||
|| (isActionMessage(message) && message.content.action?.type !== 'phoneCall')
|
|| (isActionMessage(message) && message.content.action?.type !== 'phoneCall')
|
||||||
|
|||||||
@ -25,6 +25,10 @@
|
|||||||
--slider-color: var(--color-text-secondary);
|
--slider-color: var(--color-text-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.readOnly {
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
.slider-top-row {
|
.slider-top-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import type { ChangeEvent } from 'react';
|
import type { ChangeEvent } from 'react';
|
||||||
import type { FC } from '../../lib/teact/teact';
|
import type { FC, TeactNode } from '../../lib/teact/teact';
|
||||||
import React, { memo, useCallback, useMemo } from '../../lib/teact/teact';
|
import React, { memo, useCallback, useMemo } from '../../lib/teact/teact';
|
||||||
|
|
||||||
import buildClassName from '../../util/buildClassName';
|
import buildClassName from '../../util/buildClassName';
|
||||||
@ -16,9 +16,10 @@ type OwnProps = {
|
|||||||
label?: string;
|
label?: string;
|
||||||
value: number;
|
value: number;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
readOnly?: boolean;
|
||||||
bold?: boolean;
|
bold?: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
renderValue?: (value: number) => string;
|
renderValue?: (value: number) => TeactNode;
|
||||||
onChange: (value: number) => void;
|
onChange: (value: number) => void;
|
||||||
isCenteredLayout?: boolean;
|
isCenteredLayout?: boolean;
|
||||||
};
|
};
|
||||||
@ -31,6 +32,7 @@ const RangeSlider: FC<OwnProps> = ({
|
|||||||
label,
|
label,
|
||||||
value,
|
value,
|
||||||
disabled,
|
disabled,
|
||||||
|
readOnly,
|
||||||
bold,
|
bold,
|
||||||
className,
|
className,
|
||||||
renderValue,
|
renderValue,
|
||||||
@ -46,6 +48,7 @@ const RangeSlider: FC<OwnProps> = ({
|
|||||||
className,
|
className,
|
||||||
'RangeSlider',
|
'RangeSlider',
|
||||||
disabled && 'disabled',
|
disabled && 'disabled',
|
||||||
|
readOnly && 'readOnly',
|
||||||
bold && 'bold',
|
bold && 'bold',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user