- storing changes for now

This commit is contained in:
2025-10-28 09:54:29 +00:00
parent a64fa76ecb
commit 907555cb0d
4 changed files with 47 additions and 41 deletions

View File

@@ -6,15 +6,11 @@ import { useCameraBlackboard } from "../../../hooks/useCameraBlackboard";
import { toast } from "sonner";
import SliderComponent from "../../UI/Slider";
import { useFileUpload } from "../../../hooks/useFileUpload";
import { useSound } from "react-sounds";
import { useMemo } from "react";
import { getSoundFileURL } from "../../../utils/utils";
const SoundSettingsFields = () => {
const { state, dispatch } = useSoundContext();
const { mutation } = useCameraBlackboard();
const { query } = useFileUpload({
const { query: fileQuery } = useFileUpload({
queryKey: state.sightingSound ? [state.sightingSound] : undefined,
});
@@ -31,31 +27,8 @@ const SoundSettingsFields = () => {
hotlistSound: state.hotlistSound ?? "notification",
hotlists,
};
const soundSrc = useMemo(() => {
if (state?.sightingSound?.includes(".mp3") || state.sightingSound?.includes(".wav")) {
const file = state.soundOptions?.find((item) => item.name === state.sightingSound);
query?.refetch();
console.log(query?.data);
// set state
dispatch({ type: "UPLOADEDSOUND", payload: query?.data });
if (!query?.data) {
query?.refetch();
return;
}
//get from state?
if (!state.uploadedSound) return "switchSound";
const url = URL.createObjectURL(state.uploadedSound);
return url ?? "switchSound";
}
return getSoundFileURL(state?.sightingSound) ?? "switchSound";
}, [state.sightingSound, state.soundOptions]);
const { play } = useSound(soundSrc);
const handletest = () => {
console.log(state.uploadedSound);
play();
const handleSyce = () => {
fileQuery?.refetch();
};
const handleSubmit = async (values: FormValues) => {
const updatedValues = {
@@ -176,7 +149,7 @@ const SoundSettingsFields = () => {
>
Save Settings
</button>
<button onClick={handletest} type="button">
<button onClick={handleSyce} type="button">
click
</button>
</Form>