From 37b5f5c083ebf76a4fa06b3a42e99fdf462d798a Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 7 May 2024 10:34:04 +0800 Subject: [PATCH] feature: enhance the behaviour of closing the last tab * If the last tab is an opened repository, go back to the welcome page * If the last tab is welcome page, quit this app --- src/ViewModels/Launcher.cs | 17 ++++++++++++++++- src/ViewModels/LauncherPage.cs | 8 +------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/ViewModels/Launcher.cs b/src/ViewModels/Launcher.cs index 3d1fc1c1..e8bace1e 100644 --- a/src/ViewModels/Launcher.cs +++ b/src/ViewModels/Launcher.cs @@ -107,7 +107,22 @@ namespace SourceGit.ViewModels { if (Pages.Count == 1) { - App.Quit(); + var last = Pages[0]; + if (last.Data is Repository repo) + { + Commands.AutoFetch.RemoveRepository(repo.FullPath); + repo.Close(); + + last.Node = new RepositoryNode() { Id = Guid.NewGuid().ToString() }; + last.Data = new Welcome(); + + GC.Collect(); + } + else + { + App.Quit(); + } + return; } diff --git a/src/ViewModels/LauncherPage.cs b/src/ViewModels/LauncherPage.cs index c8765c0d..00c145b3 100644 --- a/src/ViewModels/LauncherPage.cs +++ b/src/ViewModels/LauncherPage.cs @@ -26,13 +26,7 @@ namespace SourceGit.ViewModels public LauncherPage() { - _node = new RepositoryNode() - { - Id = Guid.NewGuid().ToString(), - Name = "WelcomePage", - Bookmark = 0, - IsRepository = false, - }; + _node = new RepositoryNode() { Id = Guid.NewGuid().ToString() }; _data = new Welcome(); }