diff --git a/src/GitHub.App/Authentication/TwoFactorChallengeHandler.cs b/src/GitHub.App/Authentication/TwoFactorChallengeHandler.cs index 5f8107fbb..fc99942c7 100644 --- a/src/GitHub.App/Authentication/TwoFactorChallengeHandler.cs +++ b/src/GitHub.App/Authentication/TwoFactorChallengeHandler.cs @@ -2,32 +2,34 @@ using System.ComponentModel.Composition; using System.Reactive.Linq; using GitHub.ViewModels; -using Microsoft.VisualStudio.PlatformUI; using Octokit; using ReactiveUI; +using GitHub.UI; namespace GitHub.Authentication { [Export(typeof(ITwoFactorChallengeHandler))] public class TwoFactorChallengeHandler : ITwoFactorChallengeHandler { - readonly IServiceProvider serviceProvider; + //readonly IServiceProvider serviceProvider; + readonly Lazy lazyTwoFactorDialog; [ImportingConstructor] - public TwoFactorChallengeHandler(IServiceProvider serviceProvider) + public TwoFactorChallengeHandler(Lazy twoFactorDialog) { - this.serviceProvider = serviceProvider; + //this.serviceProvider = serviceProvider; + this.lazyTwoFactorDialog = twoFactorDialog; } public IObservable HandleTwoFactorException(TwoFactorRequiredException exception) { - var twoFactorDialog = (TwoFactorDialogViewModel)serviceProvider.GetService(typeof(TwoFactorDialogViewModel)); - var twoFactorView = (IViewFor)serviceProvider.GetService(typeof(IViewFor)); + var twoFactorDialog = lazyTwoFactorDialog.Value as TwoFactorDialogViewModel; + //var twoFactorView = (IViewFor)serviceProvider.GetService(typeof(IViewFor)); return Observable.Start(() => { - twoFactorView.ViewModel = twoFactorDialog; - ((DialogWindow)twoFactorView).Show(); + //twoFactorView.ViewModel = twoFactorDialog; + //((DialogWindow)twoFactorView).Show(); var userError = new TwoFactorRequiredUserError(exception); return twoFactorDialog.Show(userError) @@ -37,8 +39,9 @@ namespace GitHub.Authentication : Observable.Throw(exception)); }, RxApp.MainThreadScheduler) .SelectMany(x => x) - .Finally(() => - ((DialogWindow)twoFactorView).Hide()); + //.Finally(() => + // ((DialogWindow)twoFactorView).Hide()); + ; } } } \ No newline at end of file