Skip to content

Commit 4a50e5e

Browse files
authored
refactor: simplify type definitions, clean up unused code, and improve encapsulation (#19610)
- Refactored component interfaces to remove unnecessary exports and limit scope (e.g., AvatarProps, ChannelAvatarProps, etc.) - Updated some interfaces to remove redundant HTML prop inheritance - Added missing props to AvatarWrapperProps for better flexibility and type safety - Removed unused imports, constants, and functions (e.g., localeConfig.ts, errorUtil.tsx) - Deleted unused index.ts in AppContainer component - Adjusted constant scopes to reduce visibility (e.g., timer constants in EnrollmentTimer.ts) - Streamlined imports and applied minor code style improvements
1 parent ce222c1 commit 4a50e5e

File tree

269 files changed

+373
-3772
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

269 files changed

+373
-3772
lines changed

src/script/E2EIdentity/EnrollmentTimer/EnrollmentTimer.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ import {CredentialType} from '@wireapp/core/lib/messagingProtocols/mls';
2323

2424
import {MLSStatuses, WireIdentity} from '../E2EIdentityVerification';
2525

26-
export const ONE_MINUTE = TimeInMillis.MINUTE;
27-
export const FIVE_MINUTES = TimeInMillis.MINUTE * 5;
28-
export const FIFTEEN_MINUTES = TimeInMillis.MINUTE * 15;
29-
export const ONE_HOUR = TimeInMillis.HOUR;
30-
export const FOUR_HOURS = TimeInMillis.HOUR * 4;
31-
export const ONE_DAY = TimeInMillis.DAY;
26+
const FIVE_MINUTES = TimeInMillis.MINUTE * 5;
27+
const FIFTEEN_MINUTES = TimeInMillis.MINUTE * 15;
28+
const ONE_HOUR = TimeInMillis.HOUR;
29+
const FOUR_HOURS = TimeInMillis.HOUR * 4;
30+
const ONE_DAY = TimeInMillis.DAY;
3231

3332
// message retention time on backend (hardcoded to 28 days)
3433
export const messageRetentionTime = 28 * TimeInMillis.DAY;

src/script/auth/component/AcceptNewsModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {t} from 'Util/LocalizerUtil';
2727

2828
import {Config} from '../../Config';
2929

30-
export interface Props extends React.HTMLProps<HTMLDivElement> {
30+
interface Props {
3131
onConfirm: (event: React.MouseEvent<HTMLButtonElement>) => void;
3232
onDecline: (event: React.MouseEvent<HTMLButtonElement>) => void;
3333
}

src/script/auth/component/AccountAlreadyExistsModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {t} from 'Util/LocalizerUtil';
2424

2525
import {buttonCss, containerCss, headerCss, linkCss} from './AccountAlreadyExistsModal.styles';
2626

27-
export interface AccountAlreadyExistsModalProps {
27+
interface AccountAlreadyExistsModalProps {
2828
onClose: () => void;
2929
}
3030

src/script/auth/component/ClientItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import {splitFingerprint} from 'Util/StringUtil';
4343
import {ValidationError} from '../module/action/ValidationError';
4444
import {parseError, parseValidationErrors} from '../util/errorUtil';
4545

46-
export interface Props extends HTMLProps<HTMLDivElement> {
46+
interface Props extends HTMLProps<HTMLDivElement> {
4747
client: RegisteredClient;
4848
onClick: (event: MouseEvent<HTMLDivElement> | KeyboardEvent) => void;
4949
onClientRemoval: (password?: string) => void;

src/script/auth/component/JoinGuestLinkPasswordModal.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
*/
1919

20-
import React, {useState} from 'react';
20+
import {FormEvent, useState} from 'react';
2121

2222
import {StatusCodes as HTTP_STATUS} from 'http-status-codes';
2323

@@ -35,16 +35,16 @@ export interface JoinGuestLinkPasswordModalProps {
3535
onClose: () => void;
3636
}
3737

38-
const JoinGuestLinkPasswordModal: React.FC<JoinGuestLinkPasswordModalProps> = ({
38+
const JoinGuestLinkPasswordModal = ({
3939
error,
4040
onClose,
4141
isLoading,
4242
conversationName,
4343
onSubmitPassword,
44-
}) => {
44+
}: JoinGuestLinkPasswordModalProps) => {
4545
const [passwordValue, setPasswordValue] = useState<string>('');
4646

47-
const onSubmit = (event: React.FormEvent<HTMLFormElement | HTMLButtonElement>) => {
47+
const onSubmit = (event: FormEvent<HTMLFormElement | HTMLButtonElement>) => {
4848
event.preventDefault();
4949
onSubmitPassword(passwordValue);
5050
};
@@ -70,7 +70,7 @@ const JoinGuestLinkPasswordModal: React.FC<JoinGuestLinkPasswordModalProps> = ({
7070
<Form
7171
name="guest-password-join-form"
7272
data-uie-name="guest-password-join-form"
73-
onSubmit={(event: React.FormEvent<HTMLFormElement>) => onSubmit(event)}
73+
onSubmit={(event: FormEvent<HTMLFormElement>) => onSubmit(event)}
7474
autoComplete="off"
7575
>
7676
<Input
@@ -98,7 +98,7 @@ const JoinGuestLinkPasswordModal: React.FC<JoinGuestLinkPasswordModalProps> = ({
9898
block
9999
type="button"
100100
disabled={!passwordValue}
101-
onClick={(event: React.FormEvent<HTMLButtonElement>) => onSubmit(event)}
101+
onClick={(event: FormEvent<HTMLButtonElement>) => onSubmit(event)}
102102
data-uie-name="guest-link-join-submit-button"
103103
>
104104
{t('guestLinkPasswordModal.joinConversation')}

src/script/auth/component/ProgressBar.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
*
1818
*/
1919

20-
import * as React from 'react';
20+
import type {CSSProperties} from 'react';
2121

2222
interface ProgressProps {
23-
error: boolean;
24-
percent: number;
25-
style?: React.CSSProperties;
2623
width: number;
24+
percent: number;
25+
error?: boolean;
26+
style?: CSSProperties;
2727
}
28+
2829
export const ProgressBar = ({width, percent, error, style}: ProgressProps) => {
2930
const progress = (percent / 100) * width;
3031

src/script/auth/component/WirelessContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ import {t} from 'Util/LocalizerUtil';
2929
import {Config} from '../../Config';
3030
import {EXTERNAL_ROUTE} from '../externalRoute';
3131

32-
export interface Props extends React.HTMLAttributes<HTMLDivElement> {
32+
interface WirelessContainerProps {
3333
children: React.ReactNode;
3434
onCookiePolicyBannerClose?: (event: React.MouseEvent<HTMLElement>) => void;
3535
showCookiePolicyBanner?: boolean;
3636
}
3737

38-
const WirelessContainer: React.FC<Props> = ({showCookiePolicyBanner, onCookiePolicyBannerClose, children}) => {
38+
const WirelessContainer = ({showCookiePolicyBanner, onCookiePolicyBannerClose, children}: WirelessContainerProps) => {
3939
return (
4040
<div
4141
style={{

src/script/auth/localeConfig.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,11 @@
1717
*
1818
*/
1919

20-
import {SupportedCurrency} from '@wireapp/api-client/lib/team/payment/';
21-
2220
import {UrlUtil} from '@wireapp/commons';
2321

2422
import {QUERY_KEY} from './route';
2523
import {supportedLocales as Locales} from './supportedLocales';
2624

27-
const DEFAULT_CURRENCY = SupportedCurrency.EUR;
2825
const DEFAULT_LANGUAGE = 'en-US';
2926

3027
function getLocale(): string {
@@ -35,10 +32,6 @@ export function currentLanguage(): string {
3532
return mapLanguage(UrlUtil.getURLParameter(QUERY_KEY.LANGUAGE) || getLocale());
3633
}
3734

38-
export function currentCurrency(): SupportedCurrency {
39-
return (UrlUtil.getURLParameter(QUERY_KEY.CURRENCY).toUpperCase() as SupportedCurrency) || DEFAULT_CURRENCY;
40-
}
41-
4235
export function normalizeLanguage(language: string = DEFAULT_LANGUAGE): string {
4336
const LANGUAGE_SHORTHAND_LENGTH = 2;
4437
return language.substring(0, LANGUAGE_SHORTHAND_LENGTH);

src/script/auth/page/ConversationJoin.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
*/
1919

20-
import React, {useEffect, useState} from 'react';
20+
import {useEffect, useState, useRef, FormEvent} from 'react';
2121

2222
import type {RegisterData} from '@wireapp/api-client/lib/auth';
2323
import {BackendErrorLabel} from '@wireapp/api-client/lib/http';
@@ -72,7 +72,7 @@ const ConversationJoinComponent = ({
7272
generalError,
7373
doGetAllClients,
7474
}: Props & ConnectedProps & DispatchProps) => {
75-
const nameInput = React.useRef<HTMLInputElement>(null);
75+
const nameInput = useRef<HTMLInputElement>(null);
7676

7777
const conversationHasPassword = conversationInfo?.has_password;
7878

@@ -205,7 +205,7 @@ const ConversationJoinComponent = ({
205205
}
206206
};
207207

208-
const checkNameValidity = async (event: React.FormEvent) => {
208+
const checkNameValidity = async (event: FormEvent) => {
209209
setIsTemporaryGuest(true);
210210
event.preventDefault();
211211
if (!nameInput.current) {

src/script/auth/page/SingleSignOnForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import {getEnterpriseLoginV2FF} from '../util/helpers';
4848
import {logoutReasonStrings} from '../util/logoutUtil';
4949
import {getSearchParams, SSO_CODE_PREFIX} from '../util/urlUtil';
5050

51-
export interface SingleSignOnFormProps extends React.HTMLAttributes<HTMLDivElement> {
51+
interface SingleSignOnFormProps {
5252
doLogin: (code: string) => Promise<void>;
5353
initialCode?: string;
5454
}

0 commit comments

Comments
 (0)