Пример #1
0
        public async Task Initialize()
        {
            var buffer = peekSession.TextView.TextBuffer;
            var info   = sessionManager.GetTextBufferInfo(buffer);

            if (info != null)
            {
                relativePath = info.RelativePath;
                side         = info.Side ?? DiffSide.Right;
                file         = await info.Session.GetFile(relativePath);

                session = info.Session;
                await UpdateThread();
            }
            else
            {
                relativePath = sessionManager.GetRelativePath(buffer);
                file         = await sessionManager.GetLiveFile(relativePath, peekSession.TextView, buffer);
                await SessionChanged(sessionManager.CurrentSession);

                sessionSubscription = sessionManager.WhenAnyValue(x => x.CurrentSession)
                                      .Skip(1)
                                      .Subscribe(x => SessionChanged(x).Forget());
            }

            fileSubscription?.Dispose();
            fileSubscription = file.LinesChanged.Subscribe(LinesChanged);
        }
Пример #2
0
        async Task Initialize()
        {
            needsInitialize = false;

            var bufferInfo = sessionManager.GetTextBufferInfo(buffer);

            if (bufferInfo != null)
            {
                session      = bufferInfo.Session;
                relativePath = bufferInfo.RelativePath;
                file         = await session.GetFile(relativePath);

                fileSubscription = file.LinesChanged.Subscribe(LinesChanged);
                side             = bufferInfo.Side ?? DiffSide.Right;
                NotifyTagsChanged();
            }
            else
            {
                await InitializeLiveFile();

                sessionManagerSubscription = sessionManager
                                             .WhenAnyValue(x => x.CurrentSession)
                                             .Skip(1)
                                             .Subscribe(_ => ForgetWithLogging(InitializeLiveFile()));
            }
        }
Пример #3
0
        public PullRequestFileMargin(
            IWpfTextView textView,
            IToggleInlineCommentMarginCommand toggleInlineCommentMarginCommand,
            IGoToSolutionOrPullRequestFileCommand goToSolutionOrPullRequestFileCommand,
            IPullRequestSessionManager sessionManager,
            Lazy <IUsageTracker> usageTracker)
        {
            this.textView       = textView;
            this.sessionManager = sessionManager;

            viewModel     = new PullRequestFileMarginViewModel(toggleInlineCommentMarginCommand, goToSolutionOrPullRequestFileCommand, usageTracker);
            visualElement = new PullRequestFileMarginView {
                DataContext = viewModel, ClipToBounds = true
            };

            visibilitySubscription = viewModel.WhenAnyValue(x => x.Enabled).Subscribe(enabled =>
            {
                visualElement.Visibility = enabled ? Visibility.Visible : Visibility.Collapsed;
            });

            optionChangedSubscription = Observable.FromEventPattern(textView.Options, nameof(textView.Options.OptionChanged)).Subscribe(_ =>
            {
                viewModel.MarginEnabled = textView.Options.GetOptionValue(InlineCommentTextViewOptions.MarginEnabledId);
            });

            currentSessionSubscription = sessionManager.WhenAnyValue(x => x.CurrentSession)
                                         .Subscribe(x => RefreshCurrentSession().Forget());
        }
Пример #4
0
        async Task Initialize()
        {
            needsInitialize = false;

            var bufferInfo = sessionManager.GetTextBufferInfo(buffer);

            if (bufferInfo != null)
            {
                session      = bufferInfo.Session;
                relativePath = bufferInfo.RelativePath;
                file         = await session.GetFile(relativePath);

                leftHandSide = bufferInfo.IsLeftComparisonBuffer;
                NotifyTagsChanged();
            }
            else
            {
                await InitializeLiveFile();

                sessionManagerSubscription = sessionManager
                                             .WhenAnyValue(x => x.CurrentSession)
                                             .Skip(1)
                                             .Subscribe(_ => ForgetWithLogging(InitializeLiveFile()));
            }
        }
        public async Task Initialize()
        {
            var buffer = peekSession.TextView.TextBuffer;
            var info   = sessionManager.GetTextBufferInfo(buffer);

            if (info != null)
            {
                relativePath = info.RelativePath;
                leftBuffer   = info.IsLeftComparisonBuffer;
                file         = await info.Session.GetFile(relativePath);

                session = info.Session;
                await UpdateThread();
            }
            else
            {
                relativePath = sessionManager.GetRelativePath(buffer);
                file         = await sessionManager.GetLiveFile(relativePath, peekSession.TextView, buffer);
                await SessionChanged(sessionManager.CurrentSession);

                sessionSubscription = sessionManager.WhenAnyValue(x => x.CurrentSession)
                                      .Skip(1)
                                      .Subscribe(x => SessionChanged(x).Forget());
            }

            fileSubscription = file.WhenAnyValue(x => x.InlineCommentThreads).Subscribe(_ => UpdateThread().Forget());
        }
Пример #6
0
 /// <summary>
 /// Start showing the PR for the active branch on the status bar.
 /// </summary>
 /// <remarks>
 /// This must be called from the Main thread.
 /// </remarks>
 public void StartShowingStatus()
 {
     try
     {
         pullRequestSessionManager = serviceProvider.GetService <IPullRequestSessionManager>();
         pullRequestSessionManager.WhenAnyValue(x => x.CurrentSession)
         .Subscribe(x => RefreshCurrentSession());
     }
     catch (Exception e)
     {
         log.Error(e, "Error initializing");
     }
 }
        public PullRequestListViewModel(
            IPullRequestSessionManager sessionManager,
            IRepositoryService repositoryService,
            IPullRequestService service)
            : base(repositoryService)
        {
            Guard.ArgumentNotNull(sessionManager, nameof(sessionManager));
            Guard.ArgumentNotNull(service, nameof(service));

            this.sessionManager = sessionManager;
            this.service        = service;

            subscription = sessionManager.WhenAnyValue(x => x.CurrentSession.PullRequest.Number).Subscribe(UpdateCurrent);
            webUrl       = this.WhenAnyValue(x => x.RemoteRepository)
                           .Select(x => x?.CloneUrl?.ToRepositoryUrl().Append("pulls"))
                           .ToProperty(this, x => x.WebUrl);
            CreatePullRequest = ReactiveCommand.Create().OnExecuteCompleted(_ => NavigateTo("pull/new"));
            OpenItemInBrowser = ReactiveCommand.Create();
        }
Пример #8
0
        void Initialize()
        {
            document = buffer.Properties.GetProperty <ITextDocument>(typeof(ITextDocument));

            if (document == null)
            {
                return;
            }

            var bufferInfo = sessionManager.GetTextBufferInfo(buffer);
            IPullRequestSession session = null;

            if (bufferInfo != null)
            {
                fullPath     = bufferInfo.FilePath;
                leftHandSide = bufferInfo.IsLeftComparisonBuffer;

                if (!bufferInfo.Session.IsCheckedOut)
                {
                    session = bufferInfo.Session;
                }
            }
            else
            {
                fullPath = document.FilePath;
            }

            if (session == null)
            {
                managerSubscription = sessionManager.WhenAnyValue(x => x.CurrentSession).Subscribe(SessionChanged);
            }
            else
            {
                SessionChanged(session);
            }

            initialized = true;
        }
        void Initialize()
        {
            document = TryGetDocument(buffer);

            if (document == null)
            {
                return;
            }

            var bufferInfo = sessionManager.GetTextBufferInfo(buffer);
            IPullRequestSession session = null;

            if (bufferInfo != null)
            {
                fullPath     = bufferInfo.FilePath;
                leftHandSide = bufferInfo.IsLeftComparisonBuffer;

                if (!bufferInfo.Session.IsCheckedOut)
                {
                    session = bufferInfo.Session;
                }
            }
            else
            {
                fullPath = document.FilePath;
            }

            if (session == null)
            {
                managerSubscription = sessionManager.WhenAnyValue(x => x.CurrentSession).Subscribe(x => ForgetWithLogging(SessionChanged(x)));
            }
            else
            {
                ForgetWithLogging(SessionChanged(session));
            }

            initialized = true;
        }
        public async Task Initialize()
        {
            var buffer = peekSession.TextView.TextBuffer;
            var info   = sessionManager.GetTextBufferInfo(buffer);

            if (info != null)
            {
                fullPath   = info.FilePath;
                leftBuffer = info.IsLeftComparisonBuffer;
                await SessionChanged(info.Session);
            }
            else
            {
                var document = buffer.Properties.GetProperty <ITextDocument>(typeof(ITextDocument));
                fullPath = document.FilePath;

                await SessionChanged(sessionManager.CurrentSession);

                sessionManager.WhenAnyValue(x => x.CurrentSession)
                .Skip(1)
                .Subscribe(x => SessionChanged(x).Forget());
            }
        }
Пример #11
0
        public PullRequestListViewModel(
            IModelServiceFactory modelServiceFactory,
            IPackageSettings settings,
            IPullRequestSessionManager sessionManager,
            IVisualStudioBrowser visualStudioBrowser)
        {
            Guard.ArgumentNotNull(modelServiceFactory, nameof(modelServiceFactory));
            Guard.ArgumentNotNull(settings, nameof(settings));
            Guard.ArgumentNotNull(sessionManager, nameof(sessionManager));
            Guard.ArgumentNotNull(visualStudioBrowser, nameof(visualStudioBrowser));

            constructing             = true;
            this.modelServiceFactory = modelServiceFactory;
            this.settings            = settings;
            this.visualStudioBrowser = visualStudioBrowser;

            Title = Resources.PullRequestsNavigationItemText;

            States = new List <PullRequestState> {
                new PullRequestState {
                    IsOpen = true, Name = "Open"
                },
                new PullRequestState {
                    IsOpen = false, Name = "Closed"
                },
                new PullRequestState {
                    Name = "All"
                }
            };

            trackingAuthors = new TrackingCollection <IAccount>(Observable.Empty <IAccount>(),
                                                                OrderedComparer <IAccount> .OrderByDescending(x => x.Login).Compare);
            trackingAssignees = new TrackingCollection <IAccount>(Observable.Empty <IAccount>(),
                                                                  OrderedComparer <IAccount> .OrderByDescending(x => x.Login).Compare);
            trackingAuthors.Subscribe();
            trackingAssignees.Subscribe();

            Authors   = trackingAuthors.CreateListenerCollection(EmptyUser, this.WhenAnyValue(x => x.SelectedAuthor));
            Assignees = trackingAssignees.CreateListenerCollection(EmptyUser, this.WhenAnyValue(x => x.SelectedAssignee));

            CreatePullRequests();

            this.WhenAny(x => x.SelectedState, x => x.Value)
            .Where(x => PullRequests != null)
            .Subscribe(s => UpdateFilter(s, SelectedAssignee, SelectedAuthor, SearchQuery));

            this.WhenAny(x => x.SelectedAssignee, x => x.Value)
            .Where(x => PullRequests != null && x != EmptyUser)
            .Subscribe(a => UpdateFilter(SelectedState, a, SelectedAuthor, SearchQuery));

            this.WhenAny(x => x.SelectedAuthor, x => x.Value)
            .Where(x => PullRequests != null && x != EmptyUser)
            .Subscribe(a => UpdateFilter(SelectedState, SelectedAssignee, a, SearchQuery));

            this.WhenAny(x => x.SearchQuery, x => x.Value)
            .Where(x => PullRequests != null)
            .Subscribe(f => UpdateFilter(SelectedState, SelectedAssignee, SelectedAuthor, f));

            this.WhenAnyValue(x => x.SelectedRepository)
            .Skip(1)
            .Subscribe(_ => ResetAndLoad());

            OpenPullRequest = ReactiveCommand.Create();
            OpenPullRequest.Subscribe(DoOpenPullRequest);
            CreatePullRequest = ReactiveCommand.Create();
            CreatePullRequest.Subscribe(_ => DoCreatePullRequest());

            OpenPullRequestOnGitHub = ReactiveCommand.Create();
            OpenPullRequestOnGitHub.Subscribe(x => DoOpenPullRequestOnGitHub((int)x));

            // Get the current pull request session and the selected repository. When the session's
            // repository is the same as our selected repository set CheckedOutPullRequest to the
            // current session's model, so that the checked out PR can be highlighted.
            Observable.CombineLatest(
                sessionManager.WhenAnyValue(x => x.CurrentSession),
                this.WhenAnyValue(x => x.SelectedRepository),
                (s, r) => new { Session = s, Repository = r })
            .Subscribe(x =>
            {
                CheckedOutPullRequest = x.Session?.RepositoryOwner == x.Repository?.Owner ?
                                        x.Session?.PullRequest : null;
            });

            constructing = false;
        }