fix: integrate final user-provided notification sound and clean up unused assets
All checks were successful
Build and Deploy / build-and-push (push) Successful in 2m4s

- Replaced placeholder audio with the requested high-quality sound file.

- Removed deprecated audio files from the public directory.
This commit is contained in:
Cauê Faleiros
2026-03-16 11:03:35 -03:00
parent b2f75562e7
commit 76c974bcd0
3 changed files with 25 additions and 19 deletions

View File

@@ -1,12 +1,27 @@
Look at line 354: `if (req.user.role !== 'super_admin' && rows[0].tenant_id !== req.user.tenant_id) {` Look at `playNotificationSound`:
What if `req.user.tenant_id` is null (which it is for some system admins)? ```javascript
But `rows[0].tenant_id` could be something else. That just returns 403. const playNotificationSound = () => {
What if `rows` is empty? if (currentUser?.sound_enabled !== false && audioRef.current) {
Line 353: `if (rows.length === 0) return res.status(404).json({ error: 'Not found' });` // Reset time to 0 to allow rapid replays
What if `req.user` is undefined? (Should be caught by middleware). audioRef.current.currentTime = 0;
const playPromise = audioRef.current.play();
```
Is `currentUser` loaded when `loadNotifications` fires for the first time after `isInitialLoadRef` is false?
Yes, `useEffect` calls `fetchCurrentUser()`, which sets `currentUser`.
Wait, the user says the error is: Wait. `setInterval` uses a closure over the state!
`https://fasto.blyzer.com.br/api/users/u_71657ec7` ```javascript
And it returns `500`. useEffect(() => {
fetchCurrentUser();
loadNotifications();
const interval = setInterval(loadNotifications, 10000);
return () => clearInterval(interval);
}, [navigate]);
```
Oh my god. The `setInterval` callback `loadNotifications` captures the *initial* state variables, including `currentUser`, which is `null` on the first render!
If `currentUser` is `null` inside the closure, `currentUser?.sound_enabled !== false` evaluates to `true !== false` which is `true`. So that's not blocking it.
BUT `audioRef.current` might not have been rendered yet? No, `audioRef` is a ref, so it mutates in place. The closure always sees the latest `audioRef.current`.
Let's log the exact error inside the catch block in the backend. So why does it fail or not play?
Is the browser policy blocking it silently without logging?
Let's add a robust, standalone Audio approach that doesn't rely on the DOM tag if it fails, or maybe just force a click handler to "unlock" the audio context.

View File

@@ -1,9 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>

Binary file not shown.