- added volume functionality for NPED notifications
This commit is contained in:
@@ -24,11 +24,17 @@ const SoundSettingsFields = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async (values: FormValues) => {
|
const handleSubmit = async (values: FormValues) => {
|
||||||
dispatch({ type: "UPDATE", payload: values });
|
const updatedValues = {
|
||||||
|
...values,
|
||||||
|
sightingVolume: state.sightingVolume,
|
||||||
|
NPEDsoundVolume: state.NPEDsoundVolume,
|
||||||
|
};
|
||||||
|
|
||||||
|
dispatch({ type: "UPDATE", payload: updatedValues });
|
||||||
const result = await mutation.mutateAsync({
|
const result = await mutation.mutateAsync({
|
||||||
operation: "INSERT",
|
operation: "INSERT",
|
||||||
path: "soundSettings",
|
path: "soundSettings",
|
||||||
value: values,
|
value: updatedValues,
|
||||||
});
|
});
|
||||||
if (result.reason !== "OK") {
|
if (result.reason !== "OK") {
|
||||||
toast.error("Cannot update sound settings");
|
toast.error("Cannot update sound settings");
|
||||||
|
|||||||
@@ -38,10 +38,7 @@ type SightingHistoryProps = {
|
|||||||
className?: string;
|
className?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function SightingHistoryWidget({
|
export default function SightingHistoryWidget({ className, title }: SightingHistoryProps) {
|
||||||
className,
|
|
||||||
title,
|
|
||||||
}: SightingHistoryProps) {
|
|
||||||
useNow(1000);
|
useNow(1000);
|
||||||
const { state } = useSoundContext();
|
const { state } = useSoundContext();
|
||||||
|
|
||||||
@@ -53,7 +50,7 @@ export default function SightingHistoryWidget({
|
|||||||
return getSoundFileURL(state?.hotlists?.[0]?.sound) ?? notification;
|
return getSoundFileURL(state?.hotlists?.[0]?.sound) ?? notification;
|
||||||
}, [state.hotlists]);
|
}, [state.hotlists]);
|
||||||
|
|
||||||
const { play: npedSound } = useSound(soundSrcNped);
|
const { play: npedSound } = useSound(soundSrcNped, { volume: state.NPEDsoundVolume });
|
||||||
const { play: hotlistsound } = useSound(soundSrcHotlist);
|
const { play: hotlistsound } = useSound(soundSrcHotlist);
|
||||||
const {
|
const {
|
||||||
sightings,
|
sightings,
|
||||||
@@ -98,10 +95,7 @@ export default function SightingHistoryWidget({
|
|||||||
[setSelectedSighting, setSightingModalOpen]
|
[setSelectedSighting, setSightingModalOpen]
|
||||||
);
|
);
|
||||||
|
|
||||||
const rows = useMemo(
|
const rows = useMemo(() => sightings?.filter(Boolean) as SightingType[], [sightings]);
|
||||||
() => sightings?.filter(Boolean) as SightingType[],
|
|
||||||
[sightings]
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!rows?.length) return;
|
if (!rows?.length) return;
|
||||||
@@ -129,13 +123,7 @@ export default function SightingHistoryWidget({
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [
|
}, [rows, hotlistsound, npedSound, setSightingModalOpen, setSelectedSighting]);
|
||||||
rows,
|
|
||||||
hotlistsound,
|
|
||||||
npedSound,
|
|
||||||
setSightingModalOpen,
|
|
||||||
setSelectedSighting,
|
|
||||||
]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
rows?.forEach((obj) => {
|
rows?.forEach((obj) => {
|
||||||
@@ -187,12 +175,7 @@ export default function SightingHistoryWidget({
|
|||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Card
|
<Card className={clsx("overflow-y-auto min-h-[40vh] md:min-h-[60vh] max-h-[80vh] lg:w-[40%] p-4", className)}>
|
||||||
className={clsx(
|
|
||||||
"overflow-y-auto min-h-[40vh] md:min-h-[60vh] max-h-[80vh] lg:w-[40%] p-4",
|
|
||||||
className
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<CardHeader title={title} />
|
<CardHeader title={title} />
|
||||||
<div className="flex flex-col gap-3 ">
|
<div className="flex flex-col gap-3 ">
|
||||||
{isLoading && (
|
{isLoading && (
|
||||||
@@ -215,45 +198,16 @@ export default function SightingHistoryWidget({
|
|||||||
className={`border border-gray-700 rounded-md mb-2 p-2 cursor-pointer `}
|
className={`border border-gray-700 rounded-md mb-2 p-2 cursor-pointer `}
|
||||||
onClick={() => onRowClick(obj)}
|
onClick={() => onRowClick(obj)}
|
||||||
>
|
>
|
||||||
<div
|
<div className={`flex items-center gap-3 mt-2 justify-between `}>
|
||||||
className={`flex items-center gap-3 mt-2 justify-between `}
|
|
||||||
>
|
|
||||||
<div className={`border p-1 `}>
|
<div className={`border p-1 `}>
|
||||||
<img
|
<img src={obj?.plateUrlColour || BLANK_IMG} height={48} width={200} alt="colour patch" />
|
||||||
src={obj?.plateUrlColour || BLANK_IMG}
|
|
||||||
height={48}
|
|
||||||
width={200}
|
|
||||||
alt="colour patch"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
{isHotListHit && (
|
{isHotListHit && (
|
||||||
<img
|
<img src={HotListImg} alt="hotlistHit" className="h-20 object-contain rounded-md" />
|
||||||
src={HotListImg}
|
|
||||||
alt="hotlistHit"
|
|
||||||
className="h-20 object-contain rounded-md"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{isNPEDHitA && (
|
|
||||||
<img
|
|
||||||
src={NPED_CAT_A}
|
|
||||||
alt="hotlistHit"
|
|
||||||
className="h-20 object-contain rounded-md"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{isNPEDHitB && (
|
|
||||||
<img
|
|
||||||
src={NPED_CAT_B}
|
|
||||||
alt="hotlistHit"
|
|
||||||
className="h-20 object-contain rounded-md"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{isNPEDHitC && (
|
|
||||||
<img
|
|
||||||
src={NPED_CAT_C}
|
|
||||||
alt="hotlistHit"
|
|
||||||
className="h-20 object-contain rounded-md"
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
|
{isNPEDHitA && <img src={NPED_CAT_A} alt="hotlistHit" className="h-20 object-contain rounded-md" />}
|
||||||
|
{isNPEDHitB && <img src={NPED_CAT_B} alt="hotlistHit" className="h-20 object-contain rounded-md" />}
|
||||||
|
{isNPEDHitC && <img src={NPED_CAT_C} alt="hotlistHit" className="h-20 object-contain rounded-md" />}
|
||||||
<NumberPlate motion={motionAway} vrm={obj?.vrm} />
|
<NumberPlate motion={motionAway} vrm={obj?.vrm} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -262,11 +216,7 @@ export default function SightingHistoryWidget({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
<SightingModal
|
<SightingModal isSightingModalOpen={isSightingModalOpen} handleClose={handleClose} sighting={selectedSighting} />
|
||||||
isSightingModalOpen={isSightingModalOpen}
|
|
||||||
handleClose={handleClose}
|
|
||||||
sighting={selectedSighting}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const SoundContextProvider = ({ children }: SoundContextProviderProps) => {
|
|||||||
operation: "VIEW",
|
operation: "VIEW",
|
||||||
path: "soundSettings",
|
path: "soundSettings",
|
||||||
});
|
});
|
||||||
|
console.log(result.result);
|
||||||
dispatch({ type: "UPDATE", payload: result.result });
|
dispatch({ type: "UPDATE", payload: result.result });
|
||||||
};
|
};
|
||||||
fetchSound();
|
fetchSound();
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ export function reducer(state: SoundState, action: SoundAction): SoundState {
|
|||||||
name: hotlist.name,
|
name: hotlist.name,
|
||||||
sound: hotlist.sound,
|
sound: hotlist.sound,
|
||||||
})),
|
})),
|
||||||
|
NPEDsoundVolume: action.payload.NPEDsoundVolume,
|
||||||
|
sightingVolume: action.payload.sightingVolume,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -308,6 +308,9 @@ type UpdateAction = {
|
|||||||
sightingSound: SoundValue;
|
sightingSound: SoundValue;
|
||||||
NPEDsound: SoundValue;
|
NPEDsound: SoundValue;
|
||||||
hotlists: Hotlist[];
|
hotlists: Hotlist[];
|
||||||
|
sightingVolume: number;
|
||||||
|
NPEDsoundVolume: number;
|
||||||
|
hotlistSoundVolume?: number;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user