From 8c96b8f7fba17790407789ffee90c58f9af36ea7 Mon Sep 17 00:00:00 2001 From: hishitetsu <66369541+hishitetsu@users.noreply.github.com> Date: Wed, 17 Apr 2024 00:04:04 +0900 Subject: [PATCH] Fix: Fixed issue where Git submenu was shown for non-GitHub repos (#15197) --- .../Data/Models/CurrentInstanceViewModel.cs | 13 ++++++++++--- src/Files.App/Views/HomePage.xaml.cs | 1 + src/Files.App/Views/Shells/BaseShellPage.cs | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Files.App/Data/Models/CurrentInstanceViewModel.cs b/src/Files.App/Data/Models/CurrentInstanceViewModel.cs index 44985617370d..51947b9fbc13 100644 --- a/src/Files.App/Data/Models/CurrentInstanceViewModel.cs +++ b/src/Files.App/Data/Models/CurrentInstanceViewModel.cs @@ -139,7 +139,15 @@ public bool CanTagFilesInPage get => !isPageTypeRecycleBin && !isPageTypeFtp && !isPageTypeZipFolder; } - public bool IsGitRepository => !string.IsNullOrWhiteSpace(gitRepositoryPath); + private bool isGitRepository; + public bool IsGitRepository + { + get => isGitRepository; + set + { + SetProperty(ref isGitRepository, value); + } + } private string? gitRepositoryPath; public string? GitRepositoryPath @@ -147,8 +155,7 @@ public string? GitRepositoryPath get => gitRepositoryPath; set { - if (SetProperty(ref gitRepositoryPath, value)) - OnPropertyChanged(nameof(IsGitRepository)); + SetProperty(ref gitRepositoryPath, value); } } diff --git a/src/Files.App/Views/HomePage.xaml.cs b/src/Files.App/Views/HomePage.xaml.cs index 70c7539318c2..d4183ebaeccc 100644 --- a/src/Files.App/Views/HomePage.xaml.cs +++ b/src/Files.App/Views/HomePage.xaml.cs @@ -58,6 +58,7 @@ protected override async void OnNavigatedTo(NavigationEventArgs e) AppInstance.InstanceViewModel.IsPageTypeZipFolder = false; AppInstance.InstanceViewModel.IsPageTypeLibrary = false; AppInstance.InstanceViewModel.GitRepositoryPath = null; + AppInstance.InstanceViewModel.IsGitRepository = false; AppInstance.ToolbarViewModel.CanRefresh = true; AppInstance.ToolbarViewModel.CanGoBack = AppInstance.CanNavigateBackward; AppInstance.ToolbarViewModel.CanGoForward = AppInstance.CanNavigateForward; diff --git a/src/Files.App/Views/Shells/BaseShellPage.cs b/src/Files.App/Views/Shells/BaseShellPage.cs index 061cb608df52..67ed786fd265 100644 --- a/src/Files.App/Views/Shells/BaseShellPage.cs +++ b/src/Files.App/Views/Shells/BaseShellPage.cs @@ -251,6 +251,7 @@ protected async void FilesystemViewModel_DirectoryInfoUpdated(object sender, Eve if (InstanceViewModel.GitRepositoryPath != FilesystemViewModel.GitDirectory) { InstanceViewModel.GitRepositoryPath = FilesystemViewModel.GitDirectory; + InstanceViewModel.IsGitRepository = FilesystemViewModel.IsValidGitDirectory; InstanceViewModel.GitBranchName = headBranch is not null ? headBranch.Name