import React, { memo } from '../../../lib/teact/teact'; import { getActions, withGlobal } from '../../../global'; import type { PrivacyVisibility } from '../../../types'; import { selectIsCurrentUserPremium, selectShouldHideReadMarks } from '../../../global/selectors'; import renderText from '../../common/helpers/renderText'; import useLastCallback from '../../../hooks/useLastCallback'; import useOldLang from '../../../hooks/useOldLang'; import StarIcon from '../../common/icons/StarIcon'; import Checkbox from '../../ui/Checkbox'; import ListItem from '../../ui/ListItem'; type OwnProps = { visibility?: PrivacyVisibility; }; type StateProps = { isCurrentUserPremium: boolean; shouldHideReadMarks: boolean; }; const SettingsPrivacyLastSeen = ({ isCurrentUserPremium, shouldHideReadMarks, visibility, }: OwnProps & StateProps) => { const { updateGlobalPrivacySettings, openPremiumModal } = getActions(); const lang = useOldLang(); const canShowHideReadTime = visibility === 'nobody' || visibility === 'contacts'; const handleChangeShouldHideReadMarks = useLastCallback( (isEnabled) => updateGlobalPrivacySettings({ shouldHideReadMarks: isEnabled }), ); const handleOpenPremiumModal = useLastCallback(() => { openPremiumModal({ initialSection: 'last_seen', }); }); return ( <> {canShowHideReadTime && (

{renderText(lang('HideReadTimeInfo'), ['br'])}

)}
} onClick={handleOpenPremiumModal} > {isCurrentUserPremium ? lang('PrivacyLastSeenPremiumForPremium') : lang('PrivacyLastSeenPremium')}

{isCurrentUserPremium ? lang('PrivacyLastSeenPremiumInfoForPremium') : lang('PrivacyLastSeenPremiumInfo')}

); }; export default memo(withGlobal( (global): StateProps => { return { isCurrentUserPremium: selectIsCurrentUserPremium(global), shouldHideReadMarks: Boolean(selectShouldHideReadMarks(global)), }; }, )(SettingsPrivacyLastSeen));