mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-02 17:32:50 +08:00
Add per-event checkbox to mute individual sound notifications
Lets users disable e.g. join/leave chimes while keeping others on, without touching the master sounds toggle. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7a69d8602c
commit
234feb4d55
3 files changed
+32
No files matched your search
@@ -14,10 +14,12 @@ import {
|
||||
SOUND_EVENTS,
|
||||
clearCustomSound,
|
||||
loadCustomSound,
|
||||
loadEventSoundEnabled,
|
||||
loadSoundsEnabled,
|
||||
loadSoundsVolume,
|
||||
playSound,
|
||||
saveCustomSound,
|
||||
saveEventSoundEnabled,
|
||||
saveSoundsEnabled,
|
||||
saveSoundsVolume,
|
||||
setSoundsOutputDevice,
|
||||
@@ -1048,6 +1050,9 @@ function SoundsPanel() {
|
||||
const [enabled, setEnabled] = useState(() => loadSoundsEnabled());
|
||||
const [volume, setVolume] = useState(() => loadSoundsVolume());
|
||||
const [customNames, setCustomNames] = useState<Partial<Record<SoundEventId, string>>>({});
|
||||
const [eventEnabled, setEventEnabled] = useState<Record<SoundEventId, boolean>>(() =>
|
||||
Object.fromEntries(SOUND_EVENTS.map((id) => [id, loadEventSoundEnabled(id)])) as Record<SoundEventId, boolean>
|
||||
);
|
||||
const fileInputRef = useRef<HTMLInputElement | null>(null);
|
||||
const uploadTargetRef = useRef<SoundEventId | null>(null);
|
||||
|
||||
@@ -1078,6 +1083,12 @@ function SoundsPanel() {
|
||||
saveSoundsVolume(v);
|
||||
};
|
||||
|
||||
const handleToggleEventEnabled = (event: SoundEventId) => {
|
||||
const next = !eventEnabled[event];
|
||||
setEventEnabled((prev) => ({ ...prev, [event]: next }));
|
||||
saveEventSoundEnabled(event, next);
|
||||
};
|
||||
|
||||
const handleUploadClick = (event: SoundEventId) => {
|
||||
uploadTargetRef.current = event;
|
||||
fileInputRef.current?.click();
|
||||
@@ -1125,6 +1136,14 @@ function SoundsPanel() {
|
||||
<tbody>
|
||||
{SOUND_EVENTS.map((eventId) => (
|
||||
<tr key={eventId}>
|
||||
<td>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={eventEnabled[eventId]}
|
||||
onChange={() => handleToggleEventEnabled(eventId)}
|
||||
title={t("sounds.eventEnable")}
|
||||
/>
|
||||
</td>
|
||||
<td>{t(`sounds.event.${eventId}`)}</td>
|
||||
<td className="ts-options-sounds-source">
|
||||
{customNames[eventId] ? t("sounds.custom", { name: customNames[eventId]! }) : t("sounds.default")}
|
||||
|
||||
Reference in new issue
Block a user