Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b790d96
ILoginCache -> IKeychain
grokys Aug 25, 2017
1c81104
Use IKeychain for credentials.
grokys Aug 25, 2017
21f888e
Updated parameter name.
grokys Aug 25, 2017
7e061d1
Removed unneeded usings.
grokys Aug 25, 2017
c8b8dd7
Updated variable names.
grokys Aug 25, 2017
95f2c0b
Remove `IObservableKeychainAdapter`.
grokys Aug 25, 2017
7b4080f
Merge branch 'master' into fixes/1176-duplicate-login-classes
grokys Aug 30, 2017
3b13736
Store "master" credential.
grokys Aug 30, 2017
a142423
Merge branch 'master' into fixes/1176-duplicate-login-classes
grokys Sep 7, 2017
bcfbd79
Fix broken merge.
grokys Sep 7, 2017
c52a261
Merge branch 'fixes/1176-duplicate-login-classes' into fixes/harden-c…
grokys Sep 7, 2017
e6c5d89
Merge branch 'master' into fixes/1176-duplicate-login-classes
grokys Oct 20, 2017
17c845e
Merge branch 'fixes/1176-duplicate-login-classes' into fixes/harden-c…
grokys Oct 20, 2017
a627271
Merge branch 'master' into refactor/connections-master
grokys Oct 20, 2017
470ea13
Removed `IConnection.Repositories`.
grokys Oct 20, 2017
d98ec51
Refactored ConnectionManager/Connection.
grokys Oct 23, 2017
aa78f03
Refactored RepositoryHost(s).
grokys Oct 23, 2017
7cf89c9
Added DebuggerDisplay back in.
grokys Oct 23, 2017
213a7fc
Moved LocalRepositories to GitHub.VisualStudio.
grokys Oct 24, 2017
90c35c5
Track login metrics.
grokys Oct 26, 2017
9db05a7
Fix failing tests.
grokys Oct 26, 2017
f854b79
WIP: Removing RepositoryHost(s)
grokys Oct 26, 2017
3240372
WIP: Still removing RepositoryHost(s)
grokys Oct 26, 2017
038f232
WIP: Removing RepositoryHost(s) from tests.
grokys Oct 26, 2017
a57a759
Finished migrating tests (I think).
grokys Oct 27, 2017
95cd0b1
Added IModelServiceFactory implemenation.
grokys Oct 27, 2017
6034643
Added IGlobalConnection.
grokys Oct 27, 2017
17aebf8
Removed ConnectionManager.ConnectionCreated.
grokys Oct 27, 2017
00232f0
Merge branch 'master' into refactor/connections-master
grokys Nov 3, 2017
01aad33
Merge branch 'refactor/connections-master' into refactor/connections/…
grokys Nov 3, 2017
217e415
Merge branch 'refactor/connections/local-repositories' into refactor/…
grokys Nov 3, 2017
7e57621
Insert AccountCacheItem for connection.
grokys Nov 7, 2017
e45d0c6
Merge branch 'master' into refactor/connections-master
grokys Nov 7, 2017
8f6d218
Merge branch 'refactor/connections-master' into refactor/connections/…
grokys Nov 7, 2017
32f073a
Merge branch 'refactor/connections/local-repositories' into refactor/…
grokys Nov 7, 2017
9f15db6
Merge branch 'refactor/connection-manager' into refactor/connections/…
grokys Nov 7, 2017
cd546bb
Fix CA errors.
grokys Nov 7, 2017
def6070
Merge pull request #1283 from github/refactor/connections/remove-repo…
grokys Nov 8, 2017
fc57163
Merge branch 'master' into refactor/connections-master
grokys Nov 8, 2017
d9c2a2f
Removed empty file.
grokys Nov 8, 2017
cefd4b9
Merge branch 'master' into refactor/connections-master
grokys Nov 14, 2017
7d7b188
Merge branch 'master' into refactor/connections-master
grokys Nov 20, 2017
4701dd0
Merge branch 'master' into refactor/connections-master
grokys Nov 20, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions src/GitHub.App/Controllers/UIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Reactive.Threading.Tasks;
using System.Windows;
using GitHub.Logging;

