Repository navigation
Disable remote actions during calls #1329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: production
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ import { | |
| CallButton, | ||
| CallConsole, | ||
| OrgCallConsole, | ||
| useIsCallActive, | ||
| } from '@/components/chat/call'; | ||
| import { | ||
| LiftedMessage, | ||
|
|
@@ -1707,6 +1708,14 @@ function Composer({ | |
|
|
||
| const voiceNote = useVoiceNote(showError); | ||
| const isVoicing = voiceNote.state.status !== 'idle'; | ||
| const isCallActive = useIsCallActive(); | ||
| const discardVoiceNote = voiceNote.discard; | ||
|
|
||
| useEffect(() => { | ||
| if (isCallActive && isVoicing) { | ||
| discardVoiceNote(); | ||
|
Comment on lines
+1715
to
+1716
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
| }, [discardVoiceNote, isCallActive, isVoicing]); | ||
|
|
||
| const pushVoiceNote = async () => { | ||
| const voice = await voiceNote.stop(); | ||
|
|
@@ -1928,67 +1937,73 @@ function Composer({ | |
| isCompact ? 'size-9' : 'size-10', | ||
| )} | ||
| /> | ||
| <Tooltip> | ||
| <TooltipTrigger asChild> | ||
| <span className="-mx-1 inline-flex shrink-0"> | ||
| {!isCallActive && ( | ||
| <Tooltip> | ||
| <TooltipTrigger asChild> | ||
| <span className="-mx-1 inline-flex shrink-0"> | ||
| <Button | ||
| type="button" | ||
| variant="ghost" | ||
| size="icon" | ||
| disabled={ | ||
| trimmed !== '' || hasImages | ||
| } | ||
| onClick={() => | ||
| void voiceNote.start() | ||
| } | ||
| aria-label="Record a voice note" | ||
| className={cn( | ||
| 'text-muted-foreground', | ||
| isCompact | ||
| ? 'size-9' | ||
| : 'size-10', | ||
| )} | ||
| data-test="record-voice-note" | ||
| > | ||
| <Mic className="size-5" /> | ||
| </Button> | ||
| </span> | ||
| </TooltipTrigger> | ||
| <TooltipContent> | ||
| {trimmed !== '' || hasImages | ||
| ? 'Voice notes go on their own' | ||
| : 'Record a voice note (max. 1 min)'} | ||
| </TooltipContent> | ||
| </Tooltip> | ||
| )} | ||
| {!isCallActive && ( | ||
| <Tooltip> | ||
| <TooltipTrigger asChild> | ||
| <Button | ||
| type="button" | ||
| variant="ghost" | ||
| size="icon" | ||
| disabled={ | ||
| trimmed !== '' || hasImages | ||
| } | ||
| onClick={() => | ||
| void voiceNote.start() | ||
| void sendPing(target).catch( | ||
| (error: unknown) => | ||
| showError( | ||
| error instanceof | ||
| ChatRequestError | ||
| ? error.firstError() | ||
| : 'Could not ping. Try again.', | ||
| ), | ||
| ) | ||
| } | ||
| aria-label="Record a voice note" | ||
| aria-label={pingLabel} | ||
| className={cn( | ||
| 'text-muted-foreground', | ||
| '-mx-1 shrink-0 text-muted-foreground', | ||
| isCompact | ||
| ? 'size-9' | ||
| : 'size-10', | ||
| )} | ||
| data-test="record-voice-note" | ||
| data-test="send-ping" | ||
| > | ||
| <Mic className="size-5" /> | ||
| <Vibrate className="size-5" /> | ||
| </Button> | ||
| </span> | ||
| </TooltipTrigger> | ||
| <TooltipContent> | ||
| {trimmed !== '' || hasImages | ||
| ? 'Voice notes go on their own' | ||
| : 'Record a voice note (max. 1 min)'} | ||
| </TooltipContent> | ||
| </Tooltip> | ||
| <Tooltip> | ||
| <TooltipTrigger asChild> | ||
| <Button | ||
| type="button" | ||
| variant="ghost" | ||
| size="icon" | ||
| onClick={() => | ||
| void sendPing(target).catch( | ||
| (error: unknown) => | ||
| showError( | ||
| error instanceof | ||
| ChatRequestError | ||
| ? error.firstError() | ||
| : 'Could not ping. Try again.', | ||
| ), | ||
| ) | ||
| } | ||
| aria-label={pingLabel} | ||
| className={cn( | ||
| '-mx-1 shrink-0 text-muted-foreground', | ||
| isCompact ? 'size-9' : 'size-10', | ||
| )} | ||
| data-test="send-ping" | ||
| > | ||
| <Vibrate className="size-5" /> | ||
| </Button> | ||
| </TooltipTrigger> | ||
| <TooltipContent>{pingLabel}</TooltipContent> | ||
| </Tooltip> | ||
| </TooltipTrigger> | ||
| <TooltipContent>{pingLabel}</TooltipContent> | ||
| </Tooltip> | ||
| )} | ||
| <CallButton | ||
| label={ | ||
| target.kind === 'direct' | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.