feautre/IO-3377-Add-Notification-Tone-For-Messaging - remove wav, adjust
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
// src/app/SoundWrapper.jsx
|
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useNotification } from "../contexts/Notifications/notificationContext.jsx";
|
import { useNotification } from "../contexts/Notifications/notificationContext.jsx";
|
||||||
import newMessageWav from "./../audio/messageTone.wav";
|
|
||||||
import { initNewMessageSound, unlockAudio } from "./../utils/soundManager";
|
import { initNewMessageSound, unlockAudio } from "./../utils/soundManager";
|
||||||
|
|
||||||
export default function SoundWrapper({ children }) {
|
export default function SoundWrapper({ children }) {
|
||||||
@@ -11,7 +9,7 @@ export default function SoundWrapper({ children }) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Initialize base audio
|
// 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
|
// Show a one-time prompt when a play was blocked by autoplay policy
|
||||||
const onNeedsUnlock = () => {
|
const onNeedsUnlock = () => {
|
||||||
|
|||||||
Binary file not shown.
@@ -39,11 +39,15 @@ const NotificationCenterContainer = ({ visible, onClose, bodyshop, unreadCount,
|
|||||||
return showUnreadOnly ? { ...baseWhereClause, read: { _is_null: true } } : baseWhereClause;
|
return showUnreadOnly ? { ...baseWhereClause, read: { _is_null: true } } : baseWhereClause;
|
||||||
}, [baseWhereClause, showUnreadOnly]);
|
}, [baseWhereClause, showUnreadOnly]);
|
||||||
|
|
||||||
|
// before you call useQuery, compute skip once so you can reuse it
|
||||||
|
const skipQuery = !userAssociationId || !isEmployee;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data,
|
data,
|
||||||
fetchMore,
|
fetchMore,
|
||||||
loading: queryLoading,
|
loading: queryLoading,
|
||||||
refetch
|
refetch,
|
||||||
|
error
|
||||||
} = useQuery(GET_NOTIFICATIONS, {
|
} = useQuery(GET_NOTIFICATIONS, {
|
||||||
variables: {
|
variables: {
|
||||||
limit: INITIAL_NOTIFICATIONS,
|
limit: INITIAL_NOTIFICATIONS,
|
||||||
@@ -52,14 +56,26 @@ const NotificationCenterContainer = ({ visible, onClose, bodyshop, unreadCount,
|
|||||||
},
|
},
|
||||||
fetchPolicy: "cache-and-network",
|
fetchPolicy: "cache-and-network",
|
||||||
notifyOnNetworkStatusChange: true,
|
notifyOnNetworkStatusChange: true,
|
||||||
|
errorPolicy: "all",
|
||||||
pollInterval: isConnected ? 0 : day.duration(NOTIFICATION_POLL_INTERVAL_SECONDS, "seconds").asMilliseconds(),
|
pollInterval: isConnected ? 0 : day.duration(NOTIFICATION_POLL_INTERVAL_SECONDS, "seconds").asMilliseconds(),
|
||||||
skip: !userAssociationId || !isEmployee,
|
skip: skipQuery
|
||||||
onError: (err) => {
|
|
||||||
console.error(`Error polling Notifications: ${err?.message || ""}`);
|
|
||||||
setTimeout(() => refetch(), day.duration(2, "seconds").asMilliseconds());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Replace onError with a side-effect that reacts to the hook’s `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(() => {
|
useEffect(() => {
|
||||||
const handleClickOutside = (event) => {
|
const handleClickOutside = (event) => {
|
||||||
// Prevent open + close behavior from the header
|
// Prevent open + close behavior from the header
|
||||||
|
|||||||
Reference in New Issue
Block a user