diff --git a/SeeGitApp/Extensions/ModelExtensions.cs b/SeeGitApp/Extensions/ModelExtensions.cs index 3b2f8e9..f1000f7 100644 --- a/SeeGitApp/Extensions/ModelExtensions.cs +++ b/SeeGitApp/Extensions/ModelExtensions.cs @@ -64,7 +64,7 @@ public static IObservable CreateGitRepositoryCreationObserv e => e.ChangeType == WatcherChangeTypes.Created && e.FullPath.Equals(expectedGitDirectory, StringComparison.OrdinalIgnoreCase)) - .Throttle(TimeSpan.FromSeconds(1)); + .Take(1); } public static IObservable CreateGitRepositoryChangesObservable(string path) diff --git a/SeeGitApp/ViewModels/MainWindowViewModel.cs b/SeeGitApp/ViewModels/MainWindowViewModel.cs index 8b83a03..5c68e0c 100644 --- a/SeeGitApp/ViewModels/MainWindowViewModel.cs +++ b/SeeGitApp/ViewModels/MainWindowViewModel.cs @@ -57,25 +57,21 @@ private set public void MonitorRepository(string repositoryWorkingPath) { if (repositoryWorkingPath == null) return; - - string gitPath = ModelExtensions.GetGitRepositoryPath(repositoryWorkingPath); - if (!Directory.Exists(gitPath)) - { - MonitorForRepositoryCreation(repositoryWorkingPath); - return; - } - RepositoryPath = repositoryWorkingPath; + string gitPath = ModelExtensions.GetGitRepositoryPath(repositoryWorkingPath); _graphBuilder = _graphBuilderThunk(gitPath); RepositoryPath = Directory.GetParent(gitPath).FullName; - Graph = _graphBuilder.Graph(); + var graph = _graphBuilder.Graph(); - if (_graph.VertexCount > 1) - _graph.LayoutAlgorithmType = "EfficientSugiyama"; - Graph = Graph; + if (graph.VertexCount > 1) + graph.LayoutAlgorithmType = "EfficientSugiyama"; + Graph = graph; - MonitorForRepositoryChanges(gitPath); + if (!Directory.Exists(gitPath)) + MonitorForRepositoryCreation(RepositoryPath); + else + MonitorForRepositoryChanges(gitPath); } private void MonitorForRepositoryCreation(string repositoryWorkingPath) @@ -92,7 +88,11 @@ private void MonitorForRepositoryChanges(string gitRepositoryPath) public void Refresh() { - Graph = _graphBuilder.Graph(); + string gitPath = ModelExtensions.GetGitRepositoryPath(RepositoryPath); + if (!Directory.Exists(gitPath)) + MonitorRepository(RepositoryPath); + else + Graph = _graphBuilder.Graph(); } public bool ToggleSettings()