overlay styling and interval fixes

Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
Timo K
2025-09-12 14:21:31 +02:00
parent c1e8cdc4e0
commit 35b9a524b2
2 changed files with 13 additions and 20 deletions

View File

@@ -50,6 +50,7 @@ import { type HeaderStyle, useUrlParams } from "../UrlParams";
import { useCallViewKeyboardShortcuts } from "../useCallViewKeyboardShortcuts"; import { useCallViewKeyboardShortcuts } from "../useCallViewKeyboardShortcuts";
import { ElementWidgetActions, widget } from "../widget"; import { ElementWidgetActions, widget } from "../widget";
import styles from "./InCallView.module.css"; import styles from "./InCallView.module.css";
import overlayStyles from "../Overlay.module.css";
import { GridTile } from "../tile/GridTile"; import { GridTile } from "../tile/GridTile";
import { type OTelGroupCallMembership } from "../otel/OTelGroupCallMembership"; import { type OTelGroupCallMembership } from "../otel/OTelGroupCallMembership";
import { SettingsModal, defaultSettingsTab } from "../settings/SettingsModal"; import { SettingsModal, defaultSettingsTab } from "../settings/SettingsModal";
@@ -285,6 +286,8 @@ export const InCallView: FC<InCallViewProps> = ({
// do we want a timeout sound? // do we want a timeout sound?
}); });
}); });
// configure this to sth that fits to the pickup waiting sound.
const PICKUP_SOUND_INTERVAL = 1000;
const pickupPhaseAudio = useAudioContext({ const pickupPhaseAudio = useAudioContext({
sounds: pickupPhaseSoundCache, sounds: pickupPhaseSoundCache,
@@ -360,6 +363,7 @@ export const InCallView: FC<InCallViewProps> = ({
onLeave(); onLeave();
} }
if (callPickupState === "decline") { if (callPickupState === "decline") {
// Wait for the sound to finish before leaving
void pickupPhaseAudio void pickupPhaseAudio
?.playSound("decline") ?.playSound("decline")
.catch((e) => { .catch((e) => {
@@ -372,23 +376,12 @@ export const InCallView: FC<InCallViewProps> = ({
}); });
// When waiting for pickup, loop a waiting sound // When waiting for pickup, loop a waiting sound
const [playing, setPlaying] = useState(false);
useEffect((): void | (() => void) => { useEffect((): void | (() => void) => {
if (callPickupState !== "ringing") return; const interval = window.setInterval(() => {
setPlaying(true); void pickupPhaseAudio?.playSound("waiting");
// play and then wait for 1.5s }, PICKUP_SOUND_INTERVAL);
const playSoundAndWait = async (): Promise<void> => { return (): void => window.clearInterval(interval);
await pickupPhaseAudio?.playSound("waiting"); }, [callPickupState, pickupPhaseAudio]);
await new Promise((res) => setTimeout(res, 1500));
};
const startPlaying = async (): Promise<void> => {
while (playing) {
await playSoundAndWait();
}
};
void startPlaying();
return (): void => setPlaying(false);
}, [callPickupState, pickupPhaseAudio, playing]);
// Waiting UI overlay // Waiting UI overlay
const waitingOverlay: JSX.Element | null = useMemo(() => { const waitingOverlay: JSX.Element | null = useMemo(() => {
@@ -413,8 +406,10 @@ export const InCallView: FC<InCallViewProps> = ({
: (matrixRoom.getMxcAvatarUrl() ?? undefined); : (matrixRoom.getMxcAvatarUrl() ?? undefined);
return ( return (
<div className={waitingStyles.overlay}> <div className={classNames(overlayStyles.bg, waitingStyles.overlay)}>
<div className={waitingStyles.content}> <div
className={classNames(overlayStyles.content, waitingStyles.content)}
>
<div className={waitingStyles.pulse}> <div className={waitingStyles.pulse}>
<Avatar <Avatar
id={isOneOnOne ? otherMember.userId : matrixRoom.roomId} id={isOneOnOne ? otherMember.userId : matrixRoom.roomId}

View File

@@ -5,8 +5,6 @@
align-items: center; align-items: center;
justify-content: center; justify-content: center;
pointer-events: none; pointer-events: none;
background: var(--cpd-color-bg-canvas-default);
opacity: 0.94;
} }
.content { .content {