A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
feat(app): prompt account setup when an action needs it
Hampusf8716fd8165d
diff --git a/fluxer_app/src/features/expressions/components/modals/GiftAcceptModal.tsx b/fluxer_app/src/features/expressions/components/modals/GiftAcceptModal.tsxindex 8f1820c50..70952d6e8 100644--- a/fluxer_app/src/features/expressions/components/modals/GiftAcceptModal.tsx+++ b/fluxer_app/src/features/expressions/components/modals/GiftAcceptModal.tsx@@ -1,12 +1,11 @@// SPDX-License-Identifier: AGPL-3.0-or-laterimport * as Modal from '@app/features/app/components/dialogs/Modal';-import {openClaimAccountModal} from '@app/features/auth/components/modals/ClaimAccountModal';import styles from '@app/features/expressions/components/modals/GiftAcceptModal.module.css';+import type {Gift} from '@app/features/gift/commands/GiftCommands';import * as GiftCommands from '@app/features/gift/commands/GiftCommands';import Gifts from '@app/features/gift/state/Gifts';import {getGiftDurationText} from '@app/features/gift/utils/GiftUtils';-import {CLAIM_ACCOUNT_DESCRIPTOR, CLOSE_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';import type {InstanceHTTPTarget} from '@app/features/platform/transport/InstanceHTTP';import {Logger} from '@app/features/platform/utils/AppLogger';import {getPremiumProductName} from '@app/features/premium/utils/PremiumUtils';@@ -15,12 +14,15 @@ import * as ModalCommands from '@app/features/ui/commands/ModalCommands';import {Spinner} from '@app/features/ui/components/Spinner';import {User} from '@app/features/user/models/User';import Users from '@app/features/user/state/Users';+import {getAccountGatePresentation} from '@app/features/user/utils/AccountGatePresentation';+import {canPerform} from '@app/features/user/utils/AccountGates';import * as NicknameUtils from '@app/features/user/utils/NicknameUtils';+import {TierGatedActions} from '@fluxer/constants/src/AccountTierConstants';import {msg} from '@lingui/core/macro';import {Trans, useLingui} from '@lingui/react/macro';import {GiftIcon, QuestionIcon} from '@phosphor-icons/react';import {observer} from 'mobx-react-lite';-import {useEffect, useMemo, useState} from 'react';+import {type ReactNode, useEffect, useMemo, useState} from 'react';const UNKNOWN_GIFT_DESCRIPTOR = msg({message: 'Unknown gift',@@ -54,10 +56,12 @@ export const GiftAcceptModal = observer(function GiftAcceptModal({code, target}:const giftState = Gifts.getGift(code, target);const gift = giftState?.data ?? null;const [isRedeeming, setIsRedeeming] = useState(false);- const isUnclaimed = !(Users.currentUser?.isClaimed() ?? false);+ const giftRedeemGate = canPerform(Users.currentUser, TierGatedActions.GIFT_REDEEM);useEffect(() => {if (!giftState) {- void GiftCommands.fetchWithCoalescing(code, target).catch(() => {});+ void GiftCommands.fetchWithCoalescing(code, target).catch((error) => {+ logger.warn('Failed to load gift for acceptance', {instanceKey: target.instanceKey, error});+ });}}, [code, giftState, target]);const creator = useMemo(() => {@@ -77,14 +81,9 @@ export const GiftAcceptModal = observer(function GiftAcceptModal({code, target}:ModalCommands.pop();};const handleRedeem = async () => {- if (isUnclaimed) {- openClaimAccountModal({force: true});- return;- }setIsRedeeming(true);try {await GiftCommands.redeem(i18n, code, target);- ModalCommands.pop();} catch (error) {logger.error('Failed to redeem gift:', error);setIsRedeeming(false);@@ -96,91 +95,70 @@ export const GiftAcceptModal = observer(function GiftAcceptModal({code, target}:</div>);const renderError = () => (- <>- <div className={styles.card} data-flx="expressions.gift-accept-modal.render-error.card">- <div className={styles.cardGrid} data-flx="expressions.gift-accept-modal.render-error.card-grid">+ <div className={styles.card} data-flx="expressions.gift-accept-modal.render-error.card">+ <div className={styles.cardGrid} data-flx="expressions.gift-accept-modal.render-error.card-grid">+ <div+ className={`${styles.iconCircle} ${styles.iconCircleDisabled}`}+ data-flx="expressions.gift-accept-modal.render-error.icon-circle"+ >+ <QuestionIcon+ className={`${styles.icon} ${styles.iconError}`}+ data-flx="expressions.gift-accept-modal.render-error.icon"+ />+ </div>+ <div className={styles.cardContent} data-flx="expressions.gift-accept-modal.render-error.card-content">+ <h3+ className={`${styles.title} ${styles.titleDanger}`}+ data-flx="expressions.gift-accept-modal.render-error.title"+ >+ {i18n._(UNKNOWN_GIFT_DESCRIPTOR)}+ </h3>+ <span className={styles.helpText} data-flx="expressions.gift-accept-modal.render-error.help-text">+ {i18n._(THIS_GIFT_CODE_IS_INVALID_OR_ALREADY_CLAIMED_DESCRIPTOR)}+ </span>+ </div>+ </div>+ </div>+ );+ const renderRedeemed = (gift: Gift) => {+ const durationText = getGiftDurationText(i18n, gift);+ return (+ <div className={styles.card} data-flx="expressions.gift-accept-modal.render-redeemed.card">+ <div className={styles.cardGrid} data-flx="expressions.gift-accept-modal.render-redeemed.card-grid"><div- className={`${styles.iconCircle} ${styles.iconCircleDisabled}`}- data-flx="expressions.gift-accept-modal.render-error.icon-circle"+ className={`${styles.iconCircle} ${styles.iconCircleInactive}`}+ data-flx="expressions.gift-accept-modal.render-redeemed.icon-circle">- <QuestionIcon- className={`${styles.icon} ${styles.iconError}`}- data-flx="expressions.gift-accept-modal.render-error.icon"+ <GiftIcon+ className={styles.icon}+ weight="fill"+ data-flx="expressions.gift-accept-modal.render-redeemed.icon"/></div>- <div className={styles.cardContent} data-flx="expressions.gift-accept-modal.render-error.card-content">+ <div className={styles.cardContent} data-flx="expressions.gift-accept-modal.render-redeemed.card-content"><h3- className={`${styles.title} ${styles.titleDanger}`}- data-flx="expressions.gift-accept-modal.render-error.title"+ className={`${styles.title} ${styles.titleTertiary}`}+ data-flx="expressions.gift-accept-modal.render-redeemed.title">- {i18n._(UNKNOWN_GIFT_DESCRIPTOR)}+ {durationText}</h3>- <span className={styles.helpText} data-flx="expressions.gift-accept-modal.render-error.help-text">- {i18n._(THIS_GIFT_CODE_IS_INVALID_OR_ALREADY_CLAIMED_DESCRIPTOR)}+ {creatorTag && (+ <span className={styles.subtitle} data-flx="expressions.gift-accept-modal.render-redeemed.subtitle">+ {i18n._(FROM_DESCRIPTOR, {creatorTag})}+ </span>+ )}+ <span className={styles.helpText} data-flx="expressions.gift-accept-modal.render-redeemed.help-text">+ {i18n._(THIS_GIFT_HAS_ALREADY_BEEN_CLAIMED_DESCRIPTOR)}</span></div></div></div>- <div className={styles.footer} data-flx="expressions.gift-accept-modal.render-error.footer">- <Button- variant="secondary"- onClick={handleDismiss}- data-flx="expressions.gift-accept-modal.render-error.button.dismiss"- >- {i18n._(CLOSE_DESCRIPTOR)}- </Button>- </div>- </>- );- const renderRedeemed = () => {- const durationText = getGiftDurationText(i18n, gift!);- return (- <>- <div className={styles.card} data-flx="expressions.gift-accept-modal.render-redeemed.card">- <div className={styles.cardGrid} data-flx="expressions.gift-accept-modal.render-redeemed.card-grid">- <div- className={`${styles.iconCircle} ${styles.iconCircleInactive}`}- data-flx="expressions.gift-accept-modal.render-redeemed.icon-circle"- >- <GiftIcon- className={styles.icon}- weight="fill"- data-flx="expressions.gift-accept-modal.render-redeemed.icon"- />- </div>- <div className={styles.cardContent} data-flx="expressions.gift-accept-modal.render-redeemed.card-content">- <h3- className={`${styles.title} ${styles.titleTertiary}`}- data-flx="expressions.gift-accept-modal.render-redeemed.title"- >- {durationText}- </h3>- {creatorTag && (- <span className={styles.subtitle} data-flx="expressions.gift-accept-modal.render-redeemed.subtitle">- {i18n._(FROM_DESCRIPTOR, {creatorTag})}- </span>- )}- <span className={styles.helpText} data-flx="expressions.gift-accept-modal.render-redeemed.help-text">- {i18n._(THIS_GIFT_HAS_ALREADY_BEEN_CLAIMED_DESCRIPTOR)}- </span>- </div>- </div>- </div>- <div className={styles.footer} data-flx="expressions.gift-accept-modal.render-redeemed.footer">- <Button- variant="secondary"- onClick={handleDismiss}- data-flx="expressions.gift-accept-modal.render-redeemed.button.dismiss"- >- {i18n._(CLOSE_DESCRIPTOR)}- </Button>- </div>- </>);};- const renderGift = () => {- const durationText = getGiftDurationText(i18n, gift!);- if (isUnclaimed) {+ const renderGift = (gift: Gift) => {+ const durationText = getGiftDurationText(i18n, gift);+ if (!giftRedeemGate.allowed) {+ const gatePresentation = getAccountGatePresentation(i18n, giftRedeemGate);return (<><div className={styles.card} data-flx="expressions.gift-accept-modal.render-gift.card">@@ -208,7 +186,7 @@ export const GiftAcceptModal = observer(function GiftAcceptModal({code, target}:</span>)}<span className={styles.helpText} data-flx="expressions.gift-accept-modal.render-gift.help-text">- <Trans>Claim your account to redeem this gift.</Trans>+ {gatePresentation.description}</span></div></div>@@ -224,12 +202,12 @@ export const GiftAcceptModal = observer(function GiftAcceptModal({code, target}:<Buttonvariant="primary"onClick={() => {- openClaimAccountModal({force: true});+ gatePresentation.onAction();handleDismiss();}}data-flx="expressions.gift-accept-modal.render-gift.button.open-claim-account-modal">- {i18n._(CLAIM_ACCOUNT_DESCRIPTOR)}+ {gatePresentation.actionLabel}</Button></div></>@@ -291,18 +269,27 @@ export const GiftAcceptModal = observer(function GiftAcceptModal({code, target}:</>);};+ const isLoading = !giftState || giftState.loading || Users.currentUser == null;+ const isUnavailable = !isLoading && (giftState.error || !gift || gift.redeemed);+ const header = <Modal.Header title={<Trans>Gift</Trans>} data-flx="expressions.gift-accept-modal.modal-header" />;+ const contentClassName = styles.content;+ let content: ReactNode;+ if (isLoading) {+ content = renderLoading();+ } else if (giftState.error || !gift) {+ content = renderError();+ } else if (gift.redeemed) {+ content = renderRedeemed(gift);+ } else {+ content = renderGift(gift);+ }return (<Modal.Root size="small" centered data-flx="expressions.gift-accept-modal.modal-root">- <Modal.Header title={<Trans>Gift</Trans>} data-flx="expressions.gift-accept-modal.modal-header" />- <Modal.Content padding="none" className={styles.content} data-flx="expressions.gift-accept-modal.content">- {!giftState || giftState.loading- ? renderLoading()- : giftState.error || !gift- ? renderError()- : gift.redeemed- ? renderRedeemed()- : renderGift()}+ {header}+ <Modal.Content padding="none" className={contentClassName} data-flx="expressions.gift-accept-modal.content">+ {content}</Modal.Content>+ {isUnavailable && <Modal.DismissFooter data-flx="expressions.gift-accept-modal.dismiss-footer" />}</Modal.Root>);});diff --git a/fluxer_app/src/features/invite/components/modals/InviteModal.tsx b/fluxer_app/src/features/invite/components/modals/InviteModal.tsxindex 08622ba26..48d708c98 100644--- a/fluxer_app/src/features/invite/components/modals/InviteModal.tsx+++ b/fluxer_app/src/features/invite/components/modals/InviteModal.tsx@@ -11,6 +11,7 @@ import {} from '@app/features/app/components/dialogs/shared/RecipientList';import selectorStyles from '@app/features/app/components/dialogs/shared/SelectorModalStyles.module.css';import RuntimeConfig from '@app/features/app/state/RuntimeConfig';+import {promptForAccountTier} from '@app/features/auth/utils/AccountTierPrompt';import type {Channel} from '@app/features/channel/models/Channel';import Channels from '@app/features/channel/state/Channels';import * as ChannelUtils from '@app/features/channel/utils/ChannelUtils';@@ -37,6 +38,7 @@ import {failureCode} from '@app/features/platform/utils/ResponseInspection';import StreamerMode from '@app/features/streamer_mode/state/StreamerMode';import {remFromPx} from '@app/features/theme/layout/RemFromPx';import {Button} from '@app/features/ui/button/Button';+import * as ModalCommands from '@app/features/ui/commands/ModalCommands';import {Combobox} from '@app/features/ui/components/form/FormCombobox';import {Input} from '@app/features/ui/components/form/FormInput';import {Switch} from '@app/features/ui/components/form/FormSwitch';@@ -262,6 +264,11 @@ const InviteModalContent = observer(function InviteModalContent({temporary: options?.temporary,});setInvite(newInvite);+ } catch (error) {+ if (!promptForAccountTier(error)) {+ throw error;+ }+ ModalCommands.pop();} finally {setLoading(false);}@@ -275,11 +282,12 @@ const InviteModalContent = observer(function InviteModalContent({}, [loadInvite, isUsingVanityUrl]);const title = i18n._(INVITE_FRIENDS_TO_DESCRIPTOR, {guildName: guild.name});const invitesDisabled = guild.features.has(GuildFeatures.INVITES_DISABLED);- const inviteUrl = isUsingVanityUrl- ? InviteUtils.getVanityInviteUrl(inviteCapability.vanityUrlCode!)- : invite- ? `${RuntimeConfig.inviteEndpoint}/${invite.code}`- : '';+ let inviteUrl = '';+ if (isUsingVanityUrl) {+ inviteUrl = InviteUtils.getVanityInviteUrl(inviteCapability.vanityUrlCode);+ } else if (invite) {+ inviteUrl = `${RuntimeConfig.inviteEndpoint}/${invite.code}`;+ }const hideInviteLinks = StreamerMode.shouldHideInviteLinks;const displayedInviteUrl = hideInviteLinks && inviteUrl ? i18n._(LINK_HIDDEN_WHILE_SHARING_DESCRIPTOR) : inviteUrl;const handleCopy = useCopyLinkHandler(inviteUrl, true);diff --git a/fluxer_app/src/features/user/components/modals/UserProfileMobileSheet.tsx b/fluxer_app/src/features/user/components/modals/UserProfileMobileSheet.tsxindex 18839dfc6..3110da98a 100644--- a/fluxer_app/src/features/user/components/modals/UserProfileMobileSheet.tsx+++ b/fluxer_app/src/features/user/components/modals/UserProfileMobileSheet.tsx@@ -60,9 +60,11 @@ import UserNote from '@app/features/user/state/UserNote';import UserProfile from '@app/features/user/state/UserProfile';import UserProfileMobile from '@app/features/user/state/UserProfileMobile';import Users from '@app/features/user/state/Users';+import {canPerform} from '@app/features/user/utils/AccountGates';import {blockedDmConfirmModal, openDMChannelOrShowError} from '@app/features/user/utils/DMActionUtils';import * as NicknameUtils from '@app/features/user/utils/NicknameUtils';import * as ProfileDisplayUtils from '@app/features/user/utils/ProfileDisplayUtils';+import {canOpenProfileEditor} from '@app/features/user/utils/ProfileEditAccess';import {getProfileMembershipDisplayName,resolveProfileGuildMembership,@@ -73,6 +75,7 @@ import {SEND_FRIEND_REQUEST_DESCRIPTOR, UNBLOCK_USER_DESCRIPTOR} from '@app/featimport {shouldShowDiscriminator} from '@app/features/user/utils/UserTagUtils';import * as CallUtils from '@app/features/voice/utils/CallUtils';import {hasActiveDirectCallWithUser} from '@app/features/voice/utils/PrivateCallMenuUtils';+import {TierGatedActions} from '@fluxer/constants/src/AccountTierConstants';import {ME} from '@fluxer/constants/src/AppConstants';import {Permissions} from '@fluxer/constants/src/ChannelConstants';import {@@ -238,7 +241,8 @@ const UserProfileMobileSheetContent: React.FC<UserProfileMobileSheetContentPropsconst relationshipType = relationship?.type;const isBlocked = relationshipType === RelationshipTypes.BLOCKED;const hasActiveDirectCall = hasActiveDirectCallWithUser(user.id);- const currentUserUnclaimed = !(Users.currentUser?.isClaimed() ?? true);+ const canSendFriendRequest = canPerform(Users.currentUser, TierGatedActions.FRIEND_REQUEST).allowed;+ const showEditProfile = canOpenProfileEditor(Users.currentUser);const profileMembership = resolveProfileGuildMembership(profile, {fallbackGuildId: guildId,userId: user.id,@@ -365,7 +369,7 @@ const UserProfileMobileSheetContent: React.FC<UserProfileMobileSheetContentPropsconst renderRelationshipButton = () => {const isFriendlyBot = user.bot && (user.flags & PublicUserFlags.FRIENDLY_BOT) === PublicUserFlags.FRIENDLY_BOT;if (isCurrentUser || (user.bot && !isFriendlyBot)) return null;- if (RuntimeConfig.directMessagesDisabled && relationshipType !== RelationshipTypes.BLOCKED) {+ if (RuntimeConfig.friendsDisabled && relationshipType !== RelationshipTypes.BLOCKED) {return null;}if (relationshipType === RelationshipTypes.FRIEND) {@@ -432,7 +436,7 @@ const UserProfileMobileSheetContent: React.FC<UserProfileMobileSheetContentProps</button>);}- if (relationshipType === undefined && !currentUserUnclaimed && Users.currentUser?.verified !== false) {+ if (relationshipType === undefined && canSendFriendRequest) {return (<buttontype="button"@@ -604,8 +608,7 @@ const UserProfileMobileSheetContent: React.FC<UserProfileMobileSheetContentPropsdata-flx="user.user-profile-mobile-sheet.user-profile-mobile-sheet-content.badges-wrapper"><UserProfileBadges- user={user}- profile={profile}+ badges={profile.profileBadges}isModal={true}isMobile={true}data-flx="user.user-profile-mobile-sheet.user-profile-mobile-sheet-content.user-profile-badges"@@ -629,7 +632,7 @@ const UserProfileMobileSheetContent: React.FC<UserProfileMobileSheetContentProps</div></div>{isCurrentUser ? (- !currentUserUnclaimed && (+ showEditProfile && (<divclassName={styles.actionButtonsContainer}data-flx="user.user-profile-mobile-sheet.user-profile-mobile-sheet-content.action-buttons-container"diff --git a/fluxer_app/src/features/user/components/modals/UserProfileModal.tsx b/fluxer_app/src/features/user/components/modals/UserProfileModal.tsxindex 3e97e201c..cc8ca60df 100644--- a/fluxer_app/src/features/user/components/modals/UserProfileModal.tsx+++ b/fluxer_app/src/features/user/components/modals/UserProfileModal.tsx@@ -53,9 +53,12 @@ import type {Profile} from '@app/features/user/models/Profile';import {User} from '@app/features/user/models/User';import UserNote from '@app/features/user/state/UserNote';import Users from '@app/features/user/state/Users';+import {accountGateReason} from '@app/features/user/utils/AccountGatePresentation';+import {canPerform} from '@app/features/user/utils/AccountGates';import {blockedDmConfirmModal, openDMChannelOrShowError} from '@app/features/user/utils/DMActionUtils';import * as NicknameUtils from '@app/features/user/utils/NicknameUtils';import type * as ProfileDisplayUtils from '@app/features/user/utils/ProfileDisplayUtils';+import {canOpenProfileEditor} from '@app/features/user/utils/ProfileEditAccess';import {getProfileMembershipDisplayName,resolveProfileGuildMembership,@@ -73,6 +76,7 @@ import {} from '@app/features/user/utils/UserMessageDescriptors';import * as CallUtils from '@app/features/voice/utils/CallUtils';import {hasActiveDirectCallWithUser} from '@app/features/voice/utils/PrivateCallMenuUtils';+import {TierGatedActions} from '@fluxer/constants/src/AccountTierConstants';import {PublicUserFlags, RelationshipTypes} from '@fluxer/constants/src/UserConstants';import {msg} from '@lingui/core/macro';import {Trans, useLingui} from '@lingui/react/macro';@@ -106,11 +110,6 @@ const YOU_CAN_T_BEFRIEND_YOURSELF_DESCRIPTOR = msg({comment: 'Error message in the user profile modal.',});-const CLAIM_YOUR_ACCOUNT_TO_SEND_FRIEND_REQUESTS_DESCRIPTOR = msg({- message: 'Claim your account to send friend requests.',- comment: 'Description text in the user profile modal.',-});-const logger = new Logger('UserProfileModal');interface UserProfileModalProps {@@ -425,7 +424,7 @@ export const UserProfileModal: UserProfileModalComponent = observer({i18n._(COPY_USER_ID_DESCRIPTOR)}</MenuItem></MenuGroup>- {!isCurrentUser && relationshipType === RelationshipTypes.FRIEND && !RuntimeConfig.directMessagesDisabled && (+ {!isCurrentUser && relationshipType === RelationshipTypes.FRIEND && !RuntimeConfig.friendsDisabled && (<MenuGroup data-flx="user.user-profile-modal.open-more-options-menu.menu-group--4"><MenuItemicon={@@ -476,7 +475,8 @@ export const UserProfileModal: UserProfileModalComponent = observer());};const renderActionButtons = () => {- const currentUserUnclaimed = !(Users.currentUser?.isClaimed() ?? true);+ const showEditProfile = canOpenProfileEditor(Users.currentUser);+ const friendRequestGate = canPerform(Users.currentUser, TierGatedActions.FRIEND_REQUEST);if (isCurrentUser && disableEditProfile) {return (<div@@ -535,7 +535,7 @@ export const UserProfileModal: UserProfileModalComponent = observer(className={userProfileModalStyles.actionButtons}data-flx="user.user-profile-modal.render-action-buttons.div--4">- {!currentUserUnclaimed && (+ {showEditProfile && (<Buttonsmall={true}leftIcon={@@ -574,7 +574,7 @@ export const UserProfileModal: UserProfileModalComponent = observer(if (isUserBot && !isFriendlyBot) {return null;}- if (RuntimeConfig.directMessagesDisabled && relationshipType !== RelationshipTypes.BLOCKED) {+ if (RuntimeConfig.friendsDisabled && relationshipType !== RelationshipTypes.BLOCKED) {return null;}if (relationshipType === RelationshipTypes.FRIEND) {@@ -682,9 +682,9 @@ export const UserProfileModal: UserProfileModalComponent = observer();}if (relationshipType === undefined && (!isUserBot || isFriendlyBot)) {- const tooltipText = currentUserUnclaimed- ? i18n._(CLAIM_YOUR_ACCOUNT_TO_SEND_FRIEND_REQUESTS_DESCRIPTOR)- : i18n._(SEND_FRIEND_REQUEST_DESCRIPTOR);+ const tooltipText = friendRequestGate.allowed+ ? i18n._(SEND_FRIEND_REQUEST_DESCRIPTOR)+ : accountGateReason(i18n, friendRequestGate);return (<Tooltiptext={tooltipText}@@ -704,7 +704,7 @@ export const UserProfileModal: UserProfileModalComponent = observer(}aria-label={i18n._(SEND_FRIEND_REQUEST_DESCRIPTOR)}onClick={handleSendFriendRequest}- disabled={currentUserUnclaimed}+ disabled={!friendRequestGate.allowed}data-flx="user.user-profile-modal.render-primary-action-button.button.send-friend-request"/></div>diff --git a/fluxer_app/src/features/user/components/modals/tabs/GiftInventoryTab.tsx b/fluxer_app/src/features/user/components/modals/tabs/GiftInventoryTab.tsxindex 0cf71a0d5..6ae507ff4 100644--- a/fluxer_app/src/features/user/components/modals/tabs/GiftInventoryTab.tsx+++ b/fluxer_app/src/features/user/components/modals/tabs/GiftInventoryTab.tsx@@ -6,13 +6,11 @@ import {SettingsTabContainer} from '@app/features/app/components/dialogs/shared/import {StatusSlate} from '@app/features/app/components/dialogs/shared/StatusSlate';import {useFormSubmit} from '@app/features/app/hooks/useFormSubmit';import RuntimeConfig from '@app/features/app/state/RuntimeConfig';-import {openClaimAccountModal} from '@app/features/auth/components/modals/ClaimAccountModal';import {GiftSendToFriendModal} from '@app/features/expressions/components/modals/GiftSendToFriendModal';import type {GiftMetadata} from '@app/features/gift/commands/GiftCommands';import * as GiftCommands from '@app/features/gift/commands/GiftCommands';import {getGiftDurationText} from '@app/features/gift/utils/GiftUtils';import {- CLAIM_ACCOUNT_DESCRIPTOR,COPIED_DESCRIPTOR,TRY_AGAIN_DESCRIPTOR,TRY_AGAIN_IN_A_MOMENT_DESCRIPTOR,@@ -33,21 +31,16 @@ import {Spinner} from '@app/features/ui/components/Spinner';import * as UserCommands from '@app/features/user/commands/UserCommands';import styles from '@app/features/user/components/modals/tabs/GiftInventoryTab.module.css';import Users from '@app/features/user/state/Users';+import {AccountGateSlate} from '@app/features/user/utils/AccountGatePresentation';+import {canPerform} from '@app/features/user/utils/AccountGates';import {getFormattedShortDate} from '@app/features/user/utils/DateFormatting';import * as NicknameUtils from '@app/features/user/utils/NicknameUtils';+import {TierGatedActions} from '@fluxer/constants/src/AccountTierConstants';import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants';import {msg} from '@lingui/core/macro';import {Trans, useLingui} from '@lingui/react/macro';-import {- CaretDownIcon,- CheckIcon,- CopyIcon,- GiftIcon,- NetworkSlashIcon,- ShareNetworkIcon,- WarningCircleIcon,-} from '@phosphor-icons/react';+import {CaretDownIcon, CheckIcon, CopyIcon, GiftIcon, NetworkSlashIcon, ShareNetworkIcon} from '@phosphor-icons/react';import {clsx} from 'clsx';import {observer} from 'mobx-react-lite';import type React from 'react';@@ -82,10 +75,6 @@ const GIFT_REDEEMED_SUCCESSFULLY_DESCRIPTOR = msg({message: 'Gift redeemed successfully. Enjoy your {premiumProductName}.',comment: 'Toast shown after redeeming a premium gift code.',});-const CLAIM_ACCOUNT_TO_MANAGE_GIFTS_DESCRIPTOR = msg({- message: 'Claim your account to redeem or manage {premiumProductName} gift codes.',- comment: 'Gift inventory empty-state text shown to unclaimed accounts.',-});const ENTER_GIFT_CODE_TO_REDEEM_DESCRIPTOR = msg({message: 'Enter a gift code to redeem {premiumProductName} for your account.',comment: 'Gift redemption form description.',@@ -302,7 +291,8 @@ const GiftInventoryTab: React.FC = observer(() => {const [loading, setLoading] = useState(true);const [error, setError] = useState(false);const [expandedGiftId, setExpandedGiftId] = useState<string | null>(null);- const isUnclaimed = !(Users.currentUser?.isClaimed() ?? false);+ const giftRedeemGate = canPerform(Users.currentUser, TierGatedActions.GIFT_REDEEM);+ const isGiftRedeemBlocked = !giftRedeemGate.allowed;const giftCodeForm = useForm<GiftCodeFormInputs>({defaultValues: {code: ''}});const handleGiftCodeSubmit = useCallback(async (data: GiftCodeFormInputs) => {@@ -319,7 +309,7 @@ const GiftInventoryTab: React.FC = observer(() => {defaultErrorField: 'code',});const fetchGifts = useCallback(async () => {- if (isUnclaimed) {+ if (isGiftRedeemBlocked) {setLoading(false);return;}@@ -333,7 +323,7 @@ const GiftInventoryTab: React.FC = observer(() => {setError(true);setLoading(false);}- }, [isUnclaimed]);+ }, [isGiftRedeemBlocked]);useEffect(() => {fetchGifts();}, [fetchGifts]);@@ -343,24 +333,8 @@ const GiftInventoryTab: React.FC = observer(() => {const handleRedeemSuccess = () => {fetchGifts();};- if (isUnclaimed) {- return (- <StatusSlate- Icon={WarningCircleIcon}- title={<Trans>Claim your account</Trans>}- description={i18n._(CLAIM_ACCOUNT_TO_MANAGE_GIFTS_DESCRIPTOR, {- premiumProductName: getPremiumProductName(),- })}- actions={[- {- text: i18n._(CLAIM_ACCOUNT_DESCRIPTOR),- onClick: () => openClaimAccountModal({force: true}),- variant: 'primary',- },- ]}- data-flx="user.gift-inventory-tab.status-slate"- />- );+ if (!giftRedeemGate.allowed) {+ return <AccountGateSlate gate={giftRedeemGate} data-flx="user.gift-inventory-tab.account-gate-slate" />;}return (<SettingsTabContainer data-flx="user.gift-inventory-tab.settings-tab-container">diff --git a/fluxer_app/src/features/user/components/modals/tabs/applications_tab/index.tsx b/fluxer_app/src/features/user/components/modals/tabs/applications_tab/index.tsxindex d54fb4ec2..efb9facbc 100644--- a/fluxer_app/src/features/user/components/modals/tabs/applications_tab/index.tsx+++ b/fluxer_app/src/features/user/components/modals/tabs/applications_tab/index.tsx@@ -19,6 +19,9 @@ import ApplicationsTabState from '@app/features/user/components/modals/tabs/applimport {useSettingsContentKey} from '@app/features/user/hooks/useSettingsContentKey';import {useUnsavedChangesFlash} from '@app/features/user/hooks/useUnsavedChangesFlash';import Users from '@app/features/user/state/Users';+import {accountGateReason} from '@app/features/user/utils/AccountGatePresentation';+import {canPerform} from '@app/features/user/utils/AccountGates';+import {TierGatedActions} from '@fluxer/constants/src/AccountTierConstants';import {msg} from '@lingui/core/macro';import {Trans, useLingui} from '@lingui/react/macro';import {BookOpenIcon, WarningCircleIcon} from '@phosphor-icons/react';@@ -26,10 +29,6 @@ import {observer} from 'mobx-react-lite';import type React from 'react';import {useCallback, useEffect, useLayoutEffect} from 'react';-const CLAIM_YOUR_ACCOUNT_TO_CREATE_APPLICATIONS_DESCRIPTOR = msg({- message: 'Claim your account to create applications.',- comment: 'Description text in the index.',-});const READ_DOCUMENTATION_DESCRIPTOR = msg({message: 'Read the documentation ({domain})',comment: 'Developer applications link label. domain is the documentation domain.',@@ -39,7 +38,7 @@ const ApplicationsTab: React.FC = observer(() => {const {checkUnsavedChanges} = useUnsavedChangesFlash('applications');const {setContentKey} = useSettingsContentKey();const store = ApplicationsTabState;- const isUnclaimed = !(Users.currentUser?.isClaimed() ?? false);+ const createGate = canPerform(Users.currentUser, TierGatedActions.APPLICATION_CREATE);useLayoutEffect(() => {setContentKey(store.contentKey);}, [store.contentKey, setContentKey]);@@ -130,11 +129,8 @@ const ApplicationsTab: React.FC = observer(() => {data-flx="user.applications-tab.settings-tab-section--2"><div className={styles.buttonContainer} data-flx="user.applications-tab.button-container">- {isUnclaimed ? (- <Tooltip- text={i18n._(CLAIM_YOUR_ACCOUNT_TO_CREATE_APPLICATIONS_DESCRIPTOR)}- data-flx="user.applications-tab.tooltip"- >+ {!createGate.allowed ? (+ <Tooltip text={accountGateReason(i18n, createGate)} data-flx="user.applications-tab.tooltip"><div data-flx="user.applications-tab.div"><Buttonvariant="primary"diff --git a/fluxer_app/src/features/user/components/modals/tabs/my_profile_tab/MyProfileTabUsernameSection.tsx b/fluxer_app/src/features/user/components/modals/tabs/my_profile_tab/MyProfileTabUsernameSection.tsxindex 23c9632fb..26b8e5592 100644--- a/fluxer_app/src/features/user/components/modals/tabs/my_profile_tab/MyProfileTabUsernameSection.tsx+++ b/fluxer_app/src/features/user/components/modals/tabs/my_profile_tab/MyProfileTabUsernameSection.tsx@@ -13,19 +13,13 @@ import {Tooltip} from '@app/features/ui/tooltip/Tooltip';import {FluxerTagChangeModal} from '@app/features/user/components/modals/FluxerTagChangeModal';import styles from '@app/features/user/components/modals/tabs/my_profile_tab/MyProfileTabUsernameSection.module.css';import type {User} from '@app/features/user/models/User';+import {accountGateReason} from '@app/features/user/utils/AccountGatePresentation';+import type {AccountGateResult} from '@app/features/user/utils/AccountGates';import {msg} from '@lingui/core/macro';import {Trans, useLingui} from '@lingui/react/macro';-import {CrownIcon} from '@phosphor-icons/react';+import {AtomIcon} from '@phosphor-icons/react';import {observer} from 'mobx-react-lite';-const CLAIM_YOUR_ACCOUNT_TO_CHANGE_YOUR_USERNAME_DESCRIPTOR = msg({- message: 'Claim your account to change your username',- comment: 'Label in the username section.',-});-const VERIFY_YOUR_EMAIL_TO_CHANGE_YOUR_USERNAME_DESCRIPTOR = msg({- message: 'Verify your email to change your username',- comment: 'Label in the username section.',-});const CUSTOMIZE_YOUR_TAG_TO_YOUR_LIKING_WITH_DESCRIPTOR = msg({message: 'Customize your tag ({discriminatorLabel}) to your liking with {premiumProductName}',comment:@@ -38,12 +32,11 @@ const GET_TO_CUSTOMIZE_YOUR_TAG_DESCRIPTOR = msg({});interface UsernameSectionProps {- isClaimed: boolean;- isEmailVerified: boolean;+ profileGate: AccountGateResult;user: User;}-export const UsernameSection = observer(({isClaimed, isEmailVerified, user}: UsernameSectionProps) => {+export const UsernameSection = observer(({profileGate, user}: UsernameSectionProps) => {const {i18n} = useLingui();const hasCustomDiscriminator = isLimitToggleEnabled({feature_custom_discriminator: LimitResolver.resolve({key: 'feature_custom_discriminator', fallback: 0})},@@ -56,28 +49,14 @@ export const UsernameSection = observer(({isClaimed, isEmailVerified, user}: Use<Trans>Username</Trans></div><div className={styles.actions} data-flx="user.my-profile-tab.username-section.actions">- {!isClaimed ? (- <Tooltip- text={i18n._(CLAIM_YOUR_ACCOUNT_TO_CHANGE_YOUR_USERNAME_DESCRIPTOR)}- data-flx="user.my-profile-tab.username-section.tooltip"- >+ {!profileGate.allowed ? (+ <Tooltip text={accountGateReason(i18n, profileGate)} data-flx="user.my-profile-tab.username-section.tooltip"><div data-flx="user.my-profile-tab.username-section.div--2"><Button variant="primary" small disabled data-flx="user.my-profile-tab.username-section.button"><Trans>Change username</Trans></Button></div></Tooltip>- ) : !isEmailVerified ? (- <Tooltip- text={i18n._(VERIFY_YOUR_EMAIL_TO_CHANGE_YOUR_USERNAME_DESCRIPTOR)}- data-flx="user.my-profile-tab.username-section.tooltip--2"- >- <div data-flx="user.my-profile-tab.username-section.div--3">- <Button variant="primary" small disabled data-flx="user.my-profile-tab.username-section.button--2">- <Trans>Change username</Trans>- </Button>- </div>- </Tooltip>) : (<Buttonvariant="primary"@@ -114,11 +93,7 @@ export const UsernameSection = observer(({isClaimed, isEmailVerified, user}: Usearia-label={i18n._(GET_TO_CUSTOMIZE_YOUR_TAG_DESCRIPTOR, {premiumProductName: getPremiumProductName()})}data-flx="user.my-profile-tab.username-section.premium-button.open">- <CrownIcon- weight="fill"- size={remFromPx(18)}- data-flx="user.my-profile-tab.username-section.crown-icon"- />+ <AtomIcon weight="fill" size={remFromPx(18)} data-flx="user.my-profile-tab.username-section.atom-icon" /></button></Tooltip>)}