Implement sound settings update and integrate sound context in sightings widget
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import type { SightingType } from "../../types/types";
|
||||
import { BLANK_IMG } from "../../utils/utils";
|
||||
import { BLANK_IMG, getSoundFileName } from "../../utils/utils";
|
||||
import NumberPlate from "../PlateStack/NumberPlate";
|
||||
import Card from "../UI/Card";
|
||||
import CardHeader from "../UI/CardHeader";
|
||||
@@ -15,6 +15,7 @@ import NPED_CAT_C from "/NPED_Cat_C.svg";
|
||||
import popup from "../../assets/sounds/ui/popup_open.mp3";
|
||||
import { useSound } from "react-sounds";
|
||||
import { useNPEDContext } from "../../context/NPEDUserContext";
|
||||
import { useSoundContext } from "../../context/SoundContext";
|
||||
|
||||
function useNow(tickMs = 1000) {
|
||||
const [, setNow] = useState(() => Date.now());
|
||||
@@ -39,7 +40,13 @@ export default function SightingHistoryWidget({
|
||||
title,
|
||||
}: SightingHistoryProps) {
|
||||
useNow(1000);
|
||||
const { play } = useSound(popup);
|
||||
const { state } = useSoundContext();
|
||||
|
||||
const soundSrc = useMemo(() => {
|
||||
return getSoundFileName(state.sightingSound) ?? popup;
|
||||
}, [state.sightingSound]);
|
||||
|
||||
const { play } = useSound(soundSrc);
|
||||
const {
|
||||
sightings,
|
||||
setSelectedSighting,
|
||||
|
||||
Reference in New Issue
Block a user