public async Task InitializeAsync( ILocalRepositoryModel localRepository, IConnection connection, string owner, string repo, int pullRequestNumber) { if (repo != localRepository.Name) { throw new NotSupportedException(); } IsLoading = true; try { LocalRepository = localRepository; RemoteRepositoryOwner = owner; session = await sessionManager.GetSession(owner, repo, pullRequestNumber).ConfigureAwait(true); await Load(session.PullRequest).ConfigureAwait(true); if (LocalRepository?.CloneUrl != null) { var key = GetDraftKey(); if (string.IsNullOrEmpty(Body)) { var draft = await draftStore.GetDraft <PullRequestReviewDraft>(key, string.Empty) .ConfigureAwait(true); Body = draft?.Body; } this.WhenAnyValue(x => x.Body) .Throttle(TimeSpan.FromSeconds(1), timerScheduler) .Select(x => new PullRequestReviewDraft { Body = x }) .Subscribe(x => draftStore.UpdateDraft(key, string.Empty, x)); } } finally { IsLoading = false; } }
async Task LoadInitialState(string draftKey) { if (activeLocalRepo.CloneUrl == null) { return; } var draft = await draftStore.GetDraft <PullRequestDraft>(draftKey, string.Empty).ConfigureAwait(true); if (draft != null) { PRTitle = draft.Title; Description = draft.Body; } else { LoadDescriptionFromCommits(); } }