mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-02 02:43:33 +00:00
enable notify, simplify use-scrobble with types, remove unused check
This commit is contained in:
parent
b219c900ca
commit
e00aeb2b67
4 changed files with 76 additions and 12 deletions
|
|
@ -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} />;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue