diff --git a/server/src/index.ts b/server/src/index.ts index a5cdcf0..62ce229 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -649,6 +649,19 @@ app.post('/api/badges/assign', requireAdmin, (req: Request, res: Response) => { res.json({ ok: true, fileBadges: fb }); }); +// Alle Custom-Badges für die angegebenen Dateien entfernen +app.post('/api/badges/clear', requireAdmin, (req: Request, res: Response) => { + const { files } = req.body as { files?: string[] }; + if (!Array.isArray(files) || files.length === 0) return res.status(400).json({ error: 'files[] erforderlich' }); + const fb = persistedState.fileBadges ?? {}; + for (const rel of files) { + delete fb[rel]; + } + persistedState.fileBadges = fb; + writePersistedState(persistedState); + res.json({ ok: true, fileBadges: fb }); +}); + app.get('/api/channels', (_req: Request, res: Response) => { if (!client.isReady()) return res.status(503).json({ error: 'Bot noch nicht bereit' }); diff --git a/web/src/App.tsx b/web/src/App.tsx index eb82a66..9714382 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useMemo, useRef, useState } from 'react'; import ReactDOM from 'react-dom'; -import { fetchChannels, fetchSounds, playSound, setVolumeLive, getVolume, adminStatus, adminLogin, adminLogout, adminDelete, adminRename, playUrl, fetchCategories, createCategory, assignCategories, assignBadges, updateCategory, deleteCategory } from './api'; +import { fetchChannels, fetchSounds, playSound, setVolumeLive, getVolume, adminStatus, adminLogin, adminLogout, adminDelete, adminRename, playUrl, fetchCategories, createCategory, assignCategories, assignBadges, clearBadges, updateCategory, deleteCategory } from './api'; import type { VoiceChannelInfo, Sound, Category } from './types'; import { getCookie, setCookie } from './cookies'; @@ -475,28 +475,18 @@ export default function App() { )} -
- - {showEmojiRemovePicker && ( -
- {EMOJIS.map((e, i)=> ( - - ))} -
- )} -
+ )} diff --git a/web/src/api.ts b/web/src/api.ts index 02d20ca..df6b535 100644 --- a/web/src/api.ts +++ b/web/src/api.ts @@ -63,6 +63,15 @@ export async function assignBadges(files: string[], add: string[], remove: strin return res.json(); } +export async function clearBadges(files: string[]) { + const res = await fetch(`${API_BASE}/badges/clear`, { + method: 'POST', headers: { 'Content-Type': 'application/json' }, credentials: 'include', + body: JSON.stringify({ files }) + }); + if (!res.ok) throw new Error('Badges löschen fehlgeschlagen'); + return res.json(); +} + export async function fetchChannels(): Promise { const res = await fetch(`${API_BASE}/channels`); if (!res.ok) throw new Error('Fehler beim Laden der Channels');