mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-08 04:50:12 +02:00
enable notify, simplify use-scrobble with types, remove unused check
This commit is contained in:
@@ -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} />;
|
||||
|
||||
Reference in New Issue
Block a user