From 11d690d22b9c8fcafef3769170fc8bad6b1af5c0 Mon Sep 17 00:00:00 2001 From: Cardidi Date: Tue, 1 Apr 2025 05:48:21 +0800 Subject: [PATCH] feat: fix repository enter issue. --- Flawless.Client/Service/RepositoryService.cs | 12 ++++----- Flawless.Client/ViewModels/HomeViewModel.cs | 26 ++++++++++++++++--- Flawless.Client/Views/HomeView.axaml | 2 +- .../RepositoryPage/RepoCommitPageView.axaml | 2 ++ .../RepoDashboardPageView.axaml | 2 ++ .../RepositoryPage/RepoFileTreePageView.axaml | 2 ++ .../RepositoryPage/RepoIssuePageView.axaml | 2 ++ .../RepositoryPage/RepoSettingPageView.axaml | 2 ++ .../RepoWorkspacePageView.axaml | 2 ++ Flawless.Client/Views/RepositoryView.axaml | 4 +-- Flawless.Client/Views/RepositoryView.axaml.cs | 4 ++- .../Controllers/RepositoryInnieController.cs | 8 +++--- .../Controllers/RepositoryOutieController.cs | 7 ++--- Flawless.Server/Program.cs | 6 +---- 14 files changed, 55 insertions(+), 26 deletions(-) diff --git a/Flawless.Client/Service/RepositoryService.cs b/Flawless.Client/Service/RepositoryService.cs index 0af8911..762c259 100644 --- a/Flawless.Client/Service/RepositoryService.cs +++ b/Flawless.Client/Service/RepositoryService.cs @@ -184,8 +184,10 @@ public class RepositoryService : BaseService { var isFolderExists = Directory.Exists(PathUtility.GetWorkspacePath(repo.OwnerName, repo.Name)); var isDbFileExists = File.Exists(PathUtility.GetWorkspaceDbPath(repo.OwnerName, repo.Name)); + + repo.IsDownloaded = isFolderExists && isDbFileExists; - return isFolderExists && isDbFileExists; + return true; } public async ValueTask UpdateMembersFromServerAsync(RepositoryModel repo) @@ -282,10 +284,6 @@ public class RepositoryService : BaseService // Create basic structures. if (!TryCreateRepositoryBaseStorageStructure(repo)) return false; - if (!await UpdateCommitsFromServerAsync(repo)) return false; - var peekCommit = repo.Commits.MaxBy(sl => sl.CommittedOn); - if (peekCommit == null) return false; // Should not use this function! - repo.IsDownloaded = true; _openedRepos.Add(repo); return true; @@ -351,7 +349,7 @@ public class RepositoryService : BaseService return false; } - var rsp = await api.Gateway.PeekCommit(repo.Name, repo.OwnerName); + var rsp = await api.Gateway.PeekCommit(repo.OwnerName, repo.Name); var emptyRepo = repo.Commits.Count == 0; // If they both empty @@ -378,7 +376,7 @@ public class RepositoryService : BaseService return false; } - var rsp = await api.Gateway.ListCommit(repo.Name, repo.OwnerName); + var rsp = await api.Gateway.ListCommit(repo.OwnerName, repo.Name); // Update existed var dict = rsp.Result.ToDictionary(m => m.Id); diff --git a/Flawless.Client/ViewModels/HomeViewModel.cs b/Flawless.Client/ViewModels/HomeViewModel.cs index b036636..e85c79c 100644 --- a/Flawless.Client/ViewModels/HomeViewModel.cs +++ b/Flawless.Client/ViewModels/HomeViewModel.cs @@ -30,6 +30,8 @@ public partial class HomeViewModel : ViewModelBase, IRoutableViewModel HostScreen = hostScreen; Api.C.ServerUrl.SubscribeOn(AvaloniaScheduler.Instance) .Subscribe(v => ServerFriendlyName = v ?? "Unknown Server"); + + RefreshRepositoriesCommand.Execute(); } [ReactiveCommand] @@ -46,7 +48,7 @@ public partial class HomeViewModel : ViewModelBase, IRoutableViewModel var opt = new OverlayDialogOptions { FullScreen = false, - Buttons = DialogButton.OK, + Buttons = DialogButton.OKCancel, CanResize = false, CanDragMove = false, IsCloseButtonVisible = true, @@ -87,9 +89,27 @@ public partial class HomeViewModel : ViewModelBase, IRoutableViewModel private async Task DeleteRepositoryAsync() { if (_selectedRepository == null) return; - if (await RepositoryService.C.DeleteFromDiskAsync(_selectedRepository)) + var opt = new OverlayDialogOptions { - await RepositoryService.C.UpdateDownloadedStatusFromDiskAsync(_selectedRepository); + FullScreen = false, + Buttons = DialogButton.YesNo, + CanResize = false, + CanDragMove = false, + IsCloseButtonVisible = true, + CanLightDismiss = true, + Mode = DialogMode.Question + }; + + var vm = new SimpleMessageDialogViewModel( + $"Do you really want to delete a CLONE of repository {_selectedRepository.StandaloneName} ?"); + + var mr = await OverlayDialog + .ShowModal(vm, AppDefaultValues.HostId, opt); + + if (mr == DialogResult.Yes) + { + if (await RepositoryService.C.DeleteFromDiskAsync(_selectedRepository)) + await RepositoryService.C.UpdateDownloadedStatusFromDiskAsync(_selectedRepository); } } diff --git a/Flawless.Client/Views/HomeView.axaml b/Flawless.Client/Views/HomeView.axaml index 9403ff7..d1aa5ec 100644 --- a/Flawless.Client/Views/HomeView.axaml +++ b/Flawless.Client/Views/HomeView.axaml @@ -81,7 +81,7 @@