🎨(frontend) replace logical OR with nullish coalescing operator
Replace `||` operators and conditional checks with `??` where appropriate for safer null/undefined handling. Nullish coalescing only triggers for null/undefined values, preventing unexpected behavior with falsy values like 0 or empty strings.
This commit is contained in:
committed by
aleb_the_flash
parent
b265c3c7cb
commit
b058e6add9
@@ -14,7 +14,7 @@ export const AppInitialization = () => {
|
|||||||
support = {},
|
support = {},
|
||||||
silence_livekit_debug_logs = false,
|
silence_livekit_debug_logs = false,
|
||||||
custom_css_url = '',
|
custom_css_url = '',
|
||||||
} = data || {}
|
} = data ?? {}
|
||||||
|
|
||||||
useAnalytics(analytics)
|
useAnalytics(analytics)
|
||||||
useSupport(support)
|
useSupport(support)
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export const Avatar = ({
|
|||||||
style,
|
style,
|
||||||
...props
|
...props
|
||||||
}: AvatarProps) => {
|
}: AvatarProps) => {
|
||||||
const initial = name?.trim()?.charAt(0) || ''
|
const initial = name?.trim()?.charAt(0) ?? ''
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export const ErrorScreen = ({
|
|||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
return (
|
return (
|
||||||
<Screen layout="centered">
|
<Screen layout="centered">
|
||||||
<CenteredContent title={title || t('error.heading')} withBackButton>
|
<CenteredContent title={title ?? t('error.heading')} withBackButton>
|
||||||
{!!body && (
|
{!!body && (
|
||||||
<Center>
|
<Center>
|
||||||
<Text as="p" variant="h3" centered>
|
<Text as="p" variant="h3" centered>
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ export const Home = () => {
|
|||||||
</RightColumn>
|
</RightColumn>
|
||||||
</Columns>
|
</Columns>
|
||||||
<LaterMeetingDialog
|
<LaterMeetingDialog
|
||||||
roomId={laterRoomId || ''}
|
roomId={laterRoomId ?? ''}
|
||||||
onOpenChange={() => setLaterRoomId(null)}
|
onOpenChange={() => setLaterRoomId(null)}
|
||||||
/>
|
/>
|
||||||
</Screen>
|
</Screen>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ type useRaisedHandProps = {
|
|||||||
export function useRaisedHand({ participant }: useRaisedHandProps) {
|
export function useRaisedHand({ participant }: useRaisedHandProps) {
|
||||||
// fixme - refactor this part to rely on attributes
|
// fixme - refactor this part to rely on attributes
|
||||||
const { metadata } = useParticipantInfo({ participant })
|
const { metadata } = useParticipantInfo({ participant })
|
||||||
const parsedMetadata = JSON.parse(metadata || '{}')
|
const parsedMetadata = JSON.parse(metadata ?? '{}')
|
||||||
|
|
||||||
const toggleRaisedHand = () => {
|
const toggleRaisedHand = () => {
|
||||||
if (isLocal(participant)) {
|
if (isLocal(participant)) {
|
||||||
@@ -19,5 +19,5 @@ export function useRaisedHand({ participant }: useRaisedHandProps) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { isHandRaised: parsedMetadata.raised || false, toggleRaisedHand }
|
return { isHandRaised: parsedMetadata.raised ?? false, toggleRaisedHand }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export const SettingsDialog = (props: SettingsDialogProps) => {
|
|||||||
<P>
|
<P>
|
||||||
<Trans
|
<Trans
|
||||||
i18nKey="settings:account.currentlyLoggedAs"
|
i18nKey="settings:account.currentlyLoggedAs"
|
||||||
values={{ user: user?.full_name || user?.email }}
|
values={{ user: user?.full_name ?? user?.email }}
|
||||||
components={[<Badge />]}
|
components={[<Badge />]}
|
||||||
/>
|
/>
|
||||||
</P>
|
</P>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export const AccountTab = ({ id, onOpenChange }: AccountTabProps) => {
|
|||||||
const { saveUsername } = usePersistentUserChoices()
|
const { saveUsername } = usePersistentUserChoices()
|
||||||
const room = useRoomContext()
|
const room = useRoomContext()
|
||||||
const { user, isLoggedIn, logout } = useUser()
|
const { user, isLoggedIn, logout } = useUser()
|
||||||
const [name, setName] = useState(room?.localParticipant.name || '')
|
const [name, setName] = useState(room?.localParticipant.name ?? '')
|
||||||
|
|
||||||
const handleOnSubmit = () => {
|
const handleOnSubmit = () => {
|
||||||
if (room) room.localParticipant.setName(name)
|
if (room) room.localParticipant.setName(name)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export default defineConfig(({ mode }) => {
|
|||||||
plugins: [react(), tsconfigPaths()],
|
plugins: [react(), tsconfigPaths()],
|
||||||
server: {
|
server: {
|
||||||
port: parseInt(env.VITE_PORT) || 3000,
|
port: parseInt(env.VITE_PORT) || 3000,
|
||||||
host: env.VITE_HOST || 'localhost',
|
host: env.VITE_HOST ?? 'localhost',
|
||||||
allowedHosts: ['.nip.io'],
|
allowedHosts: ['.nip.io'],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user