refactor: implement IDisposable instead of calling custom Cleanup

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-05-20 17:24:00 +08:00
parent 550493b572
commit 75b7724d44
No known key found for this signature in database
8 changed files with 42 additions and 34 deletions

View file

@ -11,7 +11,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
namespace SourceGit.ViewModels
{
public class StashesPage : ObservableObject
public class StashesPage : ObservableObject, IDisposable
{
public List<Models.Stash> Stashes
{
@ -125,14 +125,13 @@ namespace SourceGit.ViewModels
_repo = repo;
}
public void Cleanup()
public void Dispose()
{
_stashes?.Clear();
_changes?.Clear();
_repo = null;
if (_stashes != null)
_stashes.Clear();
_selectedStash = null;
if (_changes != null)
_changes.Clear();
_selectedChange = null;
_diffContext = null;
}