Selaa lähdekoodia

Updates remote info for enriching issues

main
Keith Daulton 1 vuosi sitten
vanhempi
commit
7b33768129
3 muutettua tiedostoa jossa 50 lisäystä ja 19 poistoa
  1. +9
    -9
      src/plus/focus/focusService.ts
  2. +35
    -5
      src/plus/webviews/focus/focusWebview.ts
  3. +6
    -5
      src/plus/webviews/focus/protocol.ts

+ 9
- 9
src/plus/focus/focusService.ts Näytä tiedosto

@ -10,7 +10,7 @@ import type { ServerConnection } from '../gk/serverConnection';
export interface FocusItem {
type: EnrichedItemResponse['entityType'];
id: string;
remote?: GitRemote<RichRemoteProvider>;
remote: GitRemote<RichRemoteProvider>;
}
export type EnrichedItem = {
@ -138,13 +138,13 @@ export class FocusService implements Disposable {
type Result = { data: EnrichedItemResponse };
const rq: EnrichedItemRequest = {
provider: item.remote!.provider.id as EnrichedItemResponse['provider'],
provider: item.remote.provider.id as EnrichedItemResponse['provider'],
entityType: item.type,
entityId: item.id,
gitRepoData: {
remoteUrl: item.remote!.url,
remotePath: item.remote!.provider.path,
remoteDomain: item.remote!.provider.domain,
remoteUrl: item.remote.url,
remotePath: item.remote.provider.path,
remoteDomain: item.remote.provider.domain,
},
};
@ -181,13 +181,13 @@ export class FocusService implements Disposable {
type Result = { data: EnrichedItemResponse };
const rq: EnrichedItemRequest = {
provider: item.remote!.provider.id as EnrichedItemResponse['provider'],
provider: item.remote.provider.id as EnrichedItemResponse['provider'],
entityType: item.type,
entityId: item.id,
gitRepoData: {
remoteUrl: item.remote!.url,
remotePath: item.remote!.provider.path,
remoteDomain: item.remote!.provider.domain,
remoteUrl: item.remote.url,
remotePath: item.remote.provider.path,
remoteDomain: item.remote.provider.domain,
},
};

+ 35
- 5
src/plus/webviews/focus/focusWebview.ts Näytä tiedosto

@ -66,10 +66,13 @@ interface SearchedPullRequestWithRemote extends SearchedPullRequest {
hasWorktree?: boolean;
isCurrentWorktree?: boolean;
rank: number;
enriched?: EnrichedItem[];
}
interface SearchedIssueWithRank extends SearchedIssue {
repoAndRemote: RepoWithRichRemote;
rank: number;
enriched?: EnrichedItem[];
}
export class FocusWebviewProvider implements WebviewProvider<State> {
@ -132,11 +135,12 @@ export class FocusWebviewProvider implements WebviewProvider {
if (pin) {
await this.container.focus.unpinItem(issueWithRemote.issue.id);
this._enrichedItems = this._enrichedItems?.filter(e => e.id !== pin);
issueWithRemote.enriched = issueWithRemote.enriched?.filter(e => e.id !== pin);
} else {
const focusItem: FocusItem = {
type: 'issue',
id: issueWithRemote.issue.id,
// remote: issueWithRemote.issue.remote,
remote: issueWithRemote.repoAndRemote.remote,
};
const enrichedItem = await this.container.focus.pinItem(focusItem);
if (enrichedItem == null) return;
@ -144,6 +148,10 @@ export class FocusWebviewProvider implements WebviewProvider {
this._enrichedItems = [];
}
this._enrichedItems.push(enrichedItem);
if (issueWithRemote.enriched == null) {
issueWithRemote.enriched = [];
}
issueWithRemote.enriched.push(enrichedItem);
}
void this.notifyDidChangeState();
@ -156,11 +164,12 @@ export class FocusWebviewProvider implements WebviewProvider {
if (snooze) {
await this.container.focus.unsnoozeItem(snooze);
this._enrichedItems = this._enrichedItems?.filter(e => e.id !== snooze);
issueWithRemote.enriched = issueWithRemote.enriched?.filter(e => e.id !== snooze);
} else {
const focusItem: FocusItem = {
type: 'issue',
id: issueWithRemote.issue.id,
// remote: issueWithRemote.issue.remote,
remote: issueWithRemote.repoAndRemote.remote,
};
const enrichedItem = await this.container.focus.snoozeItem(focusItem);
if (enrichedItem == null) return;
@ -168,6 +177,10 @@ export class FocusWebviewProvider implements WebviewProvider {
this._enrichedItems = [];
}
this._enrichedItems.push(enrichedItem);
if (issueWithRemote.enriched == null) {
issueWithRemote.enriched = [];
}
issueWithRemote.enriched.push(enrichedItem);
}
void this.notifyDidChangeState();
@ -180,6 +193,7 @@ export class FocusWebviewProvider implements WebviewProvider {
if (pin) {
await this.container.focus.unpinItem(pin);
this._enrichedItems = this._enrichedItems?.filter(e => e.id !== pin);
prWithRemote.enriched = prWithRemote.enriched?.filter(e => e.id !== pin);
} else {
const focusItem: FocusItem = {
type: 'pr',
@ -192,6 +206,10 @@ export class FocusWebviewProvider implements WebviewProvider {
this._enrichedItems = [];
}
this._enrichedItems.push(enrichedItem);
if (prWithRemote.enriched == null) {
prWithRemote.enriched = [];
}
prWithRemote.enriched.push(enrichedItem);
}
void this.notifyDidChangeState();
@ -204,6 +222,7 @@ export class FocusWebviewProvider implements WebviewProvider {
if (snooze) {
await this.container.focus.unsnoozeItem(snooze);
this._enrichedItems = this._enrichedItems?.filter(e => e.id !== snooze);
prWithRemote.enriched = prWithRemote.enriched?.filter(e => e.id !== snooze);
} else {
const focusItem: FocusItem = {
type: 'pr',
@ -216,6 +235,10 @@ export class FocusWebviewProvider implements WebviewProvider {
this._enrichedItems = [];
}
this._enrichedItems.push(enrichedItem);
if (prWithRemote.enriched == null) {
prWithRemote.enriched = [];
}
prWithRemote.enriched.push(enrichedItem);
}
void this.notifyDidChangeState();
@ -546,7 +569,8 @@ export class FocusWebviewProvider implements WebviewProvider {
private async getMyIssues(richRepos: RepoWithRichRemote[]): Promise<SearchedIssueWithRank[]> {
const allIssues = [];
for (const { remote } of richRepos) {
for (const richRepo of richRepos) {
const remote = richRepo.remote;
const issues = await this.container.git.getMyIssues(remote);
if (issues == null) {
continue;
@ -558,6 +582,7 @@ export class FocusWebviewProvider implements WebviewProvider {
}
allIssues.push({
...issue,
repoAndRemote: richRepo,
rank: 0, // getIssueRank(issue),
});
}
@ -592,7 +617,10 @@ export class FocusWebviewProvider implements WebviewProvider {
}
}
function findEnrichedItems(item: SearchedPullRequestWithRemote | SearchedIssue, enrichedItems?: EnrichedItem[]) {
function findEnrichedItems(
item: SearchedPullRequestWithRemote | SearchedIssueWithRank,
enrichedItems?: EnrichedItem[],
) {
if (enrichedItems == null || enrichedItems.length === 0) return;
let result;
@ -600,11 +628,13 @@ function findEnrichedItems(item: SearchedPullRequestWithRemote | SearchedIssue,
if ((item as SearchedPullRequestWithRemote).pullRequest != null) {
result = enrichedItems.filter(e => e.entityId === (item as SearchedPullRequestWithRemote).pullRequest.id);
} else {
result = enrichedItems.filter(e => e.entityId === (item as SearchedIssue).issue.id);
result = enrichedItems.filter(e => e.entityId === (item as SearchedIssueWithRank).issue.id);
}
if (result.length === 0) return;
item.enriched = result;
return result.map(result => {
return {
id: result.id,

+ 6
- 5
src/plus/webviews/focus/protocol.ts Näytä tiedosto

@ -18,11 +18,12 @@ export interface State {
export interface SearchResultBase {
reasons: string[];
rank?: number;
// TODO: convert to array of EnrichedItem
enriched?: {
id: EnrichedItem['id'];
type: EnrichedItem['type'];
}[];
enriched?: EnrichedItemSummary[];
}
export interface EnrichedItemSummary {
id: EnrichedItem['id'];
type: EnrichedItem['type'];
}
export interface IssueResult extends SearchResultBase {

Ladataan…
Peruuta
Tallenna