Skip to content

Commit

Permalink
Fix browsing/monitoring non-git directories
Browse files Browse the repository at this point in the history
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 54a236a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion SeeGitApp/Extensions/ModelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
28 changes: 14 additions & 14 deletions SeeGitApp/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down

0 comments on commit 54a236a

Please sign in to comment.