Skip to content

Commit

Permalink
FIx DiscordRPC SetActivity second request check issue
Browse files Browse the repository at this point in the history
This caused a really rapid request from HomePage's CheckRunningGameInstance since it's requesting the same activity. Causing the RPC request flooded and makes DiscordRPC unresponsive.
  • Loading branch information
neon-nyan committed Feb 16, 2024
1 parent 53bd9b4 commit dbe2324
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class DiscordPresenceManager : IDisposable

private RichPresence _presence;
private ActivityType _activityType;
private ActivityType _lastAttemptedActivityType;
private DateTime? _lastPlayTime;
private long _lastApplicationId;
private bool _firstTimeConnect = true;
Expand Down Expand Up @@ -167,12 +166,9 @@ public void SetActivity(ActivityType activity)
if (GetAppConfigValue("EnableDiscordRPC").ToBool())
{
// Only change activity for Idle or Play status the second time we call SetActivity
if ((activity == ActivityType.Idle || activity == ActivityType.Play) && _lastAttemptedActivityType != activity)
{
_lastAttemptedActivityType = activity;
if ((activity == ActivityType.Idle || activity == ActivityType.Play) && _activityType == activity)
return;
}
_lastAttemptedActivityType = activity;

_activityType = activity;

switch (activity)
Expand Down

0 comments on commit dbe2324

Please sign in to comment.