Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

refactor(app): flatten ternaries in voice components

Hampus3bb8813cefd2
diff --git a/fluxer_app/src/features/voice/components/EntranceSoundTrimmerModal.tsx b/fluxer_app/src/features/voice/components/EntranceSoundTrimmerModal.tsx
index 92e011d5a..cac2d85b0 100644
--- a/fluxer_app/src/features/voice/components/EntranceSoundTrimmerModal.tsx
+++ b/fluxer_app/src/features/voice/components/EntranceSoundTrimmerModal.tsx
@@ -274,6 +274,73 @@ const EntranceSoundTrimmerModal: React.FC<EntranceSoundTrimmerModalProps> = obse
const selectionTooShort = selectionDuration < MIN_DURATION_SECONDS;
const selectionTooLong = selectionDuration > MAX_DURATION_SECONDS + 0.001;
+ let trimmerBody: React.ReactNode;
+ if (decodeError) {
+ trimmerBody = (
+ <p className={styles.errorText} data-flx="voice.entrance-sound-trimmer-modal.decode-error">
+ {decodeError}
+ </p>
+ );
+ } else if (!audioBuffer || !peaks) {
+ trimmerBody = (
+ <div className={styles.spinnerWrap} data-flx="voice.entrance-sound-trimmer-modal.spinner-wrap">
+ <Spinner data-flx="voice.entrance-sound-trimmer-modal.spinner" />
+ </div>
+ );
+ } else {
+ trimmerBody = (
+ <>
+ <AudioWaveform
+ peaks={peaks}
+ durationSeconds={totalDuration}
+ startSeconds={startSeconds}
+ endSeconds={endSeconds}
+ minSelectionSeconds={MIN_DURATION_SECONDS}
+ maxSelectionSeconds={MAX_DURATION_SECONDS}
+ playheadSeconds={playheadSeconds}
+ onSelectionChange={handleSelectionChange}
+ data-flx="voice.entrance-sound-trimmer-modal.waveform"
+ />
+ <div className={styles.meta} data-flx="voice.entrance-sound-trimmer-modal.meta">
+ <span
+ className={selectionTooShort || selectionTooLong ? styles.metaWarning : undefined}
+ data-flx="voice.entrance-sound-trimmer-modal.selection-meta"
+ >
+ <Trans>
+ Selection: {formatSeconds(selectionDuration)} (max {formatSeconds(MAX_DURATION_SECONDS)})
+ </Trans>
+ </span>
+ <span data-flx="voice.entrance-sound-trimmer-modal.range-meta">
+ {formatSeconds(startSeconds)} → {formatSeconds(endSeconds)}
+ </span>
+ </div>
+ <div className={styles.controls} data-flx="voice.entrance-sound-trimmer-modal.controls">
+ <Button
+ variant="secondary"
+ small
+ onClick={togglePlayback}
+ data-flx="voice.entrance-sound-trimmer-modal.play-button"
+ >
+ <span className={styles.playButton} data-flx="voice.entrance-sound-trimmer-modal.play-button">
+ {isPlaying ? (
+ <PauseIcon size={14} weight="fill" data-flx="voice.entrance-sound-trimmer-modal.pause-icon" />
+ ) : (
+ <PlayIcon size={14} weight="fill" data-flx="voice.entrance-sound-trimmer-modal.play-icon" />
+ )}
+ <flx-i18n data-flx="voice.entrance-sound-trimmer-modal.flx-i18n">
+ {isPlaying ? i18n._(PAUSE_SELECTION_DESCRIPTOR) : i18n._(PLAY_SELECTION_DESCRIPTOR)}
+ </flx-i18n>
+ </span>
+ </Button>
+ </div>
+ {error ? (
+ <p className={styles.errorText} data-flx="voice.entrance-sound-trimmer-modal.error">
+ {error}
+ </p>
+ ) : null}
+ </>
+ );
+ }
return (
<Modal.Root size="small" centered data-flx="voice.entrance-sound-trimmer-modal.modal-root">
<Modal.Header
@@ -289,66 +356,7 @@ const EntranceSoundTrimmerModal: React.FC<EntranceSoundTrimmerModalProps> = obse
<p className={styles.helpText} data-flx="voice.entrance-sound-trimmer-modal.help-text">
{i18n._(TRIMMER_HELP_DESCRIPTOR)}
</p>
- {decodeError ? (
- <p className={styles.errorText} data-flx="voice.entrance-sound-trimmer-modal.decode-error">
- {decodeError}
- </p>
- ) : !audioBuffer || !peaks ? (
- <div className={styles.spinnerWrap} data-flx="voice.entrance-sound-trimmer-modal.spinner-wrap">
- <Spinner data-flx="voice.entrance-sound-trimmer-modal.spinner" />
- </div>
- ) : (
- <>
- <AudioWaveform
- peaks={peaks}
- durationSeconds={totalDuration}
- startSeconds={startSeconds}
- endSeconds={endSeconds}
- minSelectionSeconds={MIN_DURATION_SECONDS}
- maxSelectionSeconds={MAX_DURATION_SECONDS}
- playheadSeconds={playheadSeconds}
- onSelectionChange={handleSelectionChange}
- data-flx="voice.entrance-sound-trimmer-modal.waveform"
- />
- <div className={styles.meta} data-flx="voice.entrance-sound-trimmer-modal.meta">
- <span
- className={selectionTooShort || selectionTooLong ? styles.metaWarning : undefined}
- data-flx="voice.entrance-sound-trimmer-modal.selection-meta"
- >
- <Trans>
- Selection: {formatSeconds(selectionDuration)} (max {formatSeconds(MAX_DURATION_SECONDS)})
- </Trans>
- </span>
- <span data-flx="voice.entrance-sound-trimmer-modal.range-meta">
- {formatSeconds(startSeconds)} → {formatSeconds(endSeconds)}
- </span>
- </div>
- <div className={styles.controls} data-flx="voice.entrance-sound-trimmer-modal.controls">
- <Button
- variant="secondary"
- small
- onClick={togglePlayback}
- data-flx="voice.entrance-sound-trimmer-modal.play-button"
- >
- <span className={styles.playButton} data-flx="voice.entrance-sound-trimmer-modal.play-button">
- {isPlaying ? (
- <PauseIcon size={14} weight="fill" data-flx="voice.entrance-sound-trimmer-modal.pause-icon" />
- ) : (
- <PlayIcon size={14} weight="fill" data-flx="voice.entrance-sound-trimmer-modal.play-icon" />
- )}
- <flx-i18n data-flx="voice.entrance-sound-trimmer-modal.flx-i18n">
- {isPlaying ? i18n._(PAUSE_SELECTION_DESCRIPTOR) : i18n._(PLAY_SELECTION_DESCRIPTOR)}
- </flx-i18n>
- </span>
- </Button>
- </div>
- {error ? (
- <p className={styles.errorText} data-flx="voice.entrance-sound-trimmer-modal.error">
- {error}
- </p>
- ) : null}
- </>
- )}
+ {trimmerBody}
</div>
</Modal.Content>
<Modal.Footer data-flx="voice.entrance-sound-trimmer-modal.modal-footer">
diff --git a/fluxer_app/src/features/voice/components/PiPOverlay.tsx b/fluxer_app/src/features/voice/components/PiPOverlay.tsx
index fc15de434..65639d2f5 100644
--- a/fluxer_app/src/features/voice/components/PiPOverlay.tsx
+++ b/fluxer_app/src/features/voice/components/PiPOverlay.tsx
@@ -20,13 +20,14 @@ export const PiPOverlay = observer(function PiPOverlay() {
}, [room]);
const renderRoom = activeRoom;
const portalRoot = typeof document === 'undefined' ? null : document.body;
- const blockReason = !portalRoot
- ? 'missing-portal-root'
- : !isOpen
- ? 'pip-closed'
- : !content
- ? 'missing-content'
- : null;
+ let blockReason: 'missing-portal-root' | 'pip-closed' | 'missing-content' | null = null;
+ if (!portalRoot) {
+ blockReason = 'missing-portal-root';
+ } else if (!isOpen) {
+ blockReason = 'pip-closed';
+ } else if (!content) {
+ blockReason = 'missing-content';
+ }
useEffect(() => {
pipOverlayLogger.debug('PiP overlay shell state', {
blockReason,
diff --git a/fluxer_app/src/features/voice/components/StreamSettingsMenuContent.tsx b/fluxer_app/src/features/voice/components/StreamSettingsMenuContent.tsx
index 863c4adce..cbe8b3694 100644
--- a/fluxer_app/src/features/voice/components/StreamSettingsMenuContent.tsx
+++ b/fluxer_app/src/features/voice/components/StreamSettingsMenuContent.tsx
@@ -82,7 +82,7 @@ import type {NativeAudioAvailability, NativeAudioPlaybackDevice} from '@app/type
import type {I18n} from '@lingui/core';
import {msg} from '@lingui/core/macro';
import {Trans, useLingui} from '@lingui/react/macro';
-import {CrownSimpleIcon, MicrophoneIcon, WaveformIcon} from '@phosphor-icons/react';
+import {AtomIcon, MicrophoneIcon, WaveformIcon} from '@phosphor-icons/react';
import type {Track} from 'livekit-client';
import {observer} from 'mobx-react-lite';
import {useCallback, useEffect, useMemo, useState} from 'react';
@@ -182,10 +182,10 @@ const PremiumBadge = () => (
className={styles.premiumBadge}
data-flx="voice.stream-settings-menu-content.premium-badge.premium-badge"
>
- <CrownSimpleIcon
+ <AtomIcon
weight="fill"
size={remFromPx(12)}
- data-flx="voice.stream-settings-menu-content.premium-badge.crown-simple-icon"
+ data-flx="voice.stream-settings-menu-content.premium-badge.atom-icon"
/>
</span>
);
@@ -199,6 +199,12 @@ function getScreenShareResolutionLabel(i18n: I18n, resolution: OfferedScreenShar
return resolution === 'source' ? i18n._(SOURCE_DESCRIPTOR) : SCREEN_SHARE_RESOLUTION_LABELS[resolution];
}
+function getShareContextAudio(shareContext: StreamSettingsShareContext): boolean {
+ if (shareContext === 'app') return VoiceSettings.getShareAppAudio();
+ if (shareContext === 'device') return VoiceSettings.getShareDeviceAudio();
+ return VoiceSettings.getShareDesktopAudio();
+}
+
function supportsStreamAudioCapture(shareContext: StreamSettingsShareContext): boolean {
if (shareContext === 'device') {
return typeof navigator !== 'undefined' && Boolean(navigator.mediaDevices?.getUserMedia);
@@ -222,13 +228,7 @@ async function runActiveStreamSettingsPush(
ActiveScreenShareSource.setTarget(target);
const preferredDisplaySurface = getPreferredDisplaySurface(shareContext);
const canControlAudio = supportsStreamAudioCapture(shareContext);
- const includeAudio =
- canControlAudio &&
- (shareContext === 'app'
- ? VoiceSettings.getShareAppAudio()
- : shareContext === 'device'
- ? VoiceSettings.getShareDeviceAudio()
- : VoiceSettings.getShareDesktopAudio());
+ const includeAudio = canControlAudio && getShareContextAudio(shareContext);
const {captureOptions, publishOptions} = buildConfiguredScreenShareOptions({
target,
sourceDimensions,
@@ -358,11 +358,7 @@ export const StreamSettingsMenuContent = observer(
bitrate: VoiceSettings.getScreenShareBitrateBudget(),
});
const presetOverriddenByContext = selectStreamSettingsPresetOverriddenByContext(currentMode, shareContext);
- const captureAudioEnabled = isAppShare
- ? VoiceSettings.getShareAppAudio()
- : isDeviceShare
- ? VoiceSettings.getShareDeviceAudio()
- : VoiceSettings.getShareDesktopAudio();
+ const captureAudioEnabled = getShareContextAudio(shareContext);
const currentHideStreamPreview = VoiceSettings.getHideStreamPreview();
const currentAudioDeviceId = VoiceSettings.getScreenShareAudioDeviceId();
const effectiveAudioDeviceId = VoiceSettings.getEffectiveScreenShareAudioDeviceId();
diff --git a/fluxer_app/src/features/voice/components/VoiceCallLayoutContent.tsx b/fluxer_app/src/features/voice/components/VoiceCallLayoutContent.tsx
index b43f60d85..03d19e783 100644
--- a/fluxer_app/src/features/voice/components/VoiceCallLayoutContent.tsx
+++ b/fluxer_app/src/features/voice/components/VoiceCallLayoutContent.tsx
@@ -346,19 +346,21 @@ export const VoiceCallLayoutContent = observer(function VoiceCallLayoutContent({
className={styles.iconMedium}
data-flx="voice.voice-call-layout-content.focus-layout-node.icon-medium"
/>
- ) : isParticipantsExpanded ? (
- <CaretDownIcon
- weight="bold"
- className={styles.iconMedium}
- data-flx="voice.voice-call-layout-content.focus-layout-node.icon-medium--2"
- />
- ) : (
- <CaretUpIcon
- weight="bold"
- className={styles.iconMedium}
- data-flx="voice.voice-call-layout-content.focus-layout-node.icon-medium--3"
- />
- )}
+ ) : null}
+ {!compact &&
+ (isParticipantsExpanded ? (
+ <CaretDownIcon
+ weight="bold"
+ className={styles.iconMedium}
+ data-flx="voice.voice-call-layout-content.focus-layout-node.icon-medium--2"
+ />
+ ) : (
+ <CaretUpIcon
+ weight="bold"
+ className={styles.iconMedium}
+ data-flx="voice.voice-call-layout-content.focus-layout-node.icon-medium--3"
+ />
+ ))}
</button>
</Tooltip>
</FocusRing>
@@ -472,19 +474,21 @@ export const VoiceCallLayoutContent = observer(function VoiceCallLayoutContent({
className={styles.iconMedium}
data-flx="voice.voice-call-layout-content.focus-layout-node.icon-medium--4"
/>
- ) : isParticipantsExpanded ? (
- <CaretDownIcon
- weight="bold"
- className={styles.iconMedium}
- data-flx="voice.voice-call-layout-content.focus-layout-node.icon-medium--5"
- />
- ) : (
- <CaretUpIcon
- weight="bold"
- className={styles.iconMedium}
- data-flx="voice.voice-call-layout-content.focus-layout-node.icon-medium--6"
- />
- )}
+ ) : null}
+ {!compact &&
+ (isParticipantsExpanded ? (
+ <CaretDownIcon
+ weight="bold"
+ className={styles.iconMedium}
+ data-flx="voice.voice-call-layout-content.focus-layout-node.icon-medium--5"
+ />
+ ) : (
+ <CaretUpIcon
+ weight="bold"
+ className={styles.iconMedium}
+ data-flx="voice.voice-call-layout-content.focus-layout-node.icon-medium--6"
+ />
+ ))}
</button>
</Tooltip>
</FocusRing>
diff --git a/fluxer_app/src/features/voice/components/VoiceE2EEIndicator.tsx b/fluxer_app/src/features/voice/components/VoiceE2EEIndicator.tsx
index 10f7926e1..6d6f0d4da 100644
--- a/fluxer_app/src/features/voice/components/VoiceE2EEIndicator.tsx
+++ b/fluxer_app/src/features/voice/components/VoiceE2EEIndicator.tsx
@@ -53,13 +53,11 @@ export const VoiceE2EEIndicator = observer(function VoiceE2EEIndicator({
const status = gatewayStatus;
if (status === 'none') return null;
const isEncrypted = status === 'encrypted';
- const descriptor = isEncrypted
- ? variant === 'call'
- ? VOICE_CALL_E2EE_ENCRYPTED_DESCRIPTOR
- : VOICE_CHANNEL_E2EE_ENCRYPTED_DESCRIPTOR
- : variant === 'call'
- ? VOICE_CALL_E2EE_BROKEN_DESCRIPTOR
- : VOICE_CHANNEL_E2EE_BROKEN_DESCRIPTOR;
+ const encryptedDescriptor =
+ variant === 'call' ? VOICE_CALL_E2EE_ENCRYPTED_DESCRIPTOR : VOICE_CHANNEL_E2EE_ENCRYPTED_DESCRIPTOR;
+ const brokenDescriptor =
+ variant === 'call' ? VOICE_CALL_E2EE_BROKEN_DESCRIPTOR : VOICE_CHANNEL_E2EE_BROKEN_DESCRIPTOR;
+ const descriptor = isEncrypted ? encryptedDescriptor : brokenDescriptor;
return (
<div
className={isEncrypted ? styles.indicatorEncrypted : styles.indicatorBroken}
diff --git a/fluxer_app/src/features/voice/components/VoiceMessageComposerModal.tsx b/fluxer_app/src/features/voice/components/VoiceMessageComposerModal.tsx
index fa0e2e71a..ae767ba41 100644
--- a/fluxer_app/src/features/voice/components/VoiceMessageComposerModal.tsx
+++ b/fluxer_app/src/features/voice/components/VoiceMessageComposerModal.tsx
@@ -521,6 +521,56 @@ const VoiceMessageComposerModal: React.FC<VoiceMessageComposerModalProps> = obse
void startRecording();
}, [startRecording]);
+ let footerAction: React.ReactNode = null;
+ if (stage === 'recording') {
+ footerAction = (
+ <Button
+ variant="primary"
+ onClick={() => void stopRecording()}
+ data-flx="voice.voice-message-composer-modal.stop-button"
+ >
+ <span className={styles.buttonInner} data-flx="voice.voice-message-composer-modal.button-inner--3">
+ <StopIcon size={remFromPx(14)} weight="fill" data-flx="voice.voice-message-composer-modal.stop-icon" />
+ {i18n._(STOP_BUTTON_DESCRIPTOR)}
+ </span>
+ </Button>
+ );
+ } else if (stage === 'reviewing') {
+ footerAction = (
+ <Button
+ variant="primary"
+ onClick={() => void send()}
+ disabled={selectionDuration < MIN_DURATION_SECONDS}
+ data-flx="voice.voice-message-composer-modal.send-button"
+ >
+ <span className={styles.buttonInner} data-flx="voice.voice-message-composer-modal.button-inner--4">
+ <PaperPlaneRightIcon
+ size={remFromPx(14)}
+ weight="fill"
+ data-flx="voice.voice-message-composer-modal.paper-plane-right-icon"
+ />
+ {i18n._(SEND_BUTTON_DESCRIPTOR)}
+ </span>
+ </Button>
+ );
+ } else if (stage === 'permission_error') {
+ footerAction = (
+ <Button
+ variant="primary"
+ onClick={() => void startRecording()}
+ data-flx="voice.voice-message-composer-modal.retry-button"
+ >
+ <span className={styles.buttonInner} data-flx="voice.voice-message-composer-modal.button-inner--5">
+ <MicrophoneIcon
+ size={remFromPx(14)}
+ weight="fill"
+ data-flx="voice.voice-message-composer-modal.microphone-icon"
+ />
+ {i18n._(RECORD_BUTTON_DESCRIPTOR)}
+ </span>
+ </Button>
+ );
+ }
return (
<Modal.Root size="small" centered data-flx="voice.voice-message-composer-modal.modal-root">
<Modal.Header
@@ -633,49 +683,7 @@ const VoiceMessageComposerModal: React.FC<VoiceMessageComposerModalProps> = obse
<Button variant="secondary" onClick={close} data-flx="voice.voice-message-composer-modal.cancel-button">
{i18n._(CANCEL_DESCRIPTOR)}
</Button>
- {stage === 'recording' ? (
- <Button
- variant="primary"
- onClick={() => void stopRecording()}
- data-flx="voice.voice-message-composer-modal.stop-button"
- >
- <span className={styles.buttonInner} data-flx="voice.voice-message-composer-modal.button-inner--3">
- <StopIcon size={remFromPx(14)} weight="fill" data-flx="voice.voice-message-composer-modal.stop-icon" />
- {i18n._(STOP_BUTTON_DESCRIPTOR)}
- </span>
- </Button>
- ) : stage === 'reviewing' ? (
- <Button
- variant="primary"
- onClick={() => void send()}
- disabled={selectionDuration < MIN_DURATION_SECONDS}
- data-flx="voice.voice-message-composer-modal.send-button"
- >
- <span className={styles.buttonInner} data-flx="voice.voice-message-composer-modal.button-inner--4">
- <PaperPlaneRightIcon
- size={remFromPx(14)}
- weight="fill"
- data-flx="voice.voice-message-composer-modal.paper-plane-right-icon"
- />
- {i18n._(SEND_BUTTON_DESCRIPTOR)}
- </span>
- </Button>
- ) : stage === 'permission_error' ? (
- <Button
- variant="primary"
- onClick={() => void startRecording()}
- data-flx="voice.voice-message-composer-modal.retry-button"
- >
- <span className={styles.buttonInner} data-flx="voice.voice-message-composer-modal.button-inner--5">
- <MicrophoneIcon
- size={remFromPx(14)}
- weight="fill"
- data-flx="voice.voice-message-composer-modal.microphone-icon"
- />
- {i18n._(RECORD_BUTTON_DESCRIPTOR)}
- </span>
- </Button>
- ) : null}
+ {footerAction}
</Modal.Footer>
</Modal.Root>
);
diff --git a/fluxer_app/src/features/voice/components/VoiceParticipantAvatarList.tsx b/fluxer_app/src/features/voice/components/VoiceParticipantAvatarList.tsx
index 73efba14d..b9173d1e6 100644
--- a/fluxer_app/src/features/voice/components/VoiceParticipantAvatarList.tsx
+++ b/fluxer_app/src/features/voice/components/VoiceParticipantAvatarList.tsx
@@ -103,7 +103,7 @@ function reconcileWrappedAvatarSlots(
return {
key,
entry,
- phase: previousSlot?.phase === 'exiting' ? 'entering' : previousSlot ? 'present' : 'entering',
+ phase: previousSlot && previousSlot.phase !== 'exiting' ? 'present' : 'entering',
} satisfies WrappedAvatarSlot;
});
const exitingSlots = previousSlots
diff --git a/fluxer_app/src/features/voice/components/VoiceParticipantTile.tsx b/fluxer_app/src/features/voice/components/VoiceParticipantTile.tsx
index 76789cb5c..f0d00a74e 100644
--- a/fluxer_app/src/features/voice/components/VoiceParticipantTile.tsx
+++ b/fluxer_app/src/features/voice/components/VoiceParticipantTile.tsx
@@ -288,11 +288,14 @@ const VoiceParticipantTileInner = observer(function VoiceParticipantTileInner({
const isModeratorMuted = displayState.guildMute;
const isModeratorDeafened = displayState.guildDeaf;
const isMuteStatusVisible = isModeratorMuted || isSelfMuted;
- const muteStatusLabel = isModeratorMuted
- ? i18n._(VOICE_MUTED_BY_MODERATORS_DESCRIPTOR)
- : isPermissionMuted
- ? getVoiceNoSpeakPermissionLabel(i18n, isCurrentUser)
- : i18n._(MUTED_DESCRIPTOR);
+ let muteStatusLabel: string;
+ if (isModeratorMuted) {
+ muteStatusLabel = i18n._(VOICE_MUTED_BY_MODERATORS_DESCRIPTOR);
+ } else if (isPermissionMuted) {
+ muteStatusLabel = getVoiceNoSpeakPermissionLabel(i18n, isCurrentUser);
+ } else {
+ muteStatusLabel = i18n._(MUTED_DESCRIPTOR);
+ }
const muteStatusClassName =
isModeratorMuted || isPermissionMuted ? styles.participantIconRed : styles.participantIconMuted;
const isDeafenStatusVisible = isModeratorDeafened || isSelfDeafened;
@@ -1497,7 +1500,7 @@ const VoiceParticipantTileInner = observer(function VoiceParticipantTileInner({
{participantDisplayName}
</span>
</Tooltip>
- {connectionId && (
+ {connectionId && VoiceSettings.showVoiceConnectionId && (
<Tooltip
text={i18n._(CONNECTION_DESCRIPTOR, {connectionId})}
position="top"
diff --git a/fluxer_app/src/features/voice/components/media_player/components/VideoPlayer.tsx b/fluxer_app/src/features/voice/components/media_player/components/VideoPlayer.tsx
index 21d55e150..f9cf05a2f 100644
--- a/fluxer_app/src/features/voice/components/media_player/components/VideoPlayer.tsx
+++ b/fluxer_app/src/features/voice/components/media_player/components/VideoPlayer.tsx
@@ -574,14 +574,10 @@ export const VideoPlayer = observer(function VideoPlayer({
),
);
const progressPreviewPortalRoot = fullscreenPortalRoot;
- const containerStyle: React.CSSProperties = {
- ...style,
- ...(width && height && !fillContainer
- ? {aspectRatio: `${width} / ${height}`}
- : !fillContainer
- ? {aspectRatio: '16 / 9'}
- : {}),
- };
+ const containerStyle: React.CSSProperties = {...style};
+ if (!fillContainer) {
+ containerStyle.aspectRatio = width && height ? `${width} / ${height}` : '16 / 9';
+ }
return (
<PortalHostContext.Provider value={fullscreenPortalRoot ?? inheritedPortalHost}>
<FocusRing offset={-2} data-flx="voice.media-player.video-player.focus-ring">
diff --git a/fluxer_app/src/features/voice/components/media_player/hooks/useMediaKeyboard.ts b/fluxer_app/src/features/voice/components/media_player/hooks/useMediaKeyboard.ts
index dc8511c19..dc5bbe85a 100644
--- a/fluxer_app/src/features/voice/components/media_player/hooks/useMediaKeyboard.ts
+++ b/fluxer_app/src/features/voice/components/media_player/hooks/useMediaKeyboard.ts
@@ -15,8 +15,6 @@ interface UseMediaKeyboardOptions {
onToggleMute?: () => void;
onToggleFullscreen?: () => void;
onSeekPercentage?: (percentage: number) => void;
- seekAmount?: number;
- volumeStep?: number;
captureDocumentKeys?: boolean;
}
@@ -118,14 +116,14 @@ function trapFocusInContainer(event: KeyboardEvent, container: HTMLElement): voi
}
const activeElement = document.activeElement;
const activeIndex = activeElement instanceof HTMLElement ? focusableElements.indexOf(activeElement) : -1;
- const nextIndex =
- activeIndex === -1
- ? event.shiftKey
- ? focusableElements.length - 1
- : 0
- : event.shiftKey
- ? (activeIndex - 1 + focusableElements.length) % focusableElements.length
- : (activeIndex + 1) % focusableElements.length;
+ let nextIndex: number;
+ if (activeIndex === -1) {
+ nextIndex = event.shiftKey ? focusableElements.length - 1 : 0;
+ } else if (event.shiftKey) {
+ nextIndex = (activeIndex - 1 + focusableElements.length) % focusableElements.length;
+ } else {
+ nextIndex = (activeIndex + 1) % focusableElements.length;
+ }
focusElement(focusableElements[nextIndex]);
}
@@ -141,8 +139,6 @@ export function useMediaKeyboard(options: UseMediaKeyboardOptions): UseMediaKeyb
onToggleMute,
onToggleFullscreen,
onSeekPercentage,
- seekAmount = SEEK_STEP,
- volumeStep = VOLUME_STEP,
captureDocumentKeys = false,
} = options;
const handleMediaKeyDown = useCallback(
@@ -223,8 +219,6 @@ export function useMediaKeyboard(options: UseMediaKeyboardOptions): UseMediaKeyb
onToggleMute,
onToggleFullscreen,
onSeekPercentage,
- seekAmount,
- volumeStep,
],
);
const handleKeyDown = useCallback(
diff --git a/fluxer_app/src/features/voice/components/media_player/hooks/useMediaProgress.ts b/fluxer_app/src/features/voice/components/media_player/hooks/useMediaProgress.ts
index 8fe4ca2cd..818b9b736 100644
--- a/fluxer_app/src/features/voice/components/media_player/hooks/useMediaProgress.ts
+++ b/fluxer_app/src/features/voice/components/media_player/hooks/useMediaProgress.ts
@@ -63,11 +63,10 @@ export function useMediaProgress(options: UseMediaProgressOptions): UseMediaProg
const setDurationFromMedia = useCallback((rawDuration: number) => {
const hasRealDuration = Number.isFinite(rawDuration) && rawDuration > 0;
setDuration((previousDuration) => {
- const nextDuration = hasRealDuration
- ? rawDuration
- : previousDuration > 0
- ? previousDuration
- : fallbackDurationRef.current;
+ let nextDuration = rawDuration;
+ if (!hasRealDuration) {
+ nextDuration = previousDuration > 0 ? previousDuration : fallbackDurationRef.current;
+ }
return previousDuration === nextDuration ? previousDuration : nextDuration;
});
}, []);
@@ -216,7 +215,12 @@ export function useMediaProgress(options: UseMediaProgressOptions): UseMediaProg
setPendingProgressIfChanged(null);
}
}, [mediaRef, setPendingProgressIfChanged]);
- const progress = pendingProgress !== null ? pendingProgress : duration > 0 ? (currentTime / duration) * 100 : 0;
+ let progress = 0;
+ if (pendingProgress !== null) {
+ progress = pendingProgress;
+ } else if (duration > 0) {
+ progress = (currentTime / duration) * 100;
+ }
return {
currentTime,
duration,
diff --git a/fluxer_app/src/features/voice/components/modals/CameraPreviewModal.tsx b/fluxer_app/src/features/voice/components/modals/CameraPreviewModal.tsx
index b09b0f8d6..ab8b4a581 100644
--- a/fluxer_app/src/features/voice/components/modals/CameraPreviewModal.tsx
+++ b/fluxer_app/src/features/voice/components/modals/CameraPreviewModal.tsx
@@ -79,7 +79,6 @@ const BLUR_STRENGTH_DESCRIPTOR = msg({
const logger = new Logger('CameraPreviewModal');
interface CameraPreviewModalProps {
- onEnabled?: () => void;
onEnableCamera?: () => void | Promise<void>;
showEnableCameraButton?: boolean;
localParticipant?: LocalParticipant;
@@ -577,7 +576,6 @@ const CameraPreviewModalContent = observer((props: CameraPreviewModalProps) => {
try {
if (!localParticipant) {
await onEnableCamera?.();
- onEnabled?.();
ModalCommands.pop();
return;
}
@@ -591,7 +589,6 @@ const CameraPreviewModalContent = observer((props: CameraPreviewModalProps) => {
effectiveVideoDeviceId && effectiveVideoDeviceId !== 'default' ? effectiveVideoDeviceId : undefined,
}));
await enableCamera();
- onEnabled?.();
ModalCommands.pop();
} catch (_err) {
showGenericErrorModal({
@@ -683,6 +680,14 @@ const CameraPreviewModalContent = observer((props: CameraPreviewModalProps) => {
: device.label || formatFallbackCameraLabel(i18n),
}))
: [{value: 'default', label: i18n._(DEFAULT_CAMERA_DESCRIPTOR)}];
+ let overlayStatusText: React.ReactNode;
+ if (status === 'fixing') {
+ overlayStatusText = <Trans>Optimizing camera...</Trans>;
+ } else if (status === 'fix-switching-back') {
+ overlayStatusText = <Trans>Finalizing camera...</Trans>;
+ } else {
+ overlayStatusText = <Trans>Initializing camera...</Trans>;
+ }
return (
<Modal.Root size="medium" data-flx="voice.camera-preview-modal.camera-preview-modal-content.modal-root">
<Modal.Header
@@ -763,13 +768,7 @@ const CameraPreviewModalContent = observer((props: CameraPreviewModalProps) => {
className={styles.overlayTextMedium}
data-flx="voice.camera-preview-modal.camera-preview-modal-content.overlay-text-medium"
>
- {status === 'fixing' ? (
- <Trans>Optimizing camera...</Trans>
- ) : status === 'fix-switching-back' ? (
- <Trans>Finalizing camera...</Trans>
- ) : (
- <Trans>Initializing camera...</Trans>
- )}
+ {overlayStatusText}
</div>
</div>
</div>
diff --git a/fluxer_app/src/features/voice/components/modals/screen_share_picker_modal/PickerCardButton.tsx b/fluxer_app/src/features/voice/components/modals/screen_share_picker_modal/PickerCardButton.tsx
index 478ec56aa..6a6c2bea0 100644
--- a/fluxer_app/src/features/voice/components/modals/screen_share_picker_modal/PickerCardButton.tsx
+++ b/fluxer_app/src/features/voice/components/modals/screen_share_picker_modal/PickerCardButton.tsx
@@ -5,7 +5,7 @@ import styles from '@app/features/voice/components/modals/ScreenSharePickerModal
import type {PickerCard} from '@app/features/voice/components/modals/screen_share_picker_modal/shared';
import {getDeterministicPlaceholderGradient} from '@app/lib/placeholder-gradient';
import {clsx} from 'clsx';
-import {type FC, type Ref, useEffect, useRef} from 'react';
+import {type FC, type ReactNode, type Ref, useEffect, useRef} from 'react';
interface DevicePreviewVideoProps {
stream: MediaStream;
@@ -65,38 +65,46 @@ const PickerCardPreview: FC<PickerCardPreviewProps> = ({
onPreviewImageError,
}) => {
const PlaceholderIcon = card.placeholderIcon;
+ let preview: ReactNode;
+ if (devicePreviewStream) {
+ preview = (
+ <DevicePreviewVideo
+ stream={devicePreviewStream}
+ data-flx="voice.screen-share-picker-modal.picker-card-button.picker-card-preview.device-preview-video"
+ />
+ );
+ } else if (card.thumbnailSrc) {
+ preview = (
+ <img
+ src={card.thumbnailSrc}
+ alt=""
+ className={styles.previewImage}
+ draggable={false}
+ onError={onPreviewImageError}
+ data-flx="voice.screen-share-picker-modal.preview-image"
+ />
+ );
+ } else {
+ preview = (
+ <div
+ className={clsx(styles.previewPlaceholder, isDeviceCard && styles.devicePreviewPlaceholder)}
+ style={isDeviceCard ? getDeterministicPlaceholderGradient(card.id) : undefined}
+ data-flx="voice.screen-share-picker-modal.preview-placeholder"
+ >
+ <PlaceholderIcon
+ className={styles.previewIcon}
+ weight="fill"
+ data-flx="voice.screen-share-picker-modal.preview-icon"
+ />
+ </div>
+ );
+ }
return (
<div
className={clsx(styles.preview, isDeviceCard && styles.previewDevice)}
data-flx="voice.screen-share-picker-modal.preview"
>
- {devicePreviewStream ? (
- <DevicePreviewVideo
- stream={devicePreviewStream}
- data-flx="voice.screen-share-picker-modal.picker-card-button.picker-card-preview.device-preview-video"
- />
- ) : card.thumbnailSrc ? (
- <img
- src={card.thumbnailSrc}
- alt=""
- className={styles.previewImage}
- draggable={false}
- onError={onPreviewImageError}
- data-flx="voice.screen-share-picker-modal.preview-image"
- />
- ) : (
- <div
- className={clsx(styles.previewPlaceholder, isDeviceCard && styles.devicePreviewPlaceholder)}
- style={isDeviceCard ? getDeterministicPlaceholderGradient(card.id) : undefined}
- data-flx="voice.screen-share-picker-modal.preview-placeholder"
- >
- <PlaceholderIcon
- className={styles.previewIcon}
- weight="fill"
- data-flx="voice.screen-share-picker-modal.preview-icon"
- />
- </div>
- )}
+ {preview}
<span
className={styles.previewOverlay}
aria-hidden={true}
diff --git a/fluxer_app/src/features/voice/components/useVoiceCallTracksAndLayout.ts b/fluxer_app/src/features/voice/components/useVoiceCallTracksAndLayout.ts
index 9a8931712..aa4841c78 100644
--- a/fluxer_app/src/features/voice/components/useVoiceCallTracksAndLayout.ts
+++ b/fluxer_app/src/features/voice/components/useVoiceCallTracksAndLayout.ts
@@ -395,7 +395,14 @@ export function useVoiceCallTracksAndLayout({channel, expandedUserIds}: UseVoice
activityStates.delete(key);
activityState = undefined;
}
- const priority = isStreaming ? 3 : isSpeaking ? 2 : activityState ? 1 : 0;
+ let priority = 0;
+ if (isStreaming) {
+ priority = 3;
+ } else if (isSpeaking) {
+ priority = 2;
+ } else if (activityState) {
+ priority = 1;
+ }
activeKeys.add(key);
activityByKey.set(key, {priority, promotedOrder: activityState?.promotedOrder ?? Number.MAX_SAFE_INTEGER});
}