mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-08-13 16:57:51 +00:00
refactor(General): simplify discord toggle
This commit is contained in:
parent
f5138412a0
commit
906df6cffb
1 changed files with 15 additions and 13 deletions
|
|
@ -62,18 +62,21 @@ const General = forwardRef<HTMLDivElement, Props>(({ profile }: Props, ref) => {
|
|||
}
|
||||
}, [isTraktAuthenticated, profile.auth]);
|
||||
|
||||
const onToggleDiscord = useCallback(() => {
|
||||
core.transport.dispatch({
|
||||
action: 'Ctx',
|
||||
args: {
|
||||
action: 'UpdateSettings',
|
||||
const discordToggle = useMemo(() => ({
|
||||
checked: profile.settings.discordRpcEnabled === true,
|
||||
onClick: () => {
|
||||
core.transport.dispatch({
|
||||
action: 'Ctx',
|
||||
args: {
|
||||
...profile.settings,
|
||||
discordRpcEnabled: !profile.settings.discordRpcEnabled
|
||||
action: 'UpdateSettings',
|
||||
args: {
|
||||
...profile.settings,
|
||||
discordRpcEnabled: !profile.settings.discordRpcEnabled
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}, [profile.settings]);
|
||||
});
|
||||
}
|
||||
}), [profile.settings]);
|
||||
|
||||
useEffect(() => {
|
||||
if (dataExport.exportUrl) {
|
||||
|
|
@ -150,11 +153,10 @@ const General = forwardRef<HTMLDivElement, Props>(({ profile }: Props, ref) => {
|
|||
</Option>
|
||||
{
|
||||
discord.available &&
|
||||
<Option className={styles['discord-container']} icon={'discord'} label={t('SETTINGS_DISCORD', { defaultValue: 'Discord Rich Presence' })}>
|
||||
<Option className={styles['discord-container']} icon={'discord'} label={'SETTINGS_DISCORD'}>
|
||||
<Toggle
|
||||
checked={profile.settings.discordRpcEnabled === true}
|
||||
tabIndex={-1}
|
||||
onClick={onToggleDiscord}
|
||||
{...discordToggle}
|
||||
/>
|
||||
</Option>
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue