Clean up and streamline safety checking instead of using multiple separate checks
Signed-off-by: Jake Janicke <jaketripplj@gmail.com>
This commit is contained in:
@@ -266,34 +266,33 @@ export const SpotlightTile: FC<Props> = ({
|
|||||||
const canGoBack = visibleIndex > 0;
|
const canGoBack = visibleIndex > 0;
|
||||||
const canGoToNext = visibleIndex !== -1 && visibleIndex < media.length - 1;
|
const canGoToNext = visibleIndex !== -1 && visibleIndex < media.length - 1;
|
||||||
const currentMedia = media[visibleIndex];
|
const currentMedia = media[visibleIndex];
|
||||||
// isScreenShare only needs to check "audioEnabled$" but I wanted to be more specific
|
// only "audioEnabled$" needs to checked but I wanted to be more specific just in
|
||||||
// just in case more models are added in the future, since screen shares always have video
|
// case more models are added in the future, since screen shares always have video
|
||||||
const isScreenShare =
|
const currentScreenShare =
|
||||||
currentMedia != null &&
|
currentMedia &&
|
||||||
"audioEnabled$" in currentMedia &&
|
"audioEnabled$" in currentMedia &&
|
||||||
"videoEnabled$" in currentMedia;
|
"videoEnabled$" in currentMedia
|
||||||
|
? (currentMedia as RemoteScreenShareViewModel)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
const isScreenShare = currentScreenShare != null;
|
||||||
|
|
||||||
const hasAudio$ = useBehavior(
|
const hasAudio$ = useBehavior(
|
||||||
isScreenShare && (currentMedia as RemoteScreenShareViewModel).audioEnabled$
|
currentScreenShare?.audioEnabled$ ?? constant(false),
|
||||||
? currentMedia.audioEnabled$
|
|
||||||
: constant(false),
|
|
||||||
);
|
);
|
||||||
const isLocalScreenShare =
|
|
||||||
isScreenShare && (currentMedia as RemoteScreenShareViewModel)?.local;
|
const isLocalScreenShare = currentScreenShare?.local ?? false;
|
||||||
|
|
||||||
const screenShareLocallyMuted = useBehavior(
|
const screenShareLocallyMuted = useBehavior(
|
||||||
isScreenShare &&
|
currentScreenShare?.playbackMuted$ ?? constant(false),
|
||||||
(currentMedia as RemoteScreenShareViewModel).playbackMuted$ != null
|
|
||||||
? (currentMedia as RemoteScreenShareViewModel).playbackMuted$
|
|
||||||
: constant(false),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const ScreenShareVolumeIcon = screenShareLocallyMuted
|
const ScreenShareVolumeIcon = screenShareLocallyMuted
|
||||||
? VolumeOffIcon
|
? VolumeOffIcon
|
||||||
: VolumeOnIcon;
|
: VolumeOnIcon;
|
||||||
|
|
||||||
const screenShareVolume = useBehavior(
|
const screenShareVolume = useBehavior(
|
||||||
isScreenShare &&
|
currentScreenShare?.playbackVolume$ ?? constant(0),
|
||||||
(currentMedia as RemoteScreenShareViewModel).playbackVolume$ != null
|
|
||||||
? (currentMedia as RemoteScreenShareViewModel).playbackVolume$
|
|
||||||
: constant(0),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const isFullscreen = useCallback((): boolean => {
|
const isFullscreen = useCallback((): boolean => {
|
||||||
|
|||||||
Reference in New Issue
Block a user