Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

refactor(app): untangle entrance sound and profile editor code

Hampusecdcf5c6046d
diff --git a/fluxer_app/src/features/user/components/modals/tabs/components/EntranceSoundSection.tsx b/fluxer_app/src/features/user/components/modals/tabs/components/EntranceSoundSection.tsx
index a9e247d17..d3513d780 100644
--- a/fluxer_app/src/features/user/components/modals/tabs/components/EntranceSoundSection.tsx
+++ b/fluxer_app/src/features/user/components/modals/tabs/components/EntranceSoundSection.tsx
@@ -40,9 +40,9 @@ import {MS_PER_SECOND} from '@fluxer/date_utils/src/DateConstants';
import {msg} from '@lingui/core/macro';
import {Trans, useLingui} from '@lingui/react/macro';
import {
+ AtomIcon,
ChatCircleTextIcon,
CheckIcon,
- CrownIcon,
GlobeHemisphereWestIcon,
type Icon,
SpeakerHighIcon,
@@ -428,270 +428,266 @@ export const EntranceSoundSection: React.FC = observer(() => {
[setSoundForScope],
);
- return (
- <div data-flx="user.entrance-sound-section.div">
- {!hasVoiceEntranceSounds ? (
- shouldShowPremiumFeatures() ? (
- <div className={styles.premiumCard} data-flx="user.entrance-sound-section.premium-card">
- <div className={styles.premiumCardHeader} data-flx="user.entrance-sound-section.premium-card-header">
- <CrownIcon
- weight="fill"
- size={18}
- className={styles.premiumCardIcon}
- data-flx="user.entrance-sound-section.premium-card-icon"
- />
- <span className={styles.premiumCardTitle} data-flx="user.entrance-sound-section.premium-card-title">
- {i18n._(CUSTOM_ENTRANCE_SOUNDS_PREMIUM_DESCRIPTOR, {
- premiumProductName: getPremiumProductName(),
- })}
- </span>
+ let sectionContent: React.ReactNode;
+ if (hasVoiceEntranceSounds) {
+ sectionContent = (
+ <div className={styles.content} data-flx="user.entrance-sound-section.content">
+ <section
+ className={styles.scopeSection}
+ aria-labelledby={scopePickerLabelId}
+ data-flx="user.entrance-sound-section.scope-section"
+ >
+ <div className={styles.scopeSectionHeader} data-flx="user.entrance-sound-section.scope-section-header">
+ <div className={styles.scopeSectionText} data-flx="user.entrance-sound-section.scope-section-text">
+ <div
+ id={scopePickerLabelId}
+ className={styles.scopeSectionLabel}
+ data-flx="user.entrance-sound-section.scope-section-label"
+ >
+ {i18n._(APPLIES_TO_DESCRIPTOR)}
+ </div>
+ <p className={styles.scopeHint} data-flx="user.entrance-sound-section.scope-hint">
+ {scopeHint}
+ </p>
</div>
- <p
- className={styles.premiumCardDescription}
- data-flx="user.entrance-sound-section.premium-card-description"
- >
- <Trans>
- Upload a custom sound that plays automatically when you join a voice channel. Maximum duration:{' '}
- {maxDurationSeconds} seconds. Max file size: {maxSizeLabel}.
- </Trans>
- </p>
- <Button
- variant="secondary"
- small={true}
- onClick={() => PremiumModalCommands.open()}
- data-flx="user.entrance-sound-section.button.open"
- >
- {i18n._(GET_PREMIUM_DESCRIPTOR, {premiumProductName: getPremiumProductName()})}
- </Button>
</div>
- ) : (
- <p
- className={styles.premiumCardDescription}
- data-flx="user.entrance-sound-section.premium-card-description--2"
- >
- <Trans>Custom entrance sounds are not enabled on this instance.</Trans>
- </p>
- )
- ) : (
- <div className={styles.content} data-flx="user.entrance-sound-section.content">
- <section
- className={styles.scopeSection}
+ <div
+ className={styles.scopeTileGrid}
+ role="group"
aria-labelledby={scopePickerLabelId}
- data-flx="user.entrance-sound-section.scope-section"
+ data-flx="user.entrance-sound-section.scope-tile-grid"
>
- <div className={styles.scopeSectionHeader} data-flx="user.entrance-sound-section.scope-section-header">
- <div className={styles.scopeSectionText} data-flx="user.entrance-sound-section.scope-section-text">
- <div
- id={scopePickerLabelId}
- className={styles.scopeSectionLabel}
- data-flx="user.entrance-sound-section.scope-section-label"
+ {scopeTileOptions.map((option) => (
+ <ScopeTileButton
+ key={option.value}
+ option={option}
+ selected={selectedScopeId === option.value}
+ onSelect={setSelectedScopeId}
+ dataFlx="user.entrance-sound-section.scope-tile"
+ data-flx="user.entrance-sound-section.scope-tile-button.set-selected-scope-id"
+ />
+ ))}
+ </div>
+ {communityScopeOptions.length > 0 ? (
+ <div className={styles.communityScopePanel} data-flx="user.entrance-sound-section.community-scope-panel">
+ <div
+ className={styles.communityScopeHeader}
+ data-flx="user.entrance-sound-section.community-scope-header"
+ >
+ <span
+ className={styles.communityScopeTitle}
+ data-flx="user.entrance-sound-section.community-scope-title"
>
- {i18n._(APPLIES_TO_DESCRIPTOR)}
- </div>
- <p className={styles.scopeHint} data-flx="user.entrance-sound-section.scope-hint">
- {scopeHint}
- </p>
+ {i18n._(COMMUNITY_OVERRIDES_DESCRIPTOR)}
+ </span>
+ </div>
+ <div
+ className={styles.communityScopeList}
+ role="group"
+ aria-label={i18n._(COMMUNITY_OVERRIDES_DESCRIPTOR)}
+ data-flx="user.entrance-sound-section.community-scope-list"
+ >
+ {communityScopeOptions.map((option) => (
+ <ScopeTileButton
+ key={option.value}
+ option={option}
+ selected={selectedScopeId === option.value}
+ onSelect={setSelectedScopeId}
+ compact={true}
+ dataFlx="user.entrance-sound-section.community-scope-tile"
+ data-flx="user.entrance-sound-section.scope-tile-button.set-selected-scope-id--2"
+ />
+ ))}
</div>
</div>
- <div
- className={styles.scopeTileGrid}
- role="group"
- aria-labelledby={scopePickerLabelId}
- data-flx="user.entrance-sound-section.scope-tile-grid"
- >
- {scopeTileOptions.map((option) => (
- <ScopeTileButton
- key={option.value}
- option={option}
- selected={selectedScopeId === option.value}
- onSelect={setSelectedScopeId}
- dataFlx="user.entrance-sound-section.scope-tile"
- data-flx="user.entrance-sound-section.scope-tile-button.set-selected-scope-id"
- />
- ))}
- </div>
- {communityScopeOptions.length > 0 ? (
- <div className={styles.communityScopePanel} data-flx="user.entrance-sound-section.community-scope-panel">
- <div
- className={styles.communityScopeHeader}
- data-flx="user.entrance-sound-section.community-scope-header"
- >
- <span
- className={styles.communityScopeTitle}
- data-flx="user.entrance-sound-section.community-scope-title"
+ ) : null}
+ </section>
+ <div className={styles.controlPanel} data-flx="user.entrance-sound-section.control-panel">
+ <CompactComboboxRow<string, LibrarySoundOption>
+ label={i18n._(SOUND_FOR_THIS_SCOPE_DESCRIPTOR)}
+ value={selectedSound?.id ?? NONE_LIBRARY_VALUE}
+ options={librarySelectOptions}
+ onChange={handleLibrarySelectionChange}
+ controlWidth="large"
+ menuMinWidth={220}
+ dataFlx="user.entrance-sound-section.select--library"
+ data-flx="user.entrance-sound-section.compact-combobox-row.library-selection-change"
+ />
+ </div>
+ {resolvedSound ? (
+ <div className={styles.soundCard} data-flx="user.entrance-sound-section.sound-card">
+ <div className={styles.soundCardContent} data-flx="user.entrance-sound-section.sound-card-content">
+ <div className={styles.soundCardMain} data-flx="user.entrance-sound-section.sound-card-main">
+ <Tooltip text={i18n._(PREVIEW_SOUND_DESCRIPTOR)} data-flx="user.entrance-sound-section.tooltip">
+ <button
+ type="button"
+ onClick={() => void previewSound(resolvedSound.id)}
+ disabled={isPreviewing}
+ className={styles.previewButton}
+ aria-label={i18n._(PREVIEW_SOUND_DESCRIPTOR)}
+ data-flx="user.entrance-sound-section.preview-button"
>
- {i18n._(COMMUNITY_OVERRIDES_DESCRIPTOR)}
- </span>
- </div>
- <div
- className={styles.communityScopeList}
- role="group"
- aria-label={i18n._(COMMUNITY_OVERRIDES_DESCRIPTOR)}
- data-flx="user.entrance-sound-section.community-scope-list"
- >
- {communityScopeOptions.map((option) => (
- <ScopeTileButton
- key={option.value}
- option={option}
- selected={selectedScopeId === option.value}
- onSelect={setSelectedScopeId}
- compact={true}
- dataFlx="user.entrance-sound-section.community-scope-tile"
- data-flx="user.entrance-sound-section.scope-tile-button.set-selected-scope-id--2"
+ <SpeakerHighIcon
+ size={20}
+ weight="fill"
+ className={styles.previewIcon}
+ data-flx="user.entrance-sound-section.preview-icon"
/>
- ))}
+ </button>
+ </Tooltip>
+ <div className={styles.soundInfo} data-flx="user.entrance-sound-section.sound-info">
+ <span className={styles.soundFileName} data-flx="user.entrance-sound-section.sound-file-name">
+ {resolvedSound.name}
+ </span>
+ <span className={styles.soundDuration} data-flx="user.entrance-sound-section.sound-duration">
+ {formatSoundDuration(resolvedSound.durationMs, i18n.locale)}
+ </span>
</div>
</div>
- ) : null}
- </section>
- <div className={styles.controlPanel} data-flx="user.entrance-sound-section.control-panel">
- <CompactComboboxRow<string, LibrarySoundOption>
- label={i18n._(SOUND_FOR_THIS_SCOPE_DESCRIPTOR)}
- value={selectedSound?.id ?? NONE_LIBRARY_VALUE}
- options={librarySelectOptions}
- onChange={handleLibrarySelectionChange}
- controlWidth="large"
- menuMinWidth={220}
- dataFlx="user.entrance-sound-section.select--library"
- data-flx="user.entrance-sound-section.compact-combobox-row.library-selection-change"
- />
- </div>
- {resolvedSound ? (
- <div className={styles.soundCard} data-flx="user.entrance-sound-section.sound-card">
- <div className={styles.soundCardContent} data-flx="user.entrance-sound-section.sound-card-content">
- <div className={styles.soundCardMain} data-flx="user.entrance-sound-section.sound-card-main">
- <Tooltip text={i18n._(PREVIEW_SOUND_DESCRIPTOR)} data-flx="user.entrance-sound-section.tooltip">
- <button
- type="button"
- onClick={() => void previewSound(resolvedSound.id)}
- disabled={isPreviewing}
- className={styles.previewButton}
- aria-label={i18n._(PREVIEW_SOUND_DESCRIPTOR)}
- data-flx="user.entrance-sound-section.preview-button"
- >
- <SpeakerHighIcon
- size={20}
- weight="fill"
- className={styles.previewIcon}
- data-flx="user.entrance-sound-section.preview-icon"
- />
- </button>
- </Tooltip>
- <div className={styles.soundInfo} data-flx="user.entrance-sound-section.sound-info">
- <span className={styles.soundFileName} data-flx="user.entrance-sound-section.sound-file-name">
- {resolvedSound.name}
- </span>
- <span className={styles.soundDuration} data-flx="user.entrance-sound-section.sound-duration">
- {formatSoundDuration(resolvedSound.durationMs, i18n.locale)}
- </span>
- </div>
- </div>
- <div className={styles.soundStatus} data-flx="user.entrance-sound-section.sound-status">
- <span
- className={clsx(
- styles.scopeBadge,
- hasDirectOverride ? styles.scopeBadgeDirect : styles.scopeBadgeInherited,
- )}
- data-flx="user.entrance-sound-section.scope-badge"
- >
- {hasDirectOverride ? i18n._(SET_HERE_DESCRIPTOR) : i18n._(INHERITED_DESCRIPTOR)}
+ <div className={styles.soundStatus} data-flx="user.entrance-sound-section.sound-status">
+ <span
+ className={clsx(
+ styles.scopeBadge,
+ hasDirectOverride ? styles.scopeBadgeDirect : styles.scopeBadgeInherited,
+ )}
+ data-flx="user.entrance-sound-section.scope-badge"
+ >
+ {hasDirectOverride ? i18n._(SET_HERE_DESCRIPTOR) : i18n._(INHERITED_DESCRIPTOR)}
+ </span>
+ {hasInheritedSound && inheritedFromLabel ? (
+ <span className={styles.inheritedText} data-flx="user.entrance-sound-section.inherited-text">
+ {i18n._(INHERITED_FROM_DESCRIPTOR, {inheritedFromLabel})}
</span>
- {hasInheritedSound && inheritedFromLabel ? (
- <span className={styles.inheritedText} data-flx="user.entrance-sound-section.inherited-text">
- {i18n._(INHERITED_FROM_DESCRIPTOR, {inheritedFromLabel})}
- </span>
- ) : null}
- </div>
+ ) : null}
</div>
</div>
- ) : (
- <div className={styles.emptyState} data-flx="user.entrance-sound-section.empty-state">
- <div className={styles.emptyStateTitle} data-flx="user.entrance-sound-section.empty-state-title">
- <Trans comment="Empty-state title in entrance sound settings. The selected scope does not have its own entrance sound yet.">
- No entrance sound set here
- </Trans>
- </div>
+ </div>
+ ) : (
+ <div className={styles.emptyState} data-flx="user.entrance-sound-section.empty-state">
+ <div className={styles.emptyStateTitle} data-flx="user.entrance-sound-section.empty-state-title">
+ <Trans comment="Empty-state title in entrance sound settings. The selected scope does not have its own entrance sound yet.">
+ No entrance sound set here
+ </Trans>
</div>
- )}
- <div className={styles.actions} data-flx="user.entrance-sound-section.actions">
- <Button
- variant="primary"
- className={styles.actionButton}
- onClick={openUploadDialog}
- data-flx="user.entrance-sound-section.action-button.open-upload-dialog"
- >
- <div className={styles.uploadButtonContent} data-flx="user.entrance-sound-section.upload-button-content">
- <UploadIcon size={16} data-flx="user.entrance-sound-section.upload-icon" />
- <span data-flx="user.entrance-sound-section.span">{i18n._(UPLOAD_NEW_DESCRIPTOR)}</span>
- </div>
- </Button>
- <span className={styles.scopeHint} data-flx="user.entrance-sound-section.library-count">
- {i18n._(LIBRARY_COUNT_DESCRIPTOR, {count: library.length, max: ENTRANCE_SOUND_MAX_PER_USER})}
- </span>
</div>
- {library.length > 0 ? (
- <div className={styles.libraryList} data-flx="user.entrance-sound-section.library">
- {library.map((entry) => {
- const isActiveHere = selectedSound?.id === entry.id;
- return (
- <div key={entry.id} className={styles.soundCard} data-flx="user.entrance-sound-section.library-row">
- <div className={styles.soundCardContent} data-flx="user.entrance-sound-section.sound-card-content">
- <div className={styles.soundCardMain} data-flx="user.entrance-sound-section.sound-card-main">
- <Tooltip
- text={i18n._(PREVIEW_SOUND_DESCRIPTOR)}
- data-flx="user.entrance-sound-section.library-tooltip"
- >
- <button
- type="button"
- onClick={() => void previewSound(entry.id)}
- disabled={isPreviewing}
- className={styles.previewButton}
- aria-label={i18n._(PREVIEW_SOUND_DESCRIPTOR)}
- data-flx="user.entrance-sound-section.library-preview"
- >
- <SpeakerHighIcon
- size={18}
- weight="fill"
- className={styles.previewIcon}
- data-flx="user.entrance-sound-section.preview-icon"
- />
- </button>
- </Tooltip>
- <div className={styles.soundInfo} data-flx="user.entrance-sound-section.sound-info">
- <span className={styles.soundFileName} data-flx="user.entrance-sound-section.sound-file-name">
- {entry.name}
- </span>
- <span className={styles.soundDuration} data-flx="user.entrance-sound-section.sound-duration">
- {`${formatSoundDuration(entry.durationMs, i18n.locale)}${isActiveHere ? ` · ${i18n._(ACTIVE_BADGE_DESCRIPTOR)}` : ''}`}
- </span>
- </div>
- </div>
+ )}
+ <div className={styles.actions} data-flx="user.entrance-sound-section.actions">
+ <Button
+ variant="primary"
+ className={styles.actionButton}
+ onClick={openUploadDialog}
+ data-flx="user.entrance-sound-section.action-button.open-upload-dialog"
+ >
+ <div className={styles.uploadButtonContent} data-flx="user.entrance-sound-section.upload-button-content">
+ <UploadIcon size={16} data-flx="user.entrance-sound-section.upload-icon" />
+ <span data-flx="user.entrance-sound-section.span">{i18n._(UPLOAD_NEW_DESCRIPTOR)}</span>
+ </div>
+ </Button>
+ <span className={styles.scopeHint} data-flx="user.entrance-sound-section.library-count">
+ {i18n._(LIBRARY_COUNT_DESCRIPTOR, {count: library.length, max: ENTRANCE_SOUND_MAX_PER_USER})}
+ </span>
+ </div>
+ {library.length > 0 ? (
+ <div className={styles.libraryList} data-flx="user.entrance-sound-section.library">
+ {library.map((entry) => {
+ const isActiveHere = selectedSound?.id === entry.id;
+ return (
+ <div key={entry.id} className={styles.soundCard} data-flx="user.entrance-sound-section.library-row">
+ <div className={styles.soundCardContent} data-flx="user.entrance-sound-section.sound-card-content">
+ <div className={styles.soundCardMain} data-flx="user.entrance-sound-section.sound-card-main">
<Tooltip
- text={i18n._(DELETE_FROM_LIBRARY_DESCRIPTOR)}
- data-flx="user.entrance-sound-section.library-delete-tooltip"
+ text={i18n._(PREVIEW_SOUND_DESCRIPTOR)}
+ data-flx="user.entrance-sound-section.library-tooltip"
>
<button
type="button"
- onClick={() => void deleteSound(entry.id)}
- className={styles.deleteButton}
- aria-label={i18n._(DELETE_FROM_LIBRARY_DESCRIPTOR)}
- data-flx="user.entrance-sound-section.library-delete"
+ onClick={() => void previewSound(entry.id)}
+ disabled={isPreviewing}
+ className={styles.previewButton}
+ aria-label={i18n._(PREVIEW_SOUND_DESCRIPTOR)}
+ data-flx="user.entrance-sound-section.library-preview"
>
- <TrashIcon
- size={16}
- className={styles.deleteIcon}
- data-flx="user.entrance-sound-section.delete-icon"
+ <SpeakerHighIcon
+ size={18}
+ weight="fill"
+ className={styles.previewIcon}
+ data-flx="user.entrance-sound-section.preview-icon"
/>
</button>
</Tooltip>
+ <div className={styles.soundInfo} data-flx="user.entrance-sound-section.sound-info">
+ <span className={styles.soundFileName} data-flx="user.entrance-sound-section.sound-file-name">
+ {entry.name}
+ </span>
+ <span className={styles.soundDuration} data-flx="user.entrance-sound-section.sound-duration">
+ {`${formatSoundDuration(entry.durationMs, i18n.locale)}${isActiveHere ? ` · ${i18n._(ACTIVE_BADGE_DESCRIPTOR)}` : ''}`}
+ </span>
+ </div>
</div>
+ <Tooltip
+ text={i18n._(DELETE_FROM_LIBRARY_DESCRIPTOR)}
+ data-flx="user.entrance-sound-section.library-delete-tooltip"
+ >
+ <button
+ type="button"
+ onClick={() => void deleteSound(entry.id)}
+ className={styles.deleteButton}
+ aria-label={i18n._(DELETE_FROM_LIBRARY_DESCRIPTOR)}
+ data-flx="user.entrance-sound-section.library-delete"
+ >
+ <TrashIcon
+ size={16}
+ className={styles.deleteIcon}
+ data-flx="user.entrance-sound-section.delete-icon"
+ />
+ </button>
+ </Tooltip>
</div>
- );
- })}
- </div>
- ) : null}
+ </div>
+ );
+ })}
+ </div>
+ ) : null}
+ </div>
+ );
+ } else if (shouldShowPremiumFeatures()) {
+ sectionContent = (
+ <div className={styles.premiumCard} data-flx="user.entrance-sound-section.premium-card">
+ <div className={styles.premiumCardHeader} data-flx="user.entrance-sound-section.premium-card-header">
+ <AtomIcon
+ weight="fill"
+ size={18}
+ className={styles.premiumCardIcon}
+ data-flx="user.entrance-sound-section.premium-card-icon"
+ />
+ <span className={styles.premiumCardTitle} data-flx="user.entrance-sound-section.premium-card-title">
+ {i18n._(CUSTOM_ENTRANCE_SOUNDS_PREMIUM_DESCRIPTOR, {
+ premiumProductName: getPremiumProductName(),
+ })}
+ </span>
</div>
- )}
- </div>
- );
+ <p className={styles.premiumCardDescription} data-flx="user.entrance-sound-section.premium-card-description">
+ <Trans>
+ Upload a custom sound that plays automatically when you join a voice channel. Maximum duration:{' '}
+ {maxDurationSeconds} seconds. Max file size: {maxSizeLabel}.
+ </Trans>
+ </p>
+ <Button
+ variant="secondary"
+ small={true}
+ onClick={() => PremiumModalCommands.open()}
+ data-flx="user.entrance-sound-section.button.open"
+ >
+ {i18n._(GET_PREMIUM_DESCRIPTOR, {premiumProductName: getPremiumProductName()})}
+ </Button>
+ </div>
+ );
+ } else {
+ sectionContent = (
+ <p className={styles.premiumCardDescription} data-flx="user.entrance-sound-section.premium-card-description--2">
+ <Trans>Custom entrance sounds are not enabled on this instance.</Trans>
+ </p>
+ );
+ }
+ return <div data-flx="user.entrance-sound-section.div">{sectionContent}</div>;
});
diff --git a/fluxer_app/src/features/user/components/modals/tabs/my_profile_tab/AvatarUploader.tsx b/fluxer_app/src/features/user/components/modals/tabs/my_profile_tab/AvatarUploader.tsx
index 735ddbc55..a9392b91c 100644
--- a/fluxer_app/src/features/user/components/modals/tabs/my_profile_tab/AvatarUploader.tsx
+++ b/fluxer_app/src/features/user/components/modals/tabs/my_profile_tab/AvatarUploader.tsx
@@ -282,27 +282,30 @@ export function useChangeAvatarAction({
[processAvatarFile, showAvatarUploadError],
);
const handleAvatarUpload = useCallback(() => {
- const uploadHint = canUploadAnimatedAvatar
- ? formatImageUploadRecommendedHint(i18n, {
- formats: ANIMATED_IMAGE_FORMATS,
- maxSize: formatFileSize(i18n.locale, GlobalLimits.getAvatarMaxSize()),
- recommendedSize: AVATAR_RECOMMENDED_SIZE_LABEL,
- })
- : shouldShowPremiumFeatures()
- ? formatImageUploadRecommendedHintWithNote(i18n, {
- formats: STATIC_IMAGE_FORMATS,
- maxSize: formatFileSize(i18n.locale, GlobalLimits.getAvatarMaxSize()),
- recommendedSize: AVATAR_RECOMMENDED_SIZE_LABEL,
- note: i18n._(ANIMATED_AVATARS_REQUIRE_PREMIUM_NOTE_DESCRIPTOR, {
- animatedAvatarFormats: ANIMATED_AVATAR_FORMATS,
- premiumProductName: getPremiumProductName(),
- }),
- })
- : formatImageUploadRecommendedHint(i18n, {
- formats: STATIC_IMAGE_FORMATS,
- maxSize: formatFileSize(i18n.locale, GlobalLimits.getAvatarMaxSize()),
- recommendedSize: AVATAR_RECOMMENDED_SIZE_LABEL,
- });
+ let uploadHint: string;
+ if (canUploadAnimatedAvatar) {
+ uploadHint = formatImageUploadRecommendedHint(i18n, {
+ formats: ANIMATED_IMAGE_FORMATS,
+ maxSize: formatFileSize(i18n.locale, GlobalLimits.getAvatarMaxSize()),
+ recommendedSize: AVATAR_RECOMMENDED_SIZE_LABEL,
+ });
+ } else if (shouldShowPremiumFeatures()) {
+ uploadHint = formatImageUploadRecommendedHintWithNote(i18n, {
+ formats: STATIC_IMAGE_FORMATS,
+ maxSize: formatFileSize(i18n.locale, GlobalLimits.getAvatarMaxSize()),
+ recommendedSize: AVATAR_RECOMMENDED_SIZE_LABEL,
+ note: i18n._(ANIMATED_AVATARS_REQUIRE_PREMIUM_NOTE_DESCRIPTOR, {
+ animatedAvatarFormats: ANIMATED_AVATAR_FORMATS,
+ premiumProductName: getPremiumProductName(),
+ }),
+ });
+ } else {
+ uploadHint = formatImageUploadRecommendedHint(i18n, {
+ formats: STATIC_IMAGE_FORMATS,
+ maxSize: formatFileSize(i18n.locale, GlobalLimits.getAvatarMaxSize()),
+ recommendedSize: AVATAR_RECOMMENDED_SIZE_LABEL,
+ });
+ }
openAssetSourceModal({
title: i18n._(CHANGE_AVATAR_DESCRIPTOR),
uploadHint,
diff --git a/fluxer_app/src/features/user/components/modals/tabs/my_profile_tab/ProfileAssetCustomizationStateMachine.ts b/fluxer_app/src/features/user/components/modals/tabs/my_profile_tab/ProfileAssetCustomizationStateMachine.ts
index 813a011b0..599148b5d 100644
--- a/fluxer_app/src/features/user/components/modals/tabs/my_profile_tab/ProfileAssetCustomizationStateMachine.ts
+++ b/fluxer_app/src/features/user/components/modals/tabs/my_profile_tab/ProfileAssetCustomizationStateMachine.ts
@@ -41,7 +41,7 @@ export type ProfileAssetCustomizationEvent =
type ProfileAssetCustomizationStateValue = 'unhydrated' | 'clean' | 'dirty' | 'committed';
-export interface ProfileAssetCustomizationState extends ProfileAssetRemoteState {
+interface ProfileAssetCustomizationState extends ProfileAssetRemoteState {
readonly state: ProfileAssetCustomizationStateValue;
readonly initialMode: ProfileAssetMode;
readonly previewUrl: string | null;
@@ -109,7 +109,14 @@ export function createProfileAssetRemoteStateFromFlags(params: {
hasCustomAsset: boolean;
isUnset: boolean;
}): ProfileAssetRemoteState {
- const mode: ProfileAssetMode = params.isUnset ? 'unset' : params.hasCustomAsset ? 'custom' : 'inherit';
+ let mode: ProfileAssetMode;
+ if (params.isUnset) {
+ mode = 'unset';
+ } else if (params.hasCustomAsset) {
+ mode = 'custom';
+ } else {
+ mode = 'inherit';
+ }
return createProfileAssetRemoteState({
identityKey: params.identityKey,
mode,
@@ -218,10 +225,6 @@ const profileAssetCustomizationStateMachine = setup({
{guard: 'remoteIdentityChanged', target: 'clean', actions: 'applyRemote'},
{target: 'dirty'},
],
- 'asset.committed': {target: 'committed', actions: 'commitRemote'},
- 'asset.modeSelected': {target: 'routing', actions: 'selectMode'},
- 'asset.uploaded': {target: 'routing', actions: 'applyUpload'},
- 'asset.cleared': {target: 'routing', actions: 'clearAsset'},
},
},
committed: {
@@ -232,10 +235,6 @@ const profileAssetCustomizationStateMachine = setup({
{guard: 'remoteMatchesCurrent', target: 'clean', actions: 'applyRemote'},
{target: 'committed'},
],
- 'asset.committed': {target: 'committed', actions: 'commitRemote'},
- 'asset.modeSelected': {target: 'routing', actions: 'selectMode'},
- 'asset.uploaded': {target: 'routing', actions: 'applyUpload'},
- 'asset.cleared': {target: 'routing', actions: 'clearAsset'},
},
},
},
diff --git a/fluxer_app/src/features/user/components/popouts/UserProfileShared.tsx b/fluxer_app/src/features/user/components/popouts/UserProfileShared.tsx
index 4b7873f88..90e82a144 100644
--- a/fluxer_app/src/features/user/components/popouts/UserProfileShared.tsx
+++ b/fluxer_app/src/features/user/components/popouts/UserProfileShared.tsx
@@ -232,16 +232,18 @@ export const UserProfileTimezoneInfo: React.FC<{profile: Profile}> = observer(({
timeZone: 'UTC',
}).format(getDateAtOffset(now, timezoneOffset));
const offsetDifference = timezoneOffset - getViewerOffsetMinutes();
- const differenceText =
- offsetDifference === 0
- ? i18n._(SAME_TIME_AS_YOU_DESCRIPTOR)
- : offsetDifference > 0
- ? i18n._(TIME_AHEAD_OF_YOU_DESCRIPTOR, {
- duration: formatOffsetDifferenceDuration(i18n, offsetDifference),
- })
- : i18n._(TIME_BEHIND_YOU_DESCRIPTOR, {
- duration: formatOffsetDifferenceDuration(i18n, offsetDifference),
- });
+ let differenceText: string;
+ if (offsetDifference === 0) {
+ differenceText = i18n._(SAME_TIME_AS_YOU_DESCRIPTOR);
+ } else if (offsetDifference > 0) {
+ differenceText = i18n._(TIME_AHEAD_OF_YOU_DESCRIPTOR, {
+ duration: formatOffsetDifferenceDuration(i18n, offsetDifference),
+ });
+ } else {
+ differenceText = i18n._(TIME_BEHIND_YOU_DESCRIPTOR, {
+ duration: formatOffsetDifferenceDuration(i18n, offsetDifference),
+ });
+ }
return (
<div className={styles.timeZoneContainer} data-flx="user.user-profile-shared.user-profile-timezone-info.container">
<span className={styles.timeZoneTitle} data-flx="user.user-profile-shared.user-profile-timezone-info.title">
diff --git a/fluxer_app/src/features/user/state/CustomStatus.ts b/fluxer_app/src/features/user/state/CustomStatus.ts
index 34a2aa3a7..2af459e90 100644
--- a/fluxer_app/src/features/user/state/CustomStatus.ts
+++ b/fluxer_app/src/features/user/state/CustomStatus.ts
@@ -55,12 +55,10 @@ export function normalizeCustomStatus(status: CustomStatus | null | undefined):
const text = clampText(status.text);
const emojiId = trimToNonEmpty(status.emojiId);
const rawEmojiName = trimToNonEmpty(status.emojiName);
- const emojiName =
- rawEmojiName == null
- ? null
- : emojiId != null
- ? rawEmojiName
- : UnicodeEmojis.normalizeEmojiNameToSurrogate(rawEmojiName);
+ let emojiName: string | null = null;
+ if (rawEmojiName != null) {
+ emojiName = emojiId != null ? rawEmojiName : UnicodeEmojis.normalizeEmojiNameToSurrogate(rawEmojiName);
+ }
if (text == null && emojiId == null && emojiName == null) return null;
const normalized: CustomStatus = {
text,