diff --git a/src/routes/Settings/General/General.tsx b/src/routes/Settings/General/General.tsx index ba137a101..d3f5b8e33 100644 --- a/src/routes/Settings/General/General.tsx +++ b/src/routes/Settings/General/General.tsx @@ -73,8 +73,26 @@ const General = forwardRef(({ profile }: Props, ref) => { const onToggleDiscord = useCallback(() => { if (isDiscordConnected) { disconnectDiscord(); + core.transport.dispatch({ + action: 'Ctx', + args: { + action: 'UpdateSettings', + args: { + discordRpcEnabled: false + } + } + }); } else { connectDiscord(); + core.transport.dispatch({ + action: 'Ctx', + args: { + action: 'UpdateSettings', + args: { + discordRpcEnabled: true + } + } + }); } }, [isDiscordConnected, connectDiscord, disconnectDiscord]); @@ -84,6 +102,12 @@ const General = forwardRef(({ profile }: Props, ref) => { } }, [dataExport.exportUrl]); + useEffect(() => { + if (discordAvailable && profile.settings.discordRpcEnabled && !isDiscordConnected) { + connectDiscord(); + } + }, [discordAvailable, profile.settings.discordRpcEnabled]); + useEffect(() => { if (isTraktAuthenticated && traktAuthStarted) { core.transport.dispatch({ diff --git a/src/types/models/Ctx.d.ts b/src/types/models/Ctx.d.ts index e6c0e14e4..3dc6e825f 100644 --- a/src/types/models/Ctx.d.ts +++ b/src/types/models/Ctx.d.ts @@ -18,6 +18,7 @@ type Settings = { audioPassthrough: boolean, autoFrameRateMatching: boolean, bingeWatching: boolean, + discordRpcEnabled: boolean, hardwareDecoding: boolean, videoMode: string | null, escExitFullscreen: boolean,