refactor: add persistance

This commit is contained in:
Timothy Z. 2025-12-22 13:40:47 +01:00
parent e093583889
commit bbbf505e10
2 changed files with 25 additions and 0 deletions

View file

@ -73,8 +73,26 @@ const General = forwardRef<HTMLDivElement, Props>(({ 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<HTMLDivElement, Props>(({ profile }: Props, ref) => {
}
}, [dataExport.exportUrl]);
useEffect(() => {
if (discordAvailable && profile.settings.discordRpcEnabled && !isDiscordConnected) {
connectDiscord();
}
}, [discordAvailable, profile.settings.discordRpcEnabled]);
useEffect(() => {
if (isTraktAuthenticated && traktAuthStarted) {
core.transport.dispatch({

View file

@ -18,6 +18,7 @@ type Settings = {
audioPassthrough: boolean,
autoFrameRateMatching: boolean,
bingeWatching: boolean,
discordRpcEnabled: boolean,
hardwareDecoding: boolean,
videoMode: string | null,
escExitFullscreen: boolean,