Skip to content

Commit

Permalink
fix: Fix Main Stage in React Hello World
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyward committed Aug 27, 2024
1 parent f6bb2c0 commit 3e7e31d
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 18 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { useEffect } from 'react';
import { meet } from '@googleworkspace/meet-addons/meet.addons';
import { CLOUD_PROJECT_NUMBER } from '../constants';

/**
* See: https://developers.google.com/meet/add-ons/guides/overview#main-stage
*/
function MainStage() {
useEffect(() => {
/**
* Prepares the Add-on Main Stage Client, which signals that the add-on has
* successfully launched in the main stage.
*/
async function initializeMainStage() {
const session = await meet.addon.createAddonSession({
cloudProjectNumber: CLOUD_PROJECT_NUMBER,
});
await session.createSidePanelClient();
}
initializeMainStage();
}, []);


return (
<>
<div>This is the Add-on Main Stage. Everyone in the call can see this.</div>
<div>Hello, world!</div>
</>
)
}

export default MainStage;
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import { useEffect, useState } from 'react';
import { meet } from '@googleworkspace/meet-addons/meet.addons';
import { CLOUD_PROJECT_NUMBER, MAIN_STAGE_URL } from '../constants';

function Setup() {
/**
* See: https://developers.google.com/meet/add-ons/guides/overview#side-panel
*/
function SidePanel() {
const [sidePanelClient, setSidePanelClient] = useState(null);

// Launches the main stage when the main button is clicked.
async function startCollaboration(e) {
if (!sidePanelClient) {
throw new Error("Side Panel is not yet initialized!");
Expand All @@ -13,6 +17,9 @@ function Setup() {
}

useEffect(() => {
/**
* Prepares the Add-on Side Panel Client.
*/
async function setUpAddon() {
const session = await meet.addon.createAddonSession({
cloudProjectNumber: CLOUD_PROJECT_NUMBER,
Expand All @@ -30,4 +37,4 @@ function Setup() {
)
}

export default Setup;
export default SidePanel;
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import Game from './components/Game.tsx'
import MainStage from './components/MainStage.tsx'

// Renders the MainStage as a React component.
createRoot(document.getElementById('root')!).render(
<StrictMode>
<Game />
<MainStage />
</StrictMode>,
)
)
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import Setup from './components/Setup.tsx'
import SidePanel from './components/SidePanel.tsx'

// Renders the SidePanel as a React component.
createRoot(document.getElementById('root')!).render(
<StrictMode>
<Setup />
<SidePanel />
</StrictMode>,
)
)

0 comments on commit 3e7e31d

Please sign in to comment.