🚨(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 { NotFoundScreen } from './components/NotFoundScreen'
import { routes } from './routes' import { routes } from './routes'
import './i18n/init' import './i18n/init'
import { silenceLiveKitLogs } from "@/utils/livekit.ts"; import { silenceLiveKitLogs } from '@/utils/livekit.ts'
import { queryClient } from "@/api/queryClient"; import { queryClient } from '@/api/queryClient'
function App() { function App() {
const { i18n } = useTranslation() 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() 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 { Center } from '@/styled-system/jsx'
import { Text } from '@/primitives' import { Text } from '@/primitives'
export const ErrorScreen = ({ title, body }: { export const ErrorScreen = ({
title,
body,
}: {
title?: string title?: string
body?: string body?: string
}) => { }) => {
@@ -4,5 +4,7 @@ export const authUrl = ({
silent = false, silent = false,
returnTo = window.location.href, 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 SILENT_LOGIN_RETRY_KEY = 'silent-login-retry'
const isRetryAllowed = () => { const isRetryAllowed = () => {
const lastRetryDate = localStorage.getItem(SILENT_LOGIN_RETRY_KEY); const lastRetryDate = localStorage.getItem(SILENT_LOGIN_RETRY_KEY)
if (!lastRetryDate) { if (!lastRetryDate) {
return true; return true
} }
const now = new Date(); const now = new Date()
return now.getTime() > Number(lastRetryDate) return now.getTime() > Number(lastRetryDate)
} }
const setNextRetryTime = (retryIntervalInSeconds: number) => { const setNextRetryTime = (retryIntervalInSeconds: number) => {
const now = new Date() const now = new Date()
const nextRetryTime = now.getTime() + (retryIntervalInSeconds * 1000); const nextRetryTime = now.getTime() + retryIntervalInSeconds * 1000
localStorage.setItem(SILENT_LOGIN_RETRY_KEY, String(nextRetryTime)); localStorage.setItem(SILENT_LOGIN_RETRY_KEY, String(nextRetryTime))
} }
const initiateSilentLogin = () => { const initiateSilentLogin = () => {
@@ -19,8 +19,8 @@ export const Home = () => {
navigateTo('room', data.slug, { navigateTo('room', data.slug, {
state: { create: true, initialRoomData: data }, state: { create: true, initialRoomData: data },
}) })
} },
}); })
return ( return (
<UserAware> <UserAware>
@@ -43,9 +43,9 @@ export const Home = () => {
onPress={ onPress={
isLoggedIn isLoggedIn
? async () => { ? async () => {
const slug = generateRoomId() const slug = generateRoomId()
await createRoom({slug}) await createRoom({ slug })
} }
: undefined : undefined
} }
href={isLoggedIn ? undefined : authUrl()} href={isLoggedIn ? undefined : authUrl()}
@@ -9,6 +9,6 @@ export type ApiRoom = {
token: string token: string
} }
configuration?: { configuration?: {
[key: string]: string | number | boolean; [key: string]: string | number | boolean
} }
} }
@@ -1,25 +1,26 @@
import { useMutation, UseMutationOptions } from "@tanstack/react-query"; import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import { fetchApi } from '@/api/fetchApi'; import { fetchApi } from '@/api/fetchApi'
import { ApiError } from "@/api/ApiError"; import { ApiError } from '@/api/ApiError'
import { ApiRoom } from "./ApiRoom"; import { ApiRoom } from './ApiRoom'
export interface CreateRoomParams { export interface CreateRoomParams {
slug: string; slug: string
} }
const createRoom = ({slug}: CreateRoomParams): Promise<ApiRoom> => { const createRoom = ({ slug }: CreateRoomParams): Promise<ApiRoom> => {
return fetchApi(`rooms/`, { return fetchApi(`rooms/`, {
method: 'POST', method: 'POST',
body: JSON.stringify({ body: JSON.stringify({
name: slug, name: slug,
}), }),
}) })
}; }
export function useCreateRoom(
export function useCreateRoom(options?: UseMutationOptions<ApiRoom, ApiError, CreateRoomParams>) { options?: UseMutationOptions<ApiRoom, ApiError, CreateRoomParams>
) {
return useMutation<ApiRoom, ApiError, CreateRoomParams>({ return useMutation<ApiRoom, ApiError, CreateRoomParams>({
mutationFn: createRoom, mutationFn: createRoom,
onSuccess: options?.onSuccess, onSuccess: options?.onSuccess,
}); })
} }
@@ -32,13 +32,21 @@ export const Conference = ({
}) => { }) => {
const fetchKey = [keys.room, roomId, userConfig.username] 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) => { onSuccess: (data) => {
queryClient.setQueryData(fetchKey, data) queryClient.setQueryData(fetchKey, data)
}, },
}); })
const { status: fetchStatus, isError: isFetchError, data } = useQuery({ const {
status: fetchStatus,
isError: isFetchError,
data,
} = useQuery({
queryKey: fetchKey, queryKey: fetchKey,
enabled: !initialRoomData, enabled: !initialRoomData,
initialData: initialRoomData, initialData: initialRoomData,
@@ -48,7 +56,7 @@ export const Conference = ({
username: userConfig.username, username: userConfig.username,
}).catch((error) => { }).catch((error) => {
if (error.statusCode == '404') { if (error.statusCode == '404') {
createRoom({slug: roomId}) createRoom({ slug: roomId })
} }
}), }),
retry: false, retry: false,
@@ -92,7 +100,12 @@ export const Conference = ({
const { t } = useTranslation('rooms') const { t } = useTranslation('rooms')
if (isCreateError) { if (isCreateError) {
// this error screen should be replaced by a proper waiting room for anonymous user. // 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 ( return (
@@ -106,9 +119,7 @@ export const Conference = ({
audio={userConfig.audioEnabled} audio={userConfig.audioEnabled}
video={userConfig.videoEnabled} video={userConfig.videoEnabled}
> >
<VideoConference <VideoConference chatMessageFormatter={formatChatMessageLinks} />
chatMessageFormatter={formatChatMessageLinks}
/>
{showInviteDialog && ( {showInviteDialog && (
<InviteDialog <InviteDialog
isOpen={showInviteDialog} isOpen={showInviteDialog}
@@ -8,7 +8,9 @@ export const FeedbackRoute = () => {
return ( return (
<Screen layout="centered"> <Screen layout="centered">
<CenteredContent title={t('feedback.heading')} withBackButton> <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> </CenteredContent>
</Screen> </Screen>
) )
+3 -1
View File
@@ -74,7 +74,9 @@ export const Header = () => {
{user.email} {user.email}
</Button> </Button>
<PopoverList <PopoverList
items={[{ key: 'logout', value: 'logout', label: t('logout') }]} items={[
{ key: 'logout', value: 'logout', label: t('logout') },
]}
onAction={(value) => { onAction={(value) => {
if (value === 'logout') { if (value === 'logout') {
window.location.href = logoutUrl() window.location.href = logoutUrl()
+1 -1
View File
@@ -42,7 +42,7 @@ export const PopoverList = <T extends string | number = string>({
}: { }: {
closeOnAction?: boolean closeOnAction?: boolean
onAction: (key: T) => void onAction: (key: T) => void
items: Array<string | { key: string, value: T; label: ReactNode }> items: Array<string | { key: string; value: T; label: ReactNode }>
} & ButtonProps) => { } & ButtonProps) => {
const popoverState = useContext(OverlayTriggerStateContext)! const popoverState = useContext(OverlayTriggerStateContext)!
return ( 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) => { export const silenceLiveKitLogs = (shouldSilenceLogs: boolean) => {
setLogLevel(shouldSilenceLogs ? LogLevel.silent : LogLevel.debug); setLogLevel(shouldSilenceLogs ? LogLevel.silent : LogLevel.debug)
} }