UI: Prevent desynced RPC when toggling it off/on while in-game

This commit is contained in:
Evan Husted 2025-01-16 09:52:01 -06:00
parent 6a4bc02d7a
commit abfbc6f4bc

View File

@ -1,4 +1,5 @@
using DiscordRPC; using DiscordRPC;
using Gommon;
using Humanizer; using Humanizer;
using Humanizer.Localisation; using Humanizer.Localisation;
using Ryujinx.Ava.Utilities.AppLibrary; using Ryujinx.Ava.Utilities.AppLibrary;
@ -75,11 +76,23 @@ namespace Ryujinx.Ava
_discordClient = new DiscordRpcClient(ApplicationId); _discordClient = new DiscordRpcClient(ApplicationId);
_discordClient.Initialize(); _discordClient.Initialize();
_discordClient.SetPresence(_discordPresenceMain);
Use(TitleIDs.CurrentApplication);
} }
} }
} }
public static void Use(Optional<string> titleId)
{
if (titleId.TryGet(out string tid))
SwitchToPlayingState(
ApplicationLibrary.LoadAndSaveMetaData(tid),
Switch.Shared.Processes.ActiveApplication
);
else
SwitchToMainState();
}
private static void SwitchToPlayingState(ApplicationMetadata appMeta, ProcessResult procRes) private static void SwitchToPlayingState(ApplicationMetadata appMeta, ProcessResult procRes)
{ {
_discordClient?.SetPresence(new RichPresence _discordClient?.SetPresence(new RichPresence