fix duplicate sockets, fix dll build error

This commit is contained in:
michalcourson
2026-03-01 10:23:54 -05:00
parent 39395fd846
commit 801966e8d8
8 changed files with 588 additions and 146 deletions

View File

@ -28,15 +28,14 @@ function MainPage() {
const [newCollectionOpen, setNewCollectionOpen] = useState(false);
const [newCollectionName, setNewCollectionName] = useState<string>('');
const navigate = useNavigate();
const [socket, setSocket] = useState<any>(null);
useEffect(() => {}, []);
useEffect(() => {
let newSocket: any = null;
const initializeSocket = async () => {
const baseUrl = await getBaseUrl();
const newSocket = io(baseUrl);
setSocket(newSocket);
newSocket = io(baseUrl);
newSocket.on('connect', () => {
console.log('Connected to WebSocket server');
});
@ -56,18 +55,14 @@ function MainPage() {
});
};
initializeSocket();
// const fetchMetadata = async () => {
// try {
// const response = await apiFetch('meta');
// const data = await response.json();
// dispatch({ type: 'metadata/setAllData', payload: data });
// } catch (error) {
// console.error('Error fetching metadata:', error);
// }
// };
// fetchMetadata();
// const intervalId = setInterval(fetchMetadata, 5000);
// return () => clearInterval(intervalId);
return () => {
if (newSocket) {
newSocket.off('connect');
newSocket.off('full_data');
newSocket.off('new_clip');
newSocket.disconnect();
}
};
}, [dispatch]);
useEffect(() => {