Skip to content

Commit

Permalink
fix npm build window ref
Browse files Browse the repository at this point in the history
  • Loading branch information
benagora committed Feb 7, 2025
1 parent 4947097 commit 5dba3b0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
20 changes: 15 additions & 5 deletions playground/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Action from "@/components/Layout/Action";
import { cn } from "@/lib/utils";
import Avatar from "@/components/Agent/AvatarTrulience";
import React from "react";
import { IRtcUser, rtcManager } from "@/manager";
import { IRtcUser } from "@/manager";

const DynamicRTCCard = dynamic(() => import("@/components/Dynamic/RTCCard"), {
ssr: false,
Expand All @@ -18,6 +18,7 @@ const DynamicChatCard = dynamic(() => import("@/components/Chat/ChatCard"), {
ssr: false,
});


export default function Home() {
const mobileActiveTab = useAppSelector(
(state) => state.global.mobileActiveTab
Expand All @@ -28,13 +29,22 @@ export default function Home() {
const avatarInLargeWindow = process.env.NEXT_PUBLIC_AVATAR_DESKTOP_LARGE_WINDOW?.toLowerCase() === "true";
const [remoteuser, setRemoteUser] = React.useState<IRtcUser>()

React.useEffect(() => {
rtcManager.on("remoteUserChanged", onRemoteUserChanged)

}, [])
React.useEffect(() => {
// Only runs on the client
const { rtcManager } = require("../manager/rtc/rtc");
rtcManager.on("remoteUserChanged", onRemoteUserChanged);

return () => {
rtcManager.off("remoteUserChanged", onRemoteUserChanged);
};
}, []);

//React.useEffect(() => {
// rtcManager.on("remoteUserChanged", onRemoteUserChanged)
// }, [])

const onRemoteUserChanged = (user: IRtcUser) => {
console.log("[rtc] onRemoteUserChanged", user)
if (useTrulienceAvatar) {
user.audioTrack?.stop();
}
Expand Down
3 changes: 0 additions & 3 deletions playground/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export function cn(...inputs: ClassValue[]) {
}

export function useIsMobileScreen(breakpoint?: string) {
/*
const [isMobileScreen, setIsMobileScreen] = React.useState(false);

React.useEffect(() => {
Expand All @@ -20,6 +19,4 @@ export function useIsMobileScreen(breakpoint?: string) {
}, [breakpoint]);

return isMobileScreen;
*/
return false;
}

0 comments on commit 5dba3b0

Please sign in to comment.