A new setting, radio_in_apps, off until the person turns it on (Settings, Apps and devices, or PATCH /me/settings). With it off, the list of playlists of an OpenSubsonic app is only the playlists of the person, and a station asked for by id is not found. With it on, the stations come as playlists called Radio · Rock. - migration 0036: user_settings.radio_in_apps - usersettings, the settings API and the OpenAPI spec have the new field; the PATCH now keeps each setting apart (naming one no longer sets the other) - Settings has a switch
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { useTranslation } from 'react-i18next'
|
|
import { ApiError } from '@/api/client'
|
|
import { useMySettings, useUpdateSettings } from '@/api/discover'
|
|
import { Switch } from '@/components/ui/switch'
|
|
import { errorMessageKey } from '@/i18n'
|
|
|
|
/**
|
|
* Whether the stations of the radio are in the playlists of the apps (Feishin...). They are about two dozen, so they
|
|
* come when asked. Nothing leaves the server either way, so it asks nothing before it turns on.
|
|
*/
|
|
export default function RadioInAppsSwitch() {
|
|
const { t } = useTranslation()
|
|
const settings = useMySettings()
|
|
const update = useUpdateSettings()
|
|
const on = settings.data?.radio_in_apps === true
|
|
|
|
return (
|
|
<div className="flex max-w-xl flex-col gap-3">
|
|
<div className="flex items-center gap-4">
|
|
<Switch
|
|
checked={on}
|
|
aria-labelledby="radio-apps-label"
|
|
disabled={settings.data === undefined || update.isPending}
|
|
onClick={() => update.mutate({ radio_in_apps: !on })}
|
|
/>
|
|
<span id="radio-apps-label" className="font-semibold">
|
|
{t('devices.radio.label')}
|
|
</span>
|
|
</div>
|
|
<p className="text-sm text-muted-foreground">{t('devices.radio.help')}</p>
|
|
{update.isError && (
|
|
<p role="alert" className="text-sm text-destructive">
|
|
{t(errorMessageKey(update.error instanceof ApiError ? update.error.code : 'unknown'))}
|
|
</p>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|