// Bearbeitbare Schnellzugriff-Links (Jellyfin, Audiobookshelf, Homer), einmal geladen und überall verfügbar import { createContext, useCallback, useContext, useEffect, useState } from 'react'; import { api } from './api.js'; export const LINK_SERVICES = [ { key: 'jellyfin', name: 'Jellyfin', description: 'Filme & Serien', placeholder: 'http://jellyfin.local:8096' }, { key: 'audiobookshelf', name: 'Audiobookshelf', description: 'Hörbücher & Podcasts', placeholder: 'http://audiobookshelf.local:13378' }, { key: 'homer', name: 'Homer', description: 'Server-Startseite', placeholder: 'http://homer.local:8080' }, ]; const LinksContext = createContext({ links: {}, saveLinks: async () => {} }); export function LinksProvider({ children }) { const [links, setLinks] = useState({}); useEffect(() => { api('GET', '/api/links').then(setLinks).catch(() => {}); }, []); const saveLinks = useCallback(async (values) => { const updated = await api('PUT', '/api/links', values); setLinks(updated); return updated; }, []); return {children}; } export const useLinks = () => useContext(LinksContext);