enable notify, simplify use-scrobble with types, remove unused check

This commit is contained in:
Kendall Garner 2025-07-07 19:25:25 -07:00
parent b219c900ca
commit e00aeb2b67
No known key found for this signature in database
GPG key ID: 9355F387FE765C94
4 changed files with 76 additions and 12 deletions

View file

@ -8,6 +8,7 @@ import { usePlaybackSettings, useSettingsStoreActions } from '/@/renderer/store/
import { NumberInput } from '/@/shared/components/number-input/number-input';
import { Slider } from '/@/shared/components/slider/slider';
import { Switch } from '/@/shared/components/switch/switch';
import { toast } from '/@/shared/components/toast/toast';
export const ScrobbleSettings = () => {
const { t } = useTranslation();
@ -95,6 +96,52 @@ export const ScrobbleSettings = () => {
}),
title: t('setting.minimumScrobbleSeconds', { postProcess: 'sentenceCase' }),
},
{
control: (
<Switch
aria-label="Toggle notify"
defaultChecked={settings.scrobble.notify}
onChange={async (e) => {
if (Notification.permission === 'denied') {
toast.error({
message: t('error.notificationDenied', {
postProcess: 'sentenceCase',
}),
});
return;
}
if (Notification.permission !== 'granted') {
const permissions = await Notification.requestPermission();
if (permissions !== 'granted') {
toast.error({
message: t('error.notificationDenied', {
postProcess: 'sentenceCase',
}),
});
return;
}
}
setSettings({
playback: {
...settings,
scrobble: {
...settings.scrobble,
notify: e.currentTarget.checked,
},
},
});
}}
/>
),
description: t('setting.notify', {
context: 'description',
postProcess: 'sentenceCase',
}),
isHidden: !('Notification' in window),
title: t('setting.notify', { postProcess: 'sentenceCase' }),
},
];
return <SettingsSection options={scrobbleOptions} />;