Skip to content

Commit

Permalink
browser-sdk: Add "meeting_end" embed event
Browse files Browse the repository at this point in the history
Allow customers to take action whenever a meeting has been explicitly
ended by the host.
  • Loading branch information
havardholvik committed Mar 19, 2024
1 parent 748ec2c commit 0092158
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/sharp-ducks-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@whereby.com/browser-sdk": minor
---

Add support for meeting_end event on embed element
1 change: 1 addition & 0 deletions packages/browser-sdk/src/lib/embed/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ interface WherebyEmbedElementEventMap {
leave: CustomEvent<{ removed: boolean }>;
participant_join: CustomEvent<{ participant: { metadata: string } }>;
participant_leave: CustomEvent<{ participant: { metadata: string } }>;
meeting_end: CustomEvent;
microphone_toggle: CustomEvent<{ enabled: boolean }>;
camera_toggle: CustomEvent<{ enabled: boolean }>;
chat_toggle: CustomEvent<{ open: boolean }>;
Expand Down
8 changes: 7 additions & 1 deletion packages/browser-sdk/src/stories/prebuilt-ui.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const WherebyEmbed = ({
}: Partial<WherebyEmbedAttributes>) => {
const elmRef = useRef<WherebyEmbedElement>(null);
const [cameraEnabled, setCameraEnabled] = useState(video);
const [meetingEnded, setMeetingEnded] = useState(false);

useEffect(() => {
const element = elmRef.current;
Expand All @@ -86,11 +87,16 @@ const WherebyEmbed = ({
const cameraEnabled = e.detail.enabled;
setCameraEnabled(cameraEnabled);
});

element?.addEventListener("meeting_end", () => {
setMeetingEnded(true);
});
}, []);

return (
<p>
<span>Camera: {cameraEnabled ? "ENABLED" : "DISABLED"}</span>
<p>Camera: {cameraEnabled ? "ENABLED" : "DISABLED"}</p>
<p>Meeting ended: {meetingEnded ? "TRUE" : "FALSE"}</p>
<whereby-embed
audio={offOn(audio)}
avatarUrl={avatarUrl}
Expand Down

0 comments on commit 0092158

Please sign in to comment.