Expand Down Expand Up @@ -98,7 +99,6 @@ internal enum Trigger

readonly IUIFactory factory;
readonly IGitHubServiceProvider gitHubServiceProvider;
readonly IRepositoryHosts hosts;
readonly IConnectionManager connectionManager;

readonly CompositeDisposable disposables = new CompositeDisposable();
Expand Down Expand Up @@ -140,25 +140,22 @@ internal enum Trigger

public UIController(IGitHubServiceProvider serviceProvider)
: this(serviceProvider,
serviceProvider.TryGetService<IRepositoryHosts>(),
serviceProvider.TryGetService<IUIFactory>(),
serviceProvider.TryGetService<IConnectionManager>())
{
Guard.ArgumentNotNull(serviceProvider, nameof(serviceProvider));
}

public UIController(IGitHubServiceProvider gitHubServiceProvider,
IRepositoryHosts hosts, IUIFactory factory,
IUIFactory factory,
IConnectionManager connectionManager)
{
Guard.ArgumentNotNull(gitHubServiceProvider, nameof(gitHubServiceProvider));
Guard.ArgumentNotNull(hosts, nameof(hosts));
Guard.ArgumentNotNull(factory, nameof(factory));
Guard.ArgumentNotNull(connectionManager, nameof(connectionManager));

this.factory = factory;
this.gitHubServiceProvider = gitHubServiceProvider;
this.hosts = hosts;
this.connectionManager = connectionManager;

#if DEBUG
Expand Down Expand Up @@ -220,7 +217,7 @@ public void Start()
else // sanity check: it makes zero sense to pass a connection in when calling the auth flow
Log.Assert(false, "Calling the auth flow with a connection makes no sense!");

connection.Login()
connectionManager.GetLoadedConnections().ToObservable()
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(_ => { }, () =>
{
Expand All @@ -231,7 +228,7 @@ public void Start()
else
{
connectionManager
.GetLoggedInConnections(hosts)
.GetLoggedInConnections()
.FirstOrDefaultAsync()
.Select(c =>
{
Expand Down Expand Up @@ -445,8 +442,7 @@ void ConfigureSingleViewLogic(UIControllerFlow flow, UIViewType type)

UIControllerFlow SelectActiveFlow()
{
var host = connection != null ? hosts.LookupHost(connection.HostAddress) : null;
var loggedIn = host?.IsLoggedIn ?? false;
var loggedIn = connection?.IsLoggedIn ?? false;
return loggedIn ? selectedFlow : UIControllerFlow.Authentication;
}

Expand Down Expand Up @@ -711,7 +707,7 @@ public void Dispose()
public bool IsStopped => uiStateMachine.IsInState(UIViewType.None) || stopping;
public UIControllerFlow CurrentFlow => activeFlow;
public UIControllerFlow SelectedFlow => selectedFlow;
bool LoggedIn => connection != null && hosts.LookupHost(connection.HostAddress).IsLoggedIn;
bool LoggedIn => connection?.IsLoggedIn ?? false;
bool? Success { get; set; }
}
}
67 changes: 67 additions & 0 deletions src/GitHub.App/Factories/ModelServiceFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Threading;
using System.Threading.Tasks;
using GitHub.Caches;
using GitHub.Models;
using GitHub.Services;
using Microsoft.VisualStudio.Shell;

namespace GitHub.Factories
{
[Export(typeof(IModelServiceFactory))]
[PartCreationPolicy(CreationPolicy.Shared)]
public sealed class ModelServiceFactory : IModelServiceFactory, IDisposable
{
readonly IApiClientFactory apiClientFactory;
readonly IHostCacheFactory hostCacheFactory;
readonly IAvatarProvider avatarProvider;
readonly Dictionary<IConnection, ModelService> cache = new Dictionary<IConnection, ModelService>();
readonly SemaphoreSlim cacheLock = new SemaphoreSlim(1);

[ImportingConstructor]
public ModelServiceFactory(
IApiClientFactory apiClientFactory,
IHostCacheFactory hostCacheFactory,
IAvatarProvider avatarProvider)
{
this.apiClientFactory = apiClientFactory;
this.hostCacheFactory = hostCacheFactory;
this.avatarProvider = avatarProvider;
}

public async Task<IModelService> CreateAsync(IConnection connection)
{
ModelService result;

await cacheLock.WaitAsync();

try
{
if (!cache.TryGetValue(connection, out result))
{
result = new ModelService(
await apiClientFactory.Create(connection.HostAddress),
await hostCacheFactory.Create(connection.HostAddress),
avatarProvider);
result.InsertUser(AccountCacheItem.Create(connection.User));
cache.Add(connection, result);
}
}
finally
{
cacheLock.Release();
}

return result;
}

public IModelService CreateBlocking(IConnection connection)
{
return ThreadHelper.JoinableTaskFactory.Run(() => CreateAsync(connection));
}

public void Dispose() => cacheLock.Dispose();
}
}
74 changes: 0 additions & 74 deletions src/GitHub.App/Factories/RepositoryHostFactory.cs

This file was deleted.

7 changes: 2 additions & 5 deletions src/GitHub.App/GitHub.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Factories\ModelServiceFactory.cs" />
<Compile Include="Models\IssueCommentModel.cs" />
<Compile Include="Models\PullRequestReviewCommentModel.cs" />
<Compile Include="Models\PullRequestDetailArgument.cs" />
<Compile Include="Services\GlobalConnection.cs" />
<Compile Include="ViewModels\ViewModelBase.cs" />
<Compile Include="Caches\CacheIndex.cs" />
<Compile Include="Caches\CacheItem.cs" />
Expand Down Expand Up @@ -183,9 +185,6 @@
<Compile Include="Info\GitHubUrls.cs" />
<Compile Include="Infrastructure\ExportWrappers.cs" />
<Compile Include="Models\Account.cs" />
<Compile Include="Models\DisconnectedRepositoryHosts.cs" />
<Compile Include="Models\RepositoryHost.cs" />
<Compile Include="Models\RepositoryHosts.cs" />
<Compile Include="Models\RemoteRepositoryModel.cs" />
<Compile Include="SampleData\SampleViewModels.cs" />
<Compile Include="Api\ApiClient.cs" />
Expand All @@ -195,7 +194,6 @@
<Compile Include="Services\ErrorMessage.cs" />
<Compile Include="Services\ErrorMessageTranslator.cs" />
<Compile Include="Services\IEnterpriseProbe.cs" />
<Compile Include="Factories\RepositoryHostFactory.cs" />
<Compile Include="Services\RepositoryCreationService.cs" />
<Compile Include="Services\GistPublishService.cs" />
<Compile Include="Services\RepositoryPublishService.cs" />
Expand All @@ -208,7 +206,6 @@
<Compile Include="UserErrors\PrivateRepositoryQuotaExceededUserError.cs" />
<Compile Include="ViewModels\PanePageViewModelBase.cs" />
<Compile Include="ViewModels\DialogViewModelBase.cs" />
<Compile Include="Models\ConnectionRepositoryHostMap.cs" />
<Compile Include="ViewModels\GistCreationViewModel.cs" />
<Compile Include="ViewModels\NotAGitRepositoryViewModel.cs" />
<Compile Include="ViewModels\NotAGitHubRepositoryViewModel.cs" />
Expand Down
34 changes: 0 additions & 34 deletions src/GitHub.App/Models/ConnectionRepositoryHostMap.cs

This file was deleted.

57 changes: 0 additions & 57 deletions src/GitHub.App/Models/DisconnectedRepositoryHosts.cs

This file was deleted.

Loading