feautre/IO-3377-Add-Notification-Tone-For-Messaging - remove wav, adjust

This commit is contained in:
Dave
2025-09-24 13:52:55 -04:00
parent dfd88308e0
commit e11260e8fc
3 changed files with 23 additions and 9 deletions

View File

@@ -1,8 +1,6 @@
// src/app/SoundWrapper.jsx
import { useEffect } from "react";
import { useTranslation } from "react-i18next";
import { useNotification } from "../contexts/Notifications/notificationContext.jsx";
import newMessageWav from "./../audio/messageTone.wav";
import { initNewMessageSound, unlockAudio } from "./../utils/soundManager";
export default function SoundWrapper({ children }) {
@@ -11,7 +9,7 @@ export default function SoundWrapper({ children }) {
useEffect(() => {
// Initialize base audio
initNewMessageSound(newMessageWav, 0.7);
initNewMessageSound("https://images.imex.online/app/messageTone.wav", 0.7);
// Show a one-time prompt when a play was blocked by autoplay policy
const onNeedsUnlock = () => {

Binary file not shown.

View File

@@ -39,11 +39,15 @@ const NotificationCenterContainer = ({ visible, onClose, bodyshop, unreadCount,
return showUnreadOnly ? { ...baseWhereClause, read: { _is_null: true } } : baseWhereClause;
}, [baseWhereClause, showUnreadOnly]);
// before you call useQuery, compute skip once so you can reuse it
const skipQuery = !userAssociationId || !isEmployee;
const {
data,
fetchMore,
loading: queryLoading,
refetch
refetch,
error
} = useQuery(GET_NOTIFICATIONS, {
variables: {
limit: INITIAL_NOTIFICATIONS,
@@ -52,14 +56,26 @@ const NotificationCenterContainer = ({ visible, onClose, bodyshop, unreadCount,
},
fetchPolicy: "cache-and-network",
notifyOnNetworkStatusChange: true,
errorPolicy: "all",
pollInterval: isConnected ? 0 : day.duration(NOTIFICATION_POLL_INTERVAL_SECONDS, "seconds").asMilliseconds(),
skip: !userAssociationId || !isEmployee,
onError: (err) => {
console.error(`Error polling Notifications: ${err?.message || ""}`);
setTimeout(() => refetch(), day.duration(2, "seconds").asMilliseconds());
}
skip: skipQuery
});
// Replace onError with a side-effect that reacts to the hooks `error`
useEffect(() => {
if (!error || skipQuery) return;
console.error(`Error polling Notifications: ${error?.message || ""}`);
const t = setTimeout(() => {
// Guard: if component unmounted or query now skipped, do nothing
if (!skipQuery) {
refetch().catch((e) => console.error("Refetch failed:", e?.message || e));
}
}, day.duration(2, "seconds").asMilliseconds());
return () => clearTimeout(t);
}, [error, refetch, skipQuery]);
useEffect(() => {
const handleClickOutside = (event) => {
// Prevent open + close behavior from the header