feat(volume): serverseitig pro Guild persistieren (state.json), API GET/POST /api/volume; Frontend lädt gespeicherte Lautstärke
This commit is contained in:
parent
fee1feaca4
commit
beeffb7605
3 changed files with 71 additions and 5 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { fetchChannels, fetchSounds, playSound, setVolumeLive } from './api';
|
||||
import { fetchChannels, fetchSounds, playSound, setVolumeLive, getVolume } from './api';
|
||||
import type { VoiceChannelInfo, Sound } from './types';
|
||||
import { getCookie, setCookie } from './cookies';
|
||||
|
||||
|
|
@ -68,7 +68,17 @@ export default function App() {
|
|||
}, [theme]);
|
||||
|
||||
useEffect(() => {
|
||||
if (selected) localStorage.setItem('selectedChannel', selected);
|
||||
(async () => {
|
||||
if (selected) {
|
||||
localStorage.setItem('selectedChannel', selected);
|
||||
// gespeicherte Lautstärke vom Server laden
|
||||
try {
|
||||
const [guildId] = selected.split(':');
|
||||
const v = await getVolume(guildId);
|
||||
setVolume(v);
|
||||
} catch {}
|
||||
}
|
||||
})();
|
||||
}, [selected]);
|
||||
|
||||
const filtered = useMemo(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue