Update notification sound to notification.mp3

Replaces all references to hohoho.mp3 with notification.mp3 for notification sounds across the app. Moves AudioPreloader to layout component and removes duplicate usage. Adds a guard in BroadcastDialog to prevent duplicate sends.
This commit is contained in:
g
2025-12-28 19:21:02 +00:00
parent 07fa34d831
commit 96638f968f
9 changed files with 31 additions and 24 deletions

View File

@@ -5,7 +5,7 @@ export default function Document() {
<Html lang="en"> <Html lang="en">
<Head> <Head>
<meta charSet="utf-8" /> <meta charSet="utf-8" />
<link rel="preload" href="/hohoho.mp3" as="audio" type="audio/mpeg" /> <link rel="preload" href="/notification.mp3" as="audio" type="audio/mpeg" />
</Head> </Head>
<body> <body>
<Main /> <Main />

View File

@@ -9,7 +9,6 @@ import KeepOnlineWrapper from "@/components/layout/KeepOnlineWrapper"
// Christmas theme disabled // Christmas theme disabled
// import { ChristmasDecorations } from "@/components/christmas-decorations" // import { ChristmasDecorations } from "@/components/christmas-decorations"
// import { isDecember } from "@/lib/utils/christmas" // import { isDecember } from "@/lib/utils/christmas"
import { AudioPreloader } from "@/components/audio-preloader"
const inter = Inter({ subsets: ["latin"] }) const inter = Inter({ subsets: ["latin"] })
@@ -79,7 +78,6 @@ export default function RootLayout({
<html lang="en" suppressHydrationWarning className="dark"> <html lang="en" suppressHydrationWarning className="dark">
<body className={inter.className}> <body className={inter.className}>
<ThemeProvider attribute="class" defaultTheme="dark" enableSystem disableTransitionOnChange> <ThemeProvider attribute="class" defaultTheme="dark" enableSystem disableTransitionOnChange>
<AudioPreloader />
<NotificationProvider> <NotificationProvider>
{/* Christmas decorations disabled */} {/* Christmas decorations disabled */}
<Toaster <Toaster

View File

@@ -8,7 +8,7 @@ import { useEffect } from "react"
export function AudioPreloader() { export function AudioPreloader() {
useEffect(() => { useEffect(() => {
// Preload the audio file // Preload the audio file
const audio = new Audio('/hohoho.mp3') const audio = new Audio('/notification.mp3')
audio.preload = 'auto' audio.preload = 'auto'
// Try to load it immediately // Try to load it immediately

View File

@@ -130,9 +130,9 @@ export default function ChatDetail({ chatId }: { chatId: string }) {
// Initialize audio element // Initialize audio element
useEffect(() => { useEffect(() => {
// Create audio element for notification sound // Create audio element for notification sound
audioRef.current = new Audio('/hohoho.mp3'); audioRef.current = new Audio('/notification.mp3');
// Fallback if hohoho.mp3 doesn't exist - use browser API for a simple beep // Fallback if notification.mp3 doesn't exist - use browser API for a simple beep
audioRef.current.addEventListener('error', () => { audioRef.current.addEventListener('error', () => {
audioRef.current = null; audioRef.current = null;
}); });

View File

@@ -81,7 +81,7 @@ export default function ChatTable() {
// Initialize audio element for notifications // Initialize audio element for notifications
useEffect(() => { useEffect(() => {
audioRef.current = new Audio('/hohoho.mp3'); audioRef.current = new Audio('/notification.mp3');
return () => { return () => {
if (audioRef.current) { if (audioRef.current) {
audioRef.current = null; audioRef.current = null;

View File

@@ -5,6 +5,7 @@ import { useTheme } from "next-themes"
import { usePathname } from "next/navigation" import { usePathname } from "next/navigation"
import Sidebar from "./sidebar" import Sidebar from "./sidebar"
import UnifiedNotifications from "@/components/notifications/UnifiedNotifications" import UnifiedNotifications from "@/components/notifications/UnifiedNotifications"
import { AudioPreloader } from "@/components/audio-preloader"
import type React from "react" import type React from "react"
interface LayoutProps { interface LayoutProps {
@@ -45,21 +46,24 @@ export default function Layout({ children }: LayoutProps) {
} }
return ( return (
<div className="flex h-screen"> <>
<Sidebar /> <AudioPreloader />
<div className="w-full flex flex-1 flex-col"> <div className="flex h-screen">
{!isChatDetailPage && !isAdminPage && ( <Sidebar />
<header className="h-16 border-b border-border flex items-center justify-end px-6 bg-background"> <div className="w-full flex flex-1 flex-col">
<div className="flex items-center space-x-2"> {!isChatDetailPage && !isAdminPage && (
<UnifiedNotifications /> <header className="h-16 border-b border-border flex items-center justify-end px-6 bg-background">
</div> <div className="flex items-center space-x-2">
</header> <UnifiedNotifications />
)} </div>
<main className={`flex-1 ${isChatDetailPage ? 'p-0 overflow-hidden' : 'p-6 overflow-auto'} bg-background relative`}> </header>
{children} )}
</main> <main className={`flex-1 ${isChatDetailPage ? 'p-0 overflow-hidden' : 'p-6 overflow-auto'} bg-background relative`}>
{children}
</main>
</div>
</div> </div>
</div> </>
) )
} }

View File

@@ -83,6 +83,11 @@ export default function BroadcastDialog({ open, setOpen }: BroadcastDialogProps)
}; };
const sendBroadcast = async () => { const sendBroadcast = async () => {
// Prevent duplicate sends
if (isSending) {
return;
}
if ((!broadcastMessage || !broadcastMessage.trim()) && !selectedImage) { if ((!broadcastMessage || !broadcastMessage.trim()) && !selectedImage) {
toast.warning("Please provide a message or image to broadcast."); toast.warning("Please provide a message or image to broadcast.");
return; return;

View File

@@ -33,9 +33,9 @@ export default function OrderNotifications() {
const audioRef = useRef<HTMLAudioElement | null>(null); const audioRef = useRef<HTMLAudioElement | null>(null);
useEffect(() => { useEffect(() => {
audioRef.current = new Audio('/hohoho.mp3'); audioRef.current = new Audio('/notification.mp3');
// Fallback if hohoho.mp3 doesn't exist // Fallback if notification.mp3 doesn't exist
audioRef.current.addEventListener('error', () => { audioRef.current.addEventListener('error', () => {
audioRef.current = null; audioRef.current = null;
}); });

View File

@@ -92,7 +92,7 @@ export function NotificationProvider({ children }: NotificationProviderProps) {
} }
// Initialize audio // Initialize audio
audioRef.current = new Audio('/hohoho.mp3'); audioRef.current = new Audio('/notification.mp3');
audioRef.current.addEventListener('error', () => { audioRef.current.addEventListener('error', () => {
audioRef.current = null; audioRef.current = null;
}); });