Skip to content

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

TypeScript fluxerfluxerapp

refactor(app): unexport file-local values, drop an unused hook

Hampusac6212f392c0
diff --git a/fluxer_app/src/features/auth/components/accounts/AccountIdentity.tsx b/fluxer_app/src/features/auth/components/accounts/AccountIdentity.tsx
index 8f295be49..4a7f6c962 100644
--- a/fluxer_app/src/features/auth/components/accounts/AccountIdentity.tsx
+++ b/fluxer_app/src/features/auth/components/accounts/AccountIdentity.tsx
@@ -8,7 +8,6 @@ import {
import type {Account} from '@app/features/platform/state/AuthSession';
import {useLingui} from '@lingui/react/macro';
import type React from 'react';
-import {useCallback} from 'react';
interface AccountDisplayIdentityView {
readonly isAvailable: boolean;
@@ -48,18 +47,6 @@ export function useAccountDisplayIdentityView(account: Account): AccountDisplayI
);
}
-export function useAccountDisplayIdentityViewFormatter(): (account: Account) => AccountDisplayIdentityView {
- const {i18n} = useLingui();
- return useCallback(
- (account: Account) =>
- createAccountDisplayIdentityView(
- getAccountDisplayLabels(account),
- i18n._(ACCOUNT_DETAILS_UNAVAILABLE_DESCRIPTOR),
- ),
- [i18n],
- );
-}
-
interface AccountIdentityTextProps {
readonly identityView: AccountDisplayIdentityView;
readonly discriminatorClassName: string;
diff --git a/fluxer_app/src/features/auth/components/pages/oauth_authorize_page/hooks/useBotInviteDestinations.ts b/fluxer_app/src/features/auth/components/pages/oauth_authorize_page/hooks/useBotInviteDestinations.ts
index 80fc2e8c0..476f5845f 100644
--- a/fluxer_app/src/features/auth/components/pages/oauth_authorize_page/hooks/useBotInviteDestinations.ts
+++ b/fluxer_app/src/features/auth/components/pages/oauth_authorize_page/hooks/useBotInviteDestinations.ts
@@ -35,7 +35,7 @@ const UNKNOWN_GROUP_DM_DESCRIPTOR = msg({
comment: 'Fallback label in the authentication bot invite destination selector for an unnamed group DM.',
});
-export type BotGuildsStatus = 'idle' | 'loading' | 'ready' | 'error';
+type BotGuildsStatus = 'idle' | 'loading' | 'ready' | 'error';
export type BotInviteDestinationKind = 'guild' | 'group_dm';
export interface BotInviteDestinationOption extends GuildComboboxOption {
@@ -54,7 +54,7 @@ export interface BotInviteDestinationsResult {
error: string | null;
}
-export function mapBotGuilds(
+function mapBotGuilds(
guilds: ReadonlyArray<GuildSummary>,
requestedPermissions: bigint,
unknownCommunityLabel: string,
diff --git a/fluxer_app/src/features/auth/flow/auth_login_core/AuthLoginEmailPasswordForm.tsx b/fluxer_app/src/features/auth/flow/auth_login_core/AuthLoginEmailPasswordForm.tsx
index 7a9532b48..6051e186f 100644
--- a/fluxer_app/src/features/auth/flow/auth_login_core/AuthLoginEmailPasswordForm.tsx
+++ b/fluxer_app/src/features/auth/flow/auth_login_core/AuthLoginEmailPasswordForm.tsx
@@ -23,7 +23,7 @@ export interface AuthFormControllerLike {
isSubmitting?: boolean;
}
-export interface AuthEmailPasswordFormClasses {
+interface AuthEmailPasswordFormClasses {
form: string;
}
@@ -33,7 +33,6 @@ interface Props {
fieldErrors?: FieldErrors;
submitLabel: React.ReactNode;
classes: AuthEmailPasswordFormClasses;
- extraFields?: React.ReactNode;
links?: React.ReactNode;
linksWrapperClassName?: string;
disableSubmit?: boolean;
@@ -48,7 +47,6 @@ export default function AuthLoginEmailPasswordForm({
fieldErrors,
submitLabel,
classes,
- extraFields,
links,
linksWrapperClassName,
disableSubmit,
@@ -99,7 +97,6 @@ export default function AuthLoginEmailPasswordForm({
error={form.getError('password') || fieldErrors?.get('password')}
data-flx="auth.flow.auth-login-core.auth-login-email-password-form.form-field.set-value.password"
/>
- {extraFields}
{links ? (
<div className={linksWrapperClassName} data-flx="auth.flow.auth-login-core.auth-login-email-password-form.div">
{links}
diff --git a/fluxer_app/src/features/auth/flow/auth_login_core/useAuthLoginFlow.ts b/fluxer_app/src/features/auth/flow/auth_login_core/useAuthLoginFlow.ts
index 7fad673ba..08025aaa3 100644
--- a/fluxer_app/src/features/auth/flow/auth_login_core/useAuthLoginFlow.ts
+++ b/fluxer_app/src/features/auth/flow/auth_login_core/useAuthLoginFlow.ts
@@ -3,11 +3,11 @@
import {AuthLoginStep} from '@app/features/auth/flow/auth_login_core/AuthLoginStepTypes';
import {startTransition, useMemo, useReducer} from 'react';
-export type CredentialsBackTarget = typeof AuthLoginStep.ACCOUNT | typeof AuthLoginStep.METHOD;
+type CredentialsBackTarget = typeof AuthLoginStep.ACCOUNT | typeof AuthLoginStep.METHOD;
-export type MethodBackTarget = typeof AuthLoginStep.ACCOUNT | typeof AuthLoginStep.INSTANCE;
+type MethodBackTarget = typeof AuthLoginStep.ACCOUNT | typeof AuthLoginStep.INSTANCE;
-export interface AuthLoginFlowState {
+interface AuthLoginFlowState {
showAccountSelector: boolean;
hasCompletedInstanceStep: boolean;
hasSelectedLoginMethod: boolean;
@@ -18,7 +18,7 @@ export interface AuthLoginFlowState {
error: string | null;
}
-export interface AuthLoginFlowSync {
+interface AuthLoginFlowSync {
startWithAddAccount: boolean;
forceCredentials: boolean;
initialIdentifier: string | null;
@@ -68,7 +68,7 @@ function initialAuthLoginFlowState(init: AuthLoginFlowInit): AuthLoginFlowState
};
}
-export type AuthLoginFlowAction =
+type AuthLoginFlowAction =
| {type: 'syncFromProps'; sync: AuthLoginFlowSync}
| {
type: 'showFormForAccount';
diff --git a/fluxer_app/src/features/auth/flow/auth_login_core/useDesktopHandoffFlow.ts b/fluxer_app/src/features/auth/flow/auth_login_core/useDesktopHandoffFlow.ts
index e07e6e47c..e6a2a6d37 100644
--- a/fluxer_app/src/features/auth/flow/auth_login_core/useDesktopHandoffFlow.ts
+++ b/fluxer_app/src/features/auth/flow/auth_login_core/useDesktopHandoffFlow.ts
@@ -60,7 +60,7 @@ export interface DesktopHandoffRequest {
readonly identifier: string | null;
}
-export function readDesktopHandoffRequest(search: string): DesktopHandoffRequest {
+function readDesktopHandoffRequest(search: string): DesktopHandoffRequest {
const params = new URLSearchParams(search);
const code = parseDesktopHandoffCode(params.get('code') ?? '');
return {
diff --git a/fluxer_app/src/features/auth/flow/browser_handoff/BrowserLoginHandoffTransport.ts b/fluxer_app/src/features/auth/flow/browser_handoff/BrowserLoginHandoffTransport.ts
index 73bb923ee..22aad8b29 100644
--- a/fluxer_app/src/features/auth/flow/browser_handoff/BrowserLoginHandoffTransport.ts
+++ b/fluxer_app/src/features/auth/flow/browser_handoff/BrowserLoginHandoffTransport.ts
@@ -20,19 +20,19 @@ export interface BrowserLoginHandoffSession {
readonly target: BrowserLoginHandoffTarget;
}
-export interface BrowserLoginHandoffStatusResult {
+interface BrowserLoginHandoffStatusResult {
readonly status: DesktopHandoffStatus;
readonly token: string | null;
readonly userId: string | null;
readonly userData: UserData | undefined;
}
-export const BrowserLoginHandoffTransportKind = Object.freeze({
+const BrowserLoginHandoffTransportKind = Object.freeze({
IPC: 'ipc',
RENDERER: 'renderer',
} as const);
-export type BrowserLoginHandoffTransportKind =
+type BrowserLoginHandoffTransportKind =
(typeof BrowserLoginHandoffTransportKind)[keyof typeof BrowserLoginHandoffTransportKind];
export interface BrowserLoginHandoffTransport {
diff --git a/fluxer_app/src/features/auth/flow/client_intro/DesktopClientIntroStateMachine.ts b/fluxer_app/src/features/auth/flow/client_intro/DesktopClientIntroStateMachine.ts
index c5356a626..4797dcbc0 100644
--- a/fluxer_app/src/features/auth/flow/client_intro/DesktopClientIntroStateMachine.ts
+++ b/fluxer_app/src/features/auth/flow/client_intro/DesktopClientIntroStateMachine.ts
@@ -13,7 +13,7 @@ import {
transition,
} from 'xstate';
-export const DesktopClientIntroStage = Object.freeze({
+const DesktopClientIntroStage = Object.freeze({
INACTIVE: 'inactive',
WELCOME: 'welcome',
PREFERENCES: 'preferences',
@@ -21,7 +21,7 @@ export const DesktopClientIntroStage = Object.freeze({
COMPLETE: 'complete',
} as const);
-export type DesktopClientIntroStage = (typeof DesktopClientIntroStage)[keyof typeof DesktopClientIntroStage];
+type DesktopClientIntroStage = (typeof DesktopClientIntroStage)[keyof typeof DesktopClientIntroStage];
export interface DesktopClientIntroConditions {
enabled: boolean;
diff --git a/fluxer_app/src/features/auth/state/AccountStorageKey.ts b/fluxer_app/src/features/auth/state/AccountStorageKey.ts
index 381b8c425..e81e52dd4 100644
--- a/fluxer_app/src/features/auth/state/AccountStorageKey.ts
+++ b/fluxer_app/src/features/auth/state/AccountStorageKey.ts
@@ -2,8 +2,8 @@
import {type RuntimeConfigSnapshot, runtimeInstanceKey} from '@app/features/app/state/InstanceSnapshotStore';
-export const ACCOUNT_STORAGE_KEY_SEPARATOR = '::';
-export const ACCOUNT_STORAGE_KEY_MAX_BYTES = 1024;
+const ACCOUNT_STORAGE_KEY_SEPARATOR = '::';
+const ACCOUNT_STORAGE_KEY_MAX_BYTES = 1024;
const TEXT_ENCODER = new TextEncoder();
diff --git a/fluxer_app/src/features/auth/state/Authentication.ts b/fluxer_app/src/features/auth/state/Authentication.ts
index 87f494c77..7311ffbe6 100644
--- a/fluxer_app/src/features/auth/state/Authentication.ts
+++ b/fluxer_app/src/features/auth/state/Authentication.ts
@@ -22,7 +22,7 @@ export const LoginState = Object.freeze({
export type LoginState = (typeof LoginState)[keyof typeof LoginState];
-export interface MfaMethods {
+interface MfaMethods {
totp: boolean;
webauthn: boolean;
backupCodes: boolean;
diff --git a/fluxer_app/src/features/auth/state/SsoPendingContext.ts b/fluxer_app/src/features/auth/state/SsoPendingContext.ts
index d45c1270f..104c5c91f 100644
--- a/fluxer_app/src/features/auth/state/SsoPendingContext.ts
+++ b/fluxer_app/src/features/auth/state/SsoPendingContext.ts
@@ -14,7 +14,7 @@ const PENDING_SSO_CONTEXT_JSON_MAX_LENGTH = 262_144;
const OAUTH_STATE_MAX_LENGTH = 512;
const STORED_SSO_PENDING_CONTEXT_KEYS: ReadonlyArray<string> = ['createdAtMs', 'expiresAtMs', 'instance', 'redirectTo'];
-export const LEGACY_SSO_REDIRECT_TO_STORAGE_KEY = 'fluxer:sso:redirect_to';
+const LEGACY_SSO_REDIRECT_TO_STORAGE_KEY = 'fluxer:sso:redirect_to';
const logger = new Logger('SsoPendingContext');
@@ -45,7 +45,7 @@ function readLegacySsoRedirectTo(): string | null {
}
}
-export function clearLegacySsoRedirectTo(): void {
+function clearLegacySsoRedirectTo(): void {
const storage = getProtectedSessionStorage();
if (storage === null) {
return;
diff --git a/fluxer_app/src/features/invite/utils/InviteOtherAccountLookup.ts b/fluxer_app/src/features/invite/utils/InviteOtherAccountLookup.ts
index 4805a498a..4515ef904 100644
--- a/fluxer_app/src/features/invite/utils/InviteOtherAccountLookup.ts
+++ b/fluxer_app/src/features/invite/utils/InviteOtherAccountLookup.ts
@@ -11,7 +11,7 @@ import type {Invite} from '@fluxer/schema/src/domains/invite/InviteSchemas';
const INVITE_LOOKUP_TIMEOUT_MS = 10_000;
-export interface InviteLookupCandidate {
+interface InviteLookupCandidate {
readonly account: Account;
readonly target: InstanceHTTPTarget;
}
diff --git a/fluxer_app/src/features/user/components/modals/tabs/AccessibilityTab.tsx b/fluxer_app/src/features/user/components/modals/tabs/AccessibilityTab.tsx
index d7a267cdd..3cde058bf 100644
--- a/fluxer_app/src/features/user/components/modals/tabs/AccessibilityTab.tsx
+++ b/fluxer_app/src/features/user/components/modals/tabs/AccessibilityTab.tsx
@@ -217,7 +217,7 @@ const AccessibilityTabPreview = observer(() => {
</div>
);
});
-export const AccessibilityScreenReaderTabContent: React.FC = observer(() => {
+const AccessibilityScreenReaderTabContent: React.FC = observer(() => {
const {i18n} = useLingui();
return (
<Switch
@@ -229,7 +229,7 @@ export const AccessibilityScreenReaderTabContent: React.FC = observer(() => {
/>
);
});
-export const AccessibilityTtsTabContent: React.FC = observer(() => {
+const AccessibilityTtsTabContent: React.FC = observer(() => {
const {i18n} = useLingui();
const ttsRate = Accessibility.ttsRate;
const selectedTtsRate = getNearestTtsRate(ttsRate);
@@ -278,6 +278,14 @@ export const AccessibilityTtsTabContent: React.FC = observer(() => {
TtsUtils.stop();
};
}, []);
+ let previewDescription: string;
+ if (!synthesisSupported) {
+ previewDescription = i18n._(SPEECH_SYNTHESIS_IS_UNAVAILABLE_IN_YOUR_BROWSER_DESCRIPTOR);
+ } else if (playbackError) {
+ previewDescription = i18n._(SPEECH_PLAYBACK_FAILED_TRY_AGAIN_OR_CHECK_THAT_DESCRIPTOR);
+ } else {
+ previewDescription = i18n._(HEAR_THE_SAMPLE_LINE_SPOKEN_WITH_YOUR_CHOSEN_DESCRIPTOR);
+ }
return (
<div className={styles.ttsSection} data-flx="user.accessibility-tab.accessibility-tts-tab-content.tts-section">
<CompactComboboxRow<number>
@@ -323,11 +331,7 @@ export const AccessibilityTtsTabContent: React.FC = observer(() => {
className={styles.ttsPreviewDescription}
data-flx="user.accessibility-tab.accessibility-tts-tab-content.tts-preview-description"
>
- {!synthesisSupported
- ? i18n._(SPEECH_SYNTHESIS_IS_UNAVAILABLE_IN_YOUR_BROWSER_DESCRIPTOR)
- : playbackError
- ? i18n._(SPEECH_PLAYBACK_FAILED_TRY_AGAIN_OR_CHECK_THAT_DESCRIPTOR)
- : i18n._(HEAR_THE_SAMPLE_LINE_SPOKEN_WITH_YOUR_CHOSEN_DESCRIPTOR)}
+ {previewDescription}
</p>
</div>
</div>
diff --git a/fluxer_app/src/features/user/state/StatusPage.ts b/fluxer_app/src/features/user/state/StatusPage.ts
index efc7b8530..1c32f33a9 100644
--- a/fluxer_app/src/features/user/state/StatusPage.ts
+++ b/fluxer_app/src/features/user/state/StatusPage.ts
@@ -8,7 +8,7 @@ type IncidentStatus = 'investigating' | 'identified' | 'monitoring' | 'resolved'
type IncidentImpact = 'critical' | 'major' | 'minor' | 'maintenance';
export type MaintenanceStatus = 'scheduled' | 'in_progress' | 'completed';
-export interface StatusPageIncident {
+interface StatusPageIncident {
id: string;
name: string;
status: IncidentStatus;
@@ -82,8 +82,8 @@ interface InstatusComponent {
type InstatusComponentsResponse = Array<InstatusComponent> | {components?: Array<InstatusComponent>};
const logger = new Logger('StatusPage');
-export const STATUS_PAGE_POLL_INTERVAL_MS = 60 * 1000;
-export const STATUS_PAGE_POLL_JITTER_MS = 15 * 1000;
+const STATUS_PAGE_POLL_INTERVAL_MS = 60 * 1000;
+const STATUS_PAGE_POLL_JITTER_MS = 15 * 1000;
const POLL_ACTIVE_MAINTENANCE_INTERVAL_MS = 60 * 1000;
const POLL_ACTIVE_MAINTENANCE_JITTER_MS = 15 * 1000;
const POLL_AFTER_MAINTENANCE_START_MS = 5 * 1000;
@@ -95,7 +95,7 @@ function statusPageFetchOptions(): RequestInit {
return {cache: 'no-store', signal: AbortSignal.timeout(STATUS_PAGE_FETCH_TIMEOUT_MS)};
}
-export function computePollDelay(scheduledMaintenance: StatusPageMaintenance | null): number {
+function computePollDelay(scheduledMaintenance: StatusPageMaintenance | null): number {
if (scheduledMaintenance?.status === 'in_progress') {
return POLL_ACTIVE_MAINTENANCE_INTERVAL_MS + Math.random() * POLL_ACTIVE_MAINTENANCE_JITTER_MS;
}
@@ -114,7 +114,7 @@ export function computePollDelay(scheduledMaintenance: StatusPageMaintenance | n
return STATUS_PAGE_POLL_INTERVAL_MS + Math.random() * STATUS_PAGE_POLL_JITTER_MS;
}
-export function parseMaintenanceDurationMinutes(duration: string | number | null | undefined): number | null {
+function parseMaintenanceDurationMinutes(duration: string | number | null | undefined): number | null {
if (duration == null) {
return null;
}
@@ -156,7 +156,7 @@ function getMaintenanceStatusPriority(status: MaintenanceStatus): number {
}
}
-export function selectActiveStatusPageMaintenance(
+function selectActiveStatusPageMaintenance(
maintenances: ReadonlyArray<InstatusMaintenance> | null | undefined,
): StatusPageMaintenance | null {
let selectedMaintenance: StatusPageMaintenance | null = null;
@@ -188,7 +188,7 @@ function extractComponentMaintenances(data: InstatusComponentsResponse): Array<I
return components.flatMap((component) => component.activeMaintenances ?? []);
}
-export class StatusPage {
+class StatusPage {
incident: StatusPageIncident | null = null;
scheduledMaintenance: StatusPageMaintenance | null = null;
pollTimerId: NodeJS.Timeout | null = null;
diff --git a/fluxer_app/src/features/user/utils/NicknameUtils.ts b/fluxer_app/src/features/user/utils/NicknameUtils.ts
index b1a0a9efa..0af6334b5 100644
--- a/fluxer_app/src/features/user/utils/NicknameUtils.ts
+++ b/fluxer_app/src/features/user/utils/NicknameUtils.ts
@@ -54,7 +54,7 @@ export function getNickname(user: User, guildId?: string | null, channelId?: str
return formatNicknameForStreamerMode(getUntruncatedNickname(user, guildId, channelId));
}
-export function truncateStreamerModeName(name: string): string {
+function truncateStreamerModeName(name: string): string {
const trimmed = name.trim();
if (!trimmed) return '…';
return `${Array.from(trimmed)[0]}…`;