Skip to content

Commit

Permalink
[MTGOSDK/API] Client: Separate disposal of client from caches
Browse files Browse the repository at this point in the history
Migrate all RemoteClient disposal to the `Client.Dispose` method instead. Partially reverts 80d1b17 to better accommodate lazy instantiation of remote objects.
  • Loading branch information
Qonfused committed Jun 1, 2024
1 parent 8c5fd4e commit c79d911
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions MTGOSDK/src/API/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,10 @@ public static bool ValidateVersion(bool assert = false)
/// <summary>
/// Cleans up any cached remote objects pinning objects in client memory.
/// </summary>
/// <param name="disconnect">Whether to disconnect the client.</param>
public void ClearCaches(bool disconnect = false)
public void ClearCaches()
{
if (disconnect)
{
RemoteClient.Dispose();
ObjectProvider.RequiresRefresh = true;
}
m_currentUser = null;

Log.Debug("Disposing all pinned remote objects registered with the client.");
m_currentUser = null;
UserManager.Users.Clear();
CollectionManager.Cards.Clear();
}
Expand All @@ -265,7 +258,9 @@ public void ClearCaches(bool disconnect = false)
/// </summary>
public void Dispose()
{
ClearCaches(disconnect: true);
ClearCaches();
RemoteClient.Dispose();
ObjectProvider.RequiresRefresh = true;
}

//
Expand Down

0 comments on commit c79d911

Please sign in to comment.