added missing Settings functionality, moved ntfy setting
This commit is contained in:
@@ -1,18 +1,11 @@
|
||||
"use client";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getUserAPI } from "_querys/user";
|
||||
import { useAudioStore } from "_store/audioStore";
|
||||
import { usePilotConnectionStore } from "_store/pilot/connectionStore";
|
||||
import { useDmeStore } from "_store/pilot/dmeStore";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
export const useSounds = () => {
|
||||
const session = useSession();
|
||||
const { data: user } = useQuery({
|
||||
queryKey: ["user", session.data?.user.id],
|
||||
queryFn: () => getUserAPI(session.data!.user.id),
|
||||
});
|
||||
|
||||
const dmeVolume = useAudioStore((state) => state.settings.dmeVolume);
|
||||
const { page, setPage } = useDmeStore((state) => state);
|
||||
const mission = usePilotConnectionStore((state) => state.activeMission);
|
||||
|
||||
@@ -25,14 +18,14 @@ export const useSounds = () => {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (user?.settingsDmeVolume) {
|
||||
if (dmeVolume) {
|
||||
if (newMissionSound.current) {
|
||||
newMissionSound.current.volume = user.settingsDmeVolume;
|
||||
newMissionSound.current.volume = dmeVolume;
|
||||
}
|
||||
} else if (newMissionSound.current) {
|
||||
newMissionSound.current.volume = 0.8; // Default volume
|
||||
}
|
||||
}, [user?.settingsDmeVolume]);
|
||||
}, [dmeVolume]);
|
||||
|
||||
useEffect(() => {
|
||||
const timeouts: NodeJS.Timeout[] = [];
|
||||
@@ -40,7 +33,6 @@ export const useSounds = () => {
|
||||
if (page === "new-mission" && newMissionSound.current) {
|
||||
console.log("new-mission", mission);
|
||||
newMissionSound.current.currentTime = 0;
|
||||
newMissionSound.current.volume = 0.3;
|
||||
newMissionSound.current.play();
|
||||
if (mission) {
|
||||
timeouts.push(setTimeout(() => setPage({ page: "mission", mission }), 500));
|
||||
|
||||
Reference in New Issue
Block a user