🚨(frontend) run Prettier on the codebase

Ran Prettier on the entire codebase to fix formatting issues. My IDE was
previously misconfigured, causing most of these errors. The IDE configuration
has been corrected.
This commit is contained in:
lebaudantoine
2024-08-06 11:08:01 +02:00
committed by aleb_the_flash
parent 79519fef26
commit 0b6f58bf9c
13 changed files with 61 additions and 42 deletions
+2 -3
View File
@@ -10,9 +10,8 @@ import { Layout } from './layout/Layout'
import { NotFoundScreen } from './components/NotFoundScreen'
import { routes } from './routes'
import './i18n/init'
import { silenceLiveKitLogs } from "@/utils/livekit.ts";
import { queryClient } from "@/api/queryClient";
import { silenceLiveKitLogs } from '@/utils/livekit.ts'
import { queryClient } from '@/api/queryClient'
function App() {
const { i18n } = useTranslation()
+1 -1
View File
@@ -1,3 +1,3 @@
import { QueryClient } from "@tanstack/react-query";
import { QueryClient } from '@tanstack/react-query'
export const queryClient = new QueryClient()
+4 -1
View File
@@ -4,7 +4,10 @@ import { useTranslation } from 'react-i18next'
import { Center } from '@/styled-system/jsx'
import { Text } from '@/primitives'
export const ErrorScreen = ({ title, body }: {
export const ErrorScreen = ({
title,
body,
}: {
title?: string
body?: string
}) => {
@@ -4,5 +4,7 @@ export const authUrl = ({
silent = false,
returnTo = window.location.href,
} = {}) => {
return apiUrl(`/authenticate?silent=${encodeURIComponent(silent)}&returnTo=${encodeURIComponent(returnTo)}`)
return apiUrl(
`/authenticate?silent=${encodeURIComponent(silent)}&returnTo=${encodeURIComponent(returnTo)}`
)
}
@@ -1,20 +1,20 @@
import { authUrl } from "@/features/auth";
import { authUrl } from '@/features/auth'
const SILENT_LOGIN_RETRY_KEY = 'silent-login-retry'
const isRetryAllowed = () => {
const lastRetryDate = localStorage.getItem(SILENT_LOGIN_RETRY_KEY);
const lastRetryDate = localStorage.getItem(SILENT_LOGIN_RETRY_KEY)
if (!lastRetryDate) {
return true;
return true
}
const now = new Date();
const now = new Date()
return now.getTime() > Number(lastRetryDate)
}
const setNextRetryTime = (retryIntervalInSeconds: number) => {
const now = new Date()
const nextRetryTime = now.getTime() + (retryIntervalInSeconds * 1000);
localStorage.setItem(SILENT_LOGIN_RETRY_KEY, String(nextRetryTime));
const nextRetryTime = now.getTime() + retryIntervalInSeconds * 1000
localStorage.setItem(SILENT_LOGIN_RETRY_KEY, String(nextRetryTime))
}
const initiateSilentLogin = () => {
@@ -19,8 +19,8 @@ export const Home = () => {
navigateTo('room', data.slug, {
state: { create: true, initialRoomData: data },
})
}
});
},
})
return (
<UserAware>
@@ -43,9 +43,9 @@ export const Home = () => {
onPress={
isLoggedIn
? async () => {
const slug = generateRoomId()
await createRoom({slug})
}
const slug = generateRoomId()
await createRoom({ slug })
}
: undefined
}
href={isLoggedIn ? undefined : authUrl()}
@@ -9,6 +9,6 @@ export type ApiRoom = {
token: string
}
configuration?: {
[key: string]: string | number | boolean;
[key: string]: string | number | boolean
}
}
@@ -1,25 +1,26 @@
import { useMutation, UseMutationOptions } from "@tanstack/react-query";
import { fetchApi } from '@/api/fetchApi';
import { ApiError } from "@/api/ApiError";
import { ApiRoom } from "./ApiRoom";
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import { fetchApi } from '@/api/fetchApi'
import { ApiError } from '@/api/ApiError'
import { ApiRoom } from './ApiRoom'
export interface CreateRoomParams {
slug: string;
slug: string
}
const createRoom = ({slug}: CreateRoomParams): Promise<ApiRoom> => {
const createRoom = ({ slug }: CreateRoomParams): Promise<ApiRoom> => {
return fetchApi(`rooms/`, {
method: 'POST',
body: JSON.stringify({
name: slug,
}),
})
};
}
export function useCreateRoom(options?: UseMutationOptions<ApiRoom, ApiError, CreateRoomParams>) {
export function useCreateRoom(
options?: UseMutationOptions<ApiRoom, ApiError, CreateRoomParams>
) {
return useMutation<ApiRoom, ApiError, CreateRoomParams>({
mutationFn: createRoom,
onSuccess: options?.onSuccess,
});
})
}
@@ -32,13 +32,21 @@ export const Conference = ({
}) => {
const fetchKey = [keys.room, roomId, userConfig.username]
const { mutateAsync: createRoom, status: createStatus, isError: isCreateError} = useCreateRoom({
const {
mutateAsync: createRoom,
status: createStatus,
isError: isCreateError,
} = useCreateRoom({
onSuccess: (data) => {
queryClient.setQueryData(fetchKey, data)
},
});
})
const { status: fetchStatus, isError: isFetchError, data } = useQuery({
const {
status: fetchStatus,
isError: isFetchError,
data,
} = useQuery({
queryKey: fetchKey,
enabled: !initialRoomData,
initialData: initialRoomData,
@@ -48,7 +56,7 @@ export const Conference = ({
username: userConfig.username,
}).catch((error) => {
if (error.statusCode == '404') {
createRoom({slug: roomId})
createRoom({ slug: roomId })
}
}),
retry: false,
@@ -92,7 +100,12 @@ export const Conference = ({
const { t } = useTranslation('rooms')
if (isCreateError) {
// this error screen should be replaced by a proper waiting room for anonymous user.
return <ErrorScreen title={t('error.createRoom.heading')} body={t('error.createRoom.body')} />
return (
<ErrorScreen
title={t('error.createRoom.heading')}
body={t('error.createRoom.body')}
/>
)
}
return (
@@ -106,9 +119,7 @@ export const Conference = ({
audio={userConfig.audioEnabled}
video={userConfig.videoEnabled}
>
<VideoConference
chatMessageFormatter={formatChatMessageLinks}
/>
<VideoConference chatMessageFormatter={formatChatMessageLinks} />
{showInviteDialog && (
<InviteDialog
isOpen={showInviteDialog}
@@ -8,7 +8,9 @@ export const FeedbackRoute = () => {
return (
<Screen layout="centered">
<CenteredContent title={t('feedback.heading')} withBackButton>
<Text as="p" variant="h3" centered>{t('feedback.body')}</Text>
<Text as="p" variant="h3" centered>
{t('feedback.body')}
</Text>
</CenteredContent>
</Screen>
)
+3 -1
View File
@@ -74,7 +74,9 @@ export const Header = () => {
{user.email}
</Button>
<PopoverList
items={[{ key: 'logout', value: 'logout', label: t('logout') }]}
items={[
{ key: 'logout', value: 'logout', label: t('logout') },
]}
onAction={(value) => {
if (value === 'logout') {
window.location.href = logoutUrl()
+1 -1
View File
@@ -42,7 +42,7 @@ export const PopoverList = <T extends string | number = string>({
}: {
closeOnAction?: boolean
onAction: (key: T) => void
items: Array<string | { key: string, value: T; label: ReactNode }>
items: Array<string | { key: string; value: T; label: ReactNode }>
} & ButtonProps) => {
const popoverState = useContext(OverlayTriggerStateContext)!
return (
+2 -3
View File
@@ -1,6 +1,5 @@
import { LogLevel, setLogLevel } from "livekit-client";
import { LogLevel, setLogLevel } from 'livekit-client'
export const silenceLiveKitLogs = (shouldSilenceLogs: boolean) => {
setLogLevel(shouldSilenceLogs ? LogLevel.silent : LogLevel.debug);
setLogLevel(shouldSilenceLogs ? LogLevel.silent : LogLevel.debug)
}