gbclient/app/chat/components/sound-initializer.tsx

30 lines
710 B
TypeScript
Raw Normal View History

"use client";
import React, { useEffect, useState } from 'react';
export function SoundInitializer({ children }) {
const [isReady, setIsReady] = useState(false);
const [error, setError] = useState(null);
useEffect(() => {
const initializeSounds = async () => {
try {
// Simulate sound initialization
setIsReady(true);
} catch (err) {
setError(err.message || 'Failed to initialize sounds');
}
};
initializeSounds();
}, []);
if (error) {
return <div className="error-container"><p>Error: {error}</p></div>;
}
if (!isReady) {
return <div className="loading-container"><p>Loading sounds...</p></div>;
}
return <>{children}</>;
}