mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-07 11:54:59 +00:00
enhance: cleanup unused resources
Some checks are pending
Some checks are pending
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
b78f6b0ea8
commit
aff003fd6d
8 changed files with 51 additions and 26 deletions
|
@ -44,10 +44,10 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public object Switcher
|
||||
public IDisposable Switcher
|
||||
{
|
||||
get => _switcher;
|
||||
set => SetProperty(ref _switcher, value);
|
||||
private set => SetProperty(ref _switcher, value);
|
||||
}
|
||||
|
||||
public Launcher(string startupRepo)
|
||||
|
@ -148,12 +148,13 @@ namespace SourceGit.ViewModels
|
|||
|
||||
public void CancelSwitcher()
|
||||
{
|
||||
Switcher?.Dispose();
|
||||
Switcher = null;
|
||||
}
|
||||
|
||||
public void SwitchWorkspace(Workspace to)
|
||||
{
|
||||
if (to.IsActive)
|
||||
if (to == null || to.IsActive)
|
||||
return;
|
||||
|
||||
foreach (var one in Pages)
|
||||
|
@ -623,6 +624,6 @@ namespace SourceGit.ViewModels
|
|||
private LauncherPage _activePage = null;
|
||||
private bool _ignoreIndexChange = false;
|
||||
private string _title = string.Empty;
|
||||
private object _switcher = null;
|
||||
private IDisposable _switcher = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,14 +4,14 @@ using CommunityToolkit.Mvvm.ComponentModel;
|
|||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class LauncherPageSwitcher : ObservableObject
|
||||
public class LauncherPageSwitcher : ObservableObject, IDisposable
|
||||
{
|
||||
public List<LauncherPage> VisiblePages
|
||||
{
|
||||
get => _visiblePages;
|
||||
private set => SetProperty(ref _visiblePages, value);
|
||||
}
|
||||
|
||||
|
||||
public string SearchFilter
|
||||
{
|
||||
get => _searchFilter;
|
||||
|
@ -27,13 +27,13 @@ namespace SourceGit.ViewModels
|
|||
get => _selectedPage;
|
||||
set => SetProperty(ref _selectedPage, value);
|
||||
}
|
||||
|
||||
|
||||
public LauncherPageSwitcher(Launcher launcher)
|
||||
{
|
||||
_launcher = launcher;
|
||||
UpdateVisiblePages();
|
||||
}
|
||||
|
||||
|
||||
public void ClearFilter()
|
||||
{
|
||||
SearchFilter = string.Empty;
|
||||
|
@ -41,12 +41,17 @@ namespace SourceGit.ViewModels
|
|||
|
||||
public void Switch()
|
||||
{
|
||||
if (_selectedPage is { })
|
||||
_launcher.ActivePage = _selectedPage;
|
||||
|
||||
_launcher.ActivePage = _selectedPage ?? _launcher.ActivePage;
|
||||
_launcher.CancelSwitcher();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_visiblePages.Clear();
|
||||
_selectedPage = null;
|
||||
_searchFilter = string.Empty;
|
||||
}
|
||||
|
||||
private void UpdateVisiblePages()
|
||||
{
|
||||
var visible = new List<LauncherPage>();
|
||||
|
|
|
@ -4,7 +4,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
|
|||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class WorkspaceSwitcher : ObservableObject
|
||||
public class WorkspaceSwitcher : ObservableObject, IDisposable
|
||||
{
|
||||
public List<Workspace> VisibleWorkspaces
|
||||
{
|
||||
|
@ -41,12 +41,17 @@ namespace SourceGit.ViewModels
|
|||
|
||||
public void Switch()
|
||||
{
|
||||
if (_selectedWorkspace is { })
|
||||
_launcher.SwitchWorkspace(_selectedWorkspace);
|
||||
|
||||
_launcher.SwitchWorkspace(_selectedWorkspace);
|
||||
_launcher.CancelSwitcher();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_visibleWorkspaces.Clear();
|
||||
_selectedWorkspace = null;
|
||||
_searchFilter = string.Empty;
|
||||
}
|
||||
|
||||
private void UpdateVisibleWorkspaces()
|
||||
{
|
||||
var visible = new List<Workspace>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue