Example #1
0
        public IObservable <Unit> LogOut(IRepositoryHost host)
        {
            Guard.ArgumentNotNull(host, nameof(host));

            var address  = host.Address;
            var isDotCom = HostAddress.GitHubDotComHostAddress == address;

            return(host.LogOut()
                   .ObserveOn(RxApp.MainThreadScheduler)
                   .Do(result =>
            {
                // reset the logged out host property to null
                // it'll know what to do
                if (isDotCom)
                {
                    GitHubHost = null;
                }
                else
                {
                    EnterpriseHost = null;
                }
                connectionManager.RemoveConnection(address);
                RepositoryHostFactory.Remove(host);
            }));
        }
Example #2
0
        async Task Load()
        {
            IsBusy = true;

            if (remoteRepository == null)
            {
                remoteRepository = await repositoryHost.ModelService.GetRepository(
                    localRepository.Owner,
                    localRepository.Name);

                Repositories = remoteRepository.IsFork ?
                               new[] { remoteRepository.Parent, remoteRepository } :
                new[] { remoteRepository };
                SelectedRepository = Repositories[0];
            }

            PullRequests = repositoryHost.ModelService.GetPullRequests(SelectedRepository, pullRequests);
            pullRequests.Subscribe(pr =>
            {
                trackingAssignees.AddItem(pr.Assignee);
                trackingAuthors.AddItem(pr.Author);
            }, () => { });

            pullRequests.OriginalCompleted
            .ObserveOn(RxApp.MainThreadScheduler)
            .Catch <System.Reactive.Unit, Octokit.AuthorizationException>(ex =>
            {
                log.Info("Received AuthorizationException reading pull requests", ex);
                return(repositoryHost.LogOut());
            })
            .Catch <System.Reactive.Unit, Exception>(ex =>
            {
                // Occurs on network error, when the repository was deleted on GitHub etc.
                log.Info("Received Exception reading pull requests", ex);
                return(Observable.Empty <System.Reactive.Unit>());
            })
            .Subscribe(_ =>
            {
                if (listSettings.SelectedAuthor != null)
                {
                    SelectedAuthor = Authors.FirstOrDefault(x => x.Login == listSettings.SelectedAuthor);
                }

                if (listSettings.SelectedAssignee != null)
                {
                    SelectedAssignee = Assignees.FirstOrDefault(x => x.Login == listSettings.SelectedAssignee);
                }

                IsBusy = false;
                UpdateFilter(SelectedState, SelectedAssignee, SelectedAuthor);
            });
        }
Example #3
0
        public override void Initialize([AllowNull] ViewWithData data)
        {
            base.Initialize(data);

            IsLoaded = false;

            PullRequests = repositoryHost.ModelService.GetPullRequests(repository, pullRequests);
            pullRequests.Subscribe(pr =>
            {
                trackingAssignees.AddItem(pr.Assignee);
                trackingAuthors.AddItem(pr.Author);
            }, () => { });

            pullRequests.OriginalCompleted
            .ObserveOn(RxApp.MainThreadScheduler)
            .Catch <System.Reactive.Unit, Octokit.AuthorizationException>(ex =>
            {
                log.Info("Received AuthorizationException reading pull requests", ex);
                return(repositoryHost.LogOut());
            })
            .Catch <System.Reactive.Unit, Exception>(ex =>
            {
                // Occurs on network error, when the repository was deleted on GitHub etc.
                log.Info("Received Exception reading pull requests", ex);
                return(Observable.Empty <System.Reactive.Unit>());
            })
            .Subscribe(_ =>
            {
                if (listSettings.SelectedAuthor != null)
                {
                    SelectedAuthor = Authors.FirstOrDefault(x => x.Login == listSettings.SelectedAuthor);
                }

                if (listSettings.SelectedAssignee != null)
                {
                    SelectedAssignee = Assignees.FirstOrDefault(x => x.Login == listSettings.SelectedAssignee);
                }

                IsLoaded = true;
                UpdateFilter(SelectedState, SelectedAssignee, SelectedAuthor);
            });
        }
Example #4
0
        public override void Initialize([AllowNull] ViewWithData data)
        {
            base.Initialize(data);

            IsLoaded = false;

            PullRequests = repositoryHost.ModelService.GetPullRequests(repository, pullRequests);
            pullRequests.Subscribe(pr =>
            {
                trackingAssignees.AddItem(pr.Assignee);
                trackingAuthors.AddItem(pr.Author);
            }, () => { });

            pullRequests.OriginalCompleted
            .ObserveOn(RxApp.MainThreadScheduler)
            .Catch <System.Reactive.Unit, Octokit.AuthorizationException>(ex =>
            {
                // TODO: Do some decent logging here
                return(repositoryHost.LogOut());
            })
            .Catch <System.Reactive.Unit, Octokit.NotFoundException>(ex =>
            {
                //this is caused when repository was deleted on github
                return(Observable.Empty <System.Reactive.Unit>());
            })
            .Subscribe(_ =>
            {
                if (listSettings.SelectedAuthor != null)
                {
                    SelectedAuthor = Authors.FirstOrDefault(x => x.Login == listSettings.SelectedAuthor);
                }

                if (listSettings.SelectedAssignee != null)
                {
                    SelectedAssignee = Assignees.FirstOrDefault(x => x.Login == listSettings.SelectedAssignee);
                }

                IsLoaded = true;
                UpdateFilter(SelectedState, SelectedAssignee, SelectedAuthor);
            });
        }
Example #5
0
        public IObservable <Unit> LogOut(IRepositoryHost host)
        {
            var address  = host.Address;
            var isDotCom = HostAddress.GitHubDotComHostAddress == address;

            return(host.LogOut()
                   .Do(result =>
            {
                // reset the logged out host property to null
                // it'll know what to do
                if (isDotCom)
                {
                    GitHubHost = null;
                }
                else
                {
                    EnterpriseHost = null;
                }
                connectionManager.RemoveConnection(address);
                RepositoryHostFactory.Remove(host);
            }));
        }
 public IObservable<Unit> LogOut(IRepositoryHost host)
 {
     var address = host.Address;
     var isDotCom = HostAddress.GitHubDotComHostAddress == address;
     return host.LogOut()
         .Do(result =>
         {
             // reset the logged out host property to null
             // it'll know what to do
             if (isDotCom)
                 GitHubHost = null;
             else
                 EnterpriseHost = null;
             connectionManager.RemoveConnection(address);
             disposables.Remove(host);
         });
 }