Do not emit new game added event without a clear need

This callback is emitted by Steam with new licenses available, but also in many other situations, such as when somebody else logs in into the account (e.g. Steam deck, another PC), when somebody deletes licenses, and even on PICS changes from time to time, not to mention other cases I forgot/don't know about.

It seems silly to restart cards farmer every time, I believe we can assume that user won't delete license for a game we're farming, and even if he does, we'll catch that in 30 minutes or so anyway, while not restarting the farming every time Steam feels like sending us licenses.
This commit is contained in:
JustArchi
2022-06-15 18:50:32 +02:00
parent 164d9330f0
commit bd0f1779d6

View File

@@ -2371,6 +2371,7 @@ public sealed class Bot : IAsyncDisposable {
Trading.OnDisconnected();
FirstTradeSent = false;
OwnedPackageIDs = ImmutableDictionary<uint, (EPaymentMethod PaymentMethod, DateTime TimeCreated)>.Empty;
await PluginsCore.OnBotDisconnected(this, callback.UserInitiated ? EResult.OK : lastLogOnResult).ConfigureAwait(false);
@@ -2658,6 +2659,8 @@ public sealed class Bot : IAsyncDisposable {
}
}
bool hasNewEntries = ownedPackageIDs.Count > OwnedPackageIDs.Count;
OwnedPackageIDs = ownedPackageIDs.ToImmutableDictionary();
if (packageAccessTokens.Count > 0) {
@@ -2670,7 +2673,9 @@ public sealed class Bot : IAsyncDisposable {
ArchiLogger.LogGenericTrace(Strings.Done);
}
await CardsFarmer.OnNewGameAdded().ConfigureAwait(false);
if (hasNewEntries) {
await CardsFarmer.OnNewGameAdded().ConfigureAwait(false);
}
}
private void OnLoggedOff(SteamUser.LoggedOffCallback callback) {