♻️(frontend) refactor feedback redirect to global onDisconnect hook
Centralize disconnect handling to ensure all client-initiated disconnects trigger feedback page navigation. More extensible for future disconnect event routing needs, especially when errors happen.
This commit is contained in:
committed by
aleb_the_flash
parent
6b3e5d747a
commit
dac6bfe142
@@ -2,7 +2,7 @@ import { useEffect, useMemo, useState } from 'react'
|
|||||||
import { useQuery } from '@tanstack/react-query'
|
import { useQuery } from '@tanstack/react-query'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { LiveKitRoom } from '@livekit/components-react'
|
import { LiveKitRoom } from '@livekit/components-react'
|
||||||
import { Room, RoomOptions } from 'livekit-client'
|
import { DisconnectReason, Room, RoomOptions } from 'livekit-client'
|
||||||
import { keys } from '@/api/queryKeys'
|
import { keys } from '@/api/queryKeys'
|
||||||
import { queryClient } from '@/api/queryClient'
|
import { queryClient } from '@/api/queryClient'
|
||||||
import { Screen } from '@/layout/Screen'
|
import { Screen } from '@/layout/Screen'
|
||||||
@@ -17,6 +17,7 @@ import posthog from 'posthog-js'
|
|||||||
import { css } from '@/styled-system/css'
|
import { css } from '@/styled-system/css'
|
||||||
import { BackgroundProcessorFactory } from '../livekit/components/blur'
|
import { BackgroundProcessorFactory } from '../livekit/components/blur'
|
||||||
import { LocalUserChoices } from '@/stores/userChoices'
|
import { LocalUserChoices } from '@/stores/userChoices'
|
||||||
|
import { navigateTo } from '@/navigation/navigateTo'
|
||||||
|
|
||||||
export const Conference = ({
|
export const Conference = ({
|
||||||
roomId,
|
roomId,
|
||||||
@@ -124,6 +125,11 @@ export const Conference = ({
|
|||||||
className={css({
|
className={css({
|
||||||
backgroundColor: 'primaryDark.50 !important',
|
backgroundColor: 'primaryDark.50 !important',
|
||||||
})}
|
})}
|
||||||
|
onDisconnected={(e) => {
|
||||||
|
if (e == DisconnectReason.CLIENT_INITIATED) {
|
||||||
|
navigateTo('feedback')
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<VideoConference />
|
<VideoConference />
|
||||||
{showInviteDialog && (
|
{showInviteDialog && (
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { useConnectionState, useRoomContext } from '@livekit/components-react'
|
import { useConnectionState, useRoomContext } from '@livekit/components-react'
|
||||||
import { Button } from '@/primitives'
|
import { Button } from '@/primitives'
|
||||||
import { navigateTo } from '@/navigation/navigateTo'
|
|
||||||
import { RiPhoneFill } from '@remixicon/react'
|
import { RiPhoneFill } from '@remixicon/react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { ConnectionState } from 'livekit-client'
|
import { ConnectionState } from 'livekit-client'
|
||||||
@@ -21,9 +20,6 @@ export const LeaveButton = () => {
|
|||||||
.catch((e) =>
|
.catch((e) =>
|
||||||
console.error('An error occurred while disconnecting:', e)
|
console.error('An error occurred while disconnecting:', e)
|
||||||
)
|
)
|
||||||
.finally(() => {
|
|
||||||
navigateTo('feedback')
|
|
||||||
})
|
|
||||||
}}
|
}}
|
||||||
data-attr="controls-leave"
|
data-attr="controls-leave"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user