Permalink
Browse files

Fix browsing/monitoring non-git directories

Update view model when selecting an empty/non-git directory so that UI
refreshes correctly.

Make sure the observable for the git directory creation event gets
disposed after getting one event, so that FileSystemWatchers listening
for creation events don't accumulate if the directory is created more
than once.
  • Loading branch information...
shana committed Dec 11, 2014
1 parent 7261668 commit 54a236a1129229f25b99872e3ede338f273f123d
Showing with 15 additions and 15 deletions.
  1. +1 −1 SeeGitApp/Extensions/ModelExtensions.cs
  2. +14 −14 SeeGitApp/ViewModels/MainWindowViewModel.cs
@@ -64,7 +64,7 @@ public static IObservable<FileSystemEventArgs> CreateGitRepositoryCreationObserv
e =>
e.ChangeType == WatcherChangeTypes.Created &&
e.FullPath.Equals(expectedGitDirectory, StringComparison.OrdinalIgnoreCase))
.Throttle(TimeSpan.FromSeconds(1));
.Take(1);
}
public static IObservable<FileSystemEventArgs> CreateGitRepositoryChangesObservable(string path)
@@ -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()

0 comments on commit 54a236a

Please sign in to comment.