Skip to content

Commit 248f043

Browse files
author
Stephen Gutekanst
committed
update to use new code discussions api (cleaner)
1 parent c39e5a9 commit 248f043

File tree

2 files changed

+8
-27
lines changed

2 files changed

+8
-27
lines changed

src/api.ts

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ export async function fetchDiscussionThreads(opts: {
124124
threadID?: GQL.ID;
125125
authorUserID?: GQL.ID;
126126
targetRepositoryID?: GQL.ID;
127+
targetRepositoryName?: string;
128+
targetRepositoryGitCloneURL?: string;
127129
targetRepositoryPath?: string;
128130
relativeRev?: string;
129131
}): Promise<GQL.IDiscussionThreadConnection> {
@@ -136,6 +138,8 @@ export async function fetchDiscussionThreads(opts: {
136138
$threadID: ID
137139
$authorUserID: ID
138140
$targetRepositoryID: ID
141+
$targetRepositoryName: String
142+
$targetRepositoryGitCloneURL: String
139143
$targetRepositoryPath: String
140144
$relativeRev: String!
141145
) {
@@ -145,6 +149,8 @@ export async function fetchDiscussionThreads(opts: {
145149
threadID: $threadID
146150
authorUserID: $authorUserID
147151
targetRepositoryID: $targetRepositoryID
152+
targetRepositoryName: $targetRepositoryName
153+
targetRepositoryGitCloneURL: $targetRepositoryGitCloneURL
148154
targetRepositoryPath: $targetRepositoryPath
149155
) {
150156
totalCount
@@ -266,27 +272,3 @@ export async function renderMarkdown(
266272
}
267273
return data.renderMarkdown;
268274
}
269-
270-
/**
271-
* Turn a repository name into a GraphQL repository ID.
272-
*
273-
* @return Promise that emits the ID.
274-
*/
275-
export async function resolveRepository(
276-
repositoryName: string
277-
): Promise<GQL.ID> {
278-
let { data, errors } = await queryGraphQL(
279-
`
280-
query ResolveRepository($repositoryName: String!) {
281-
repository(name:$repositoryName) {
282-
id
283-
}
284-
}
285-
`,
286-
{ repositoryName }
287-
);
288-
if (!data || !data.repository || !data.repository.id) {
289-
throw createAggregateError(errors);
290-
}
291-
return data.repository.id;
292-
}

src/extension.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as sourcegraph from "sourcegraph";
2-
import { fetchDiscussionThreads, resolveRepository } from "./api";
2+
import { fetchDiscussionThreads } from "./api";
33
import * as GQL from "./graphqlschema";
44
import distanceInWordsToNow from "date-fns/distance_in_words_to_now";
55
import { resolveSettings, Settings } from "./settings";
@@ -26,10 +26,9 @@ export function activate(): void {
2626
filePath: u.hash.slice(1)
2727
};
2828

29-
const repoID = await resolveRepository(uri.repositoryName);
3029
const threads = await fetchDiscussionThreads({
3130
first: 10000,
32-
targetRepositoryID: repoID,
31+
targetRepositoryName: uri.repositoryName,
3332
targetRepositoryPath: uri.filePath,
3433
relativeRev: uri.revision
3534
});

0 commit comments

Comments
 (0)