Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions apps/web/src/features/channel/Call/CallAlonePrompt.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { ConfirmDialog } from '@ui/components/ConfirmDialog';
import { createSignal, onCleanup } from 'solid-js';

function formatRemaining(ms: number) {
const totalSeconds = Math.max(0, Math.ceil(ms / 1000));
const minutes = Math.floor(totalSeconds / 60);
const seconds = totalSeconds % 60;
return `${minutes}:${seconds.toString().padStart(2, '0')}`;
}

/**
* Asks a user who is alone in a call whether to keep it going before the
* server ends it at `endsAt`. Dismissing leaves the deadline in place.
*/
export function CallAlonePrompt(props: {
/** Epoch ms when the server ends the call. */
endsAt: number;
pending: boolean;
onStay: () => void;
onDismiss: () => void;
}) {
const [nowMs, setNowMs] = createSignal(Date.now());
const countdownTimer = globalThis.setInterval(
() => setNowMs(Date.now()),
1000
);
onCleanup(() => globalThis.clearInterval(countdownTimer));

return (
<ConfirmDialog
open
onOpenChange={(open) => {
if (!open) props.onDismiss();
}}
title="You're the only one here"
body={`No one else is in this call. It will end in ${formatRemaining(
props.endsAt - nowMs()
)} unless you stay.`}
confirmLabel="Stay in call"
cancelLabel="Dismiss"
pending={props.pending}
onConfirm={props.onStay}
/>
);
}
Loading
Loading