From 674b28f678782070376060f822a0af62745f6ee7 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sun, 28 Aug 2022 03:25:21 -0400 Subject: [PATCH] Fixes more serialization issues w/ commit details --- src/git/models/issue.ts | 19 +++++++++++++++++++ src/git/models/pullRequest.ts | 6 +++--- .../commitDetails/commitDetailsWebviewView.ts | 7 ++++--- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/git/models/issue.ts b/src/git/models/issue.ts index 586235e..2d1fede 100644 --- a/src/git/models/issue.ts +++ b/src/git/models/issue.ts @@ -18,6 +18,25 @@ export interface IssueOrPullRequest { readonly closed: boolean; } +export function serializeIssueOrPullRequest(value: IssueOrPullRequest): IssueOrPullRequest { + const serialized: IssueOrPullRequest = { + type: value.type, + provider: { + id: value.provider.id, + name: value.provider.name, + domain: value.provider.domain, + icon: value.provider.icon, + }, + id: value.id, + title: value.title, + url: value.url, + date: value.date, + closedDate: value.closedDate, + closed: value.closed, + }; + return serialized; +} + export namespace IssueOrPullRequest { export function getMarkdownIcon(issue: IssueOrPullRequest): string { if (issue.type === IssueOrPullRequestType.PullRequest) { diff --git a/src/git/models/pullRequest.ts b/src/git/models/pullRequest.ts index 3105e98..532f3ad 100644 --- a/src/git/models/pullRequest.ts +++ b/src/git/models/pullRequest.ts @@ -24,8 +24,8 @@ export interface PullRequestShape extends IssueOrPullRequest { readonly mergedDate?: Date; } -export function toPullRequestShape(value: PullRequest): PullRequestShape { - const shape: PullRequestShape = { +export function serializePullRequest(value: PullRequest): PullRequestShape { + const serialized: PullRequestShape = { type: value.type, provider: { id: value.provider.id, @@ -47,7 +47,7 @@ export function toPullRequestShape(value: PullRequest): PullRequestShape { state: value.state, mergedDate: value.mergedDate, }; - return shape; + return serialized; } export class PullRequest implements PullRequestShape { diff --git a/src/webviews/commitDetails/commitDetailsWebviewView.ts b/src/webviews/commitDetails/commitDetailsWebviewView.ts index 3e353bd..c066c53 100644 --- a/src/webviews/commitDetails/commitDetailsWebviewView.ts +++ b/src/webviews/commitDetails/commitDetailsWebviewView.ts @@ -9,8 +9,9 @@ import { isCommit } from '../../git/models/commit'; import type { GitFileChange } from '../../git/models/file'; import { GitFile } from '../../git/models/file'; import type { IssueOrPullRequest } from '../../git/models/issue'; +import { serializeIssueOrPullRequest } from '../../git/models/issue'; import type { PullRequest } from '../../git/models/pullRequest'; -import { toPullRequestShape } from '../../git/models/pullRequest'; +import { serializePullRequest } from '../../git/models/pullRequest'; import type { GitRevisionReference } from '../../git/models/reference'; import { Logger } from '../../logger'; import type { ShowCommitInGraphCommandArgs } from '../../plus/webviews/graph/graphWebview'; @@ -320,8 +321,8 @@ export class CommitDetailsWebviewView extends WebviewViewBase