void StartFlow(UIControllerFlow controllerFlow, [AllowNull] IConnection conn, ViewWithData data = null) { Stop(); if (conn == null) { return; } switch (controllerFlow) { case UIControllerFlow.PullRequests: Title = Resources.PullRequestsNavigationItemText; break; default: Title = "GitHub"; break; } var uiProvider = ServiceProvider.GetExportedValue <IUIProvider>(); var factory = uiProvider.GetService <IExportFactoryProvider>(); var uiflow = factory.UIControllerFactory.CreateExport(); disposables.Add(uiflow); uiController = uiflow.Value; var creation = uiController.SelectFlow(controllerFlow).Publish().RefCount(); // if the flow is authentication, we need to show the login dialog. and we can't // block the main thread on the subscriber, it'll block other handlers, so we're doing // this on a separate thread and posting the dialog to the main thread creation .Where(c => uiController.CurrentFlow == UIControllerFlow.Authentication) .ObserveOn(RxApp.TaskpoolScheduler) .Subscribe(c => { // nothing to do, we already have a dialog if (windowController != null) { return; } syncContext.Post(_ => { windowController = new WindowController(creation, __ => uiController.CurrentFlow == UIControllerFlow.Authentication, ___ => uiController.CurrentFlow != UIControllerFlow.Authentication); windowController.WindowStartupLocation = WindowStartupLocation.CenterOwner; windowController.Load(c.View); windowController.ShowModal(); windowController = null; }, null); }); creation .Where(c => uiController.CurrentFlow != UIControllerFlow.Authentication) .Subscribe(c => { if (!navigatingViaArrows) { if (c.Direction == LoadDirection.Forward) { GoForward(c.Data); } else if (c.Direction == LoadDirection.Back) { GoBack(); } } UpdateToolbar(); Control = c.View; }); if (data != null) { uiController.Jump(data); } uiController.Start(conn); }
void StartFlow(UIControllerFlow controllerFlow, [AllowNull]IConnection conn, ViewWithData data = null) { Stop(); if (conn == null) return; var uiProvider = ServiceProvider.GetService<IUIProvider>(); var factory = uiProvider.GetService<IExportFactoryProvider>(); var uiflow = factory.UIControllerFactory.CreateExport(); disposables.Add(uiflow); uiController = uiflow.Value; var creation = uiController.SelectFlow(controllerFlow).Publish().RefCount(); // if the flow is authentication, we need to show the login dialog. and we can't // block the main thread on the subscriber, it'll block other handlers, so we're doing // this on a separate thread and posting the dialog to the main thread creation .Where(c => uiController.CurrentFlow == UIControllerFlow.Authentication) .ObserveOn(RxApp.TaskpoolScheduler) .Subscribe(c => { // nothing to do, we already have a dialog if (windowController != null) return; syncContext.Post(_ => { windowController = new WindowController(creation, __ => uiController.CurrentFlow == UIControllerFlow.Authentication, ___ => uiController.CurrentFlow != UIControllerFlow.Authentication); windowController.WindowStartupLocation = WindowStartupLocation.CenterOwner; windowController.Load(c.View); windowController.ShowModal(); windowController = null; }, null); }); creation .Where(c => uiController.CurrentFlow != UIControllerFlow.Authentication) .Subscribe(c => { if (!navigatingViaArrows) { if (c.Direction == LoadDirection.Forward) GoForward(c.Data); else if (c.Direction == LoadDirection.Back) GoBack(); } UpdateToolbar(); Control = c.View; }); if (data != null) uiController.Jump(data); uiController.Start(conn); }