Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Oct 14, 2024
1 parent 5ccc27b commit 6ae0ccc
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
23 changes: 22 additions & 1 deletion package-lock.json

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

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
"@egoist/tailwindcss-icons": "^1.4.0",
"@hookform/resolvers": "^3.3.2",
"@iconify-json/heroicons": "^1.1.15",
"@types/uuid": "^10.0.0",
"axios": "^1.7.7",
"eventemitter3": "^5.0.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"simli-client": "^1.1.0"
"simli-client": "^1.1.0",
"uuid": "^10.0.0"
},
"devDependencies": {
"@tailwindcss/aspect-ratio": "^0.4.2",
Expand Down Expand Up @@ -109,4 +111,4 @@
}
]
}
}
}
24 changes: 24 additions & 0 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useCallback, useEffect, useRef, useState } from 'react'
import ReactDOM from 'react-dom/client'
import axios from 'axios'
import { v4 as uuidv4 } from 'uuid'

import { SimliClient } from './SimliClient'

Expand Down Expand Up @@ -33,6 +34,26 @@ const App = () => {
const analyserRef = useRef<any | null>(null)
const microphoneRef = useRef<any | null>(null)

// TODO: populate these from localStorage if roomid and useruuid are set, otherwise generate a random uuid
const [roomID, setRoomID] = useState('')
const [userUUID, setUserUUID] = useState('')

useEffect(() => {
const storedRoomID = localStorage.getItem('roomID')
const storedUserUUID = localStorage.getItem('userUUID')
if (storedRoomID && storedUserUUID) {
setRoomID(storedRoomID)
setUserUUID(storedUserUUID)
} else {
const newRoomID = uuidv4()
const newUserUUID = uuidv4()
setRoomID(newRoomID)
setUserUUID(newUserUUID)
localStorage.setItem('roomID', newRoomID)
localStorage.setItem('userUUID', newUserUUID)
}
}, [])

const initializeSimliClient = useCallback(() => {
if (videoRef.current && audioRef.current) {
const SimliConfig = {
Expand Down Expand Up @@ -112,6 +133,9 @@ const App = () => {
completionEndpoint + '/ruby/message',
{
text,
roomId: roomID,
userId: userUUID,
userName: 'User',
},
{
cancelToken: cancelTokenRef.current.token,
Expand Down

0 comments on commit 6ae0ccc

Please sign in to comment.