Skip to content

Commit

Permalink
Fixes avatars from getting lost on Home
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Dec 20, 2024
1 parent 2e362df commit e6f5a9a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 78 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed

- Fixes [#3899](https://github.com/gitkraken/vscode-gitlens/issues/#3899) - custom autolinks not being detected
- Fixes owner avatars from getting lost (progressively) on refresh of the _Home_ view
- Fixes launchpad status icon for 'waiting for review' state on _Home_
- Fixes missing _Delete Branch..._ command from branches on worktrees in the _Branches_ view

Expand Down
39 changes: 3 additions & 36 deletions src/webviews/apps/plus/home/components/branch-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ export abstract class GlBranchCardBase extends GlElement {
this.autolinksPromise = value?.autolinks;
this.contributorsPromise = value?.contributors;
this.issuesPromise = value?.issues;
this.ownerPromise = value?.owner;
this.prPromise = value?.pr;
this.wipPromise = value?.wip;
}
Expand Down Expand Up @@ -308,26 +307,6 @@ export abstract class GlBranchCardBase extends GlElement {
);
}

@state()
private _owner!: Awaited<GetOverviewBranch['owner']>;
get owner() {
return this._owner;
}

private _ownerPromise!: GetOverviewBranch['owner'];
get ownerPromise() {
return this._ownerPromise;
}
set ownerPromise(value: GetOverviewBranch['owner']) {
if (this._ownerPromise === value) return;

this._ownerPromise = value;
void this._ownerPromise?.then(
r => (this._owner = r),
() => (this._owner = undefined),
);
}

@state()
private _pr!: Awaited<GetOverviewBranch['pr']>;
get pr() {
Expand Down Expand Up @@ -526,24 +505,12 @@ export abstract class GlBranchCardBase extends GlElement {
}

protected renderAvatars() {
const { owner, contributors } = this;

const avatars = [];

if (owner) {
avatars.push(owner);
}
const { contributors } = this;

if (contributors) {
avatars.push(...contributors);
}

if (avatars.length === 0) {
return undefined;
}
if (!contributors?.length) return undefined;

return html`<gl-avatar-list
.avatars=${avatars.map(a => ({ name: a.name, src: a.avatarUrl }))}
.avatars=${contributors.map(a => ({ name: a.name, src: a.avatarUrl }))}
max="1"
></gl-avatar-list>`;
}
Expand Down
25 changes: 0 additions & 25 deletions src/webviews/home/homeWebview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ type BranchMergeTargetStatusInfo = Awaited<GetOverviewBranch['mergeTarget']>;
type ContributorsInfo = Awaited<GetOverviewBranch['contributors']>;
type IssuesInfo = Awaited<GetOverviewBranch['issues']>;
type LaunchpadItemInfo = Awaited<NonNullable<Awaited<GetOverviewBranch['pr']>>['launchpad']>;
type OwnerInfo = Awaited<GetOverviewBranch['owner']>;
type PullRequestInfo = Awaited<GetOverviewBranch['pr']>;
type WipInfo = Awaited<GetOverviewBranch['wip']>;

Expand Down Expand Up @@ -1323,7 +1322,6 @@ function enrichOverviewBranches(
branch.wip = getWipInfo(container, branch, statusPromises.get(branch.id), isActive);

const contributors = contributorsPromises.get(branch.id);
branch.owner = getOwnerInfo(container, contributors);
branch.contributors = getContributorsInfo(container, contributors);

branch.mergeTarget = mergeTargetPromises.get(branch.id);
Expand Down Expand Up @@ -1379,29 +1377,6 @@ async function getContributorsInfo(
return result.map(r => (r.status === 'fulfilled' ? r.value : undefined)).filter(r => r != null);
}

async function getOwnerInfo(
_container: Container,
contributorsPromise: Promise<BranchContributorOverview | undefined> | undefined,
) {
if (contributorsPromise == null) return undefined;

const contributors = await contributorsPromise;
if (contributors == null) return undefined;

const owner = contributors.owner ?? contributors.contributors?.shift();
if (owner == null) return undefined;

return {
name: owner.name ?? '',
email: owner.email ?? '',
current: owner.current,
timestamp: owner.date?.getTime(),
count: owner.count,
stats: owner.stats,
avatarUrl: (await owner.getAvatarUri())?.toString(),
} satisfies OwnerInfo;
}

async function getBranchMergeTargetStatusInfo(
container: Container,
branch: GitBranch,
Expand Down
17 changes: 0 additions & 17 deletions src/webviews/home/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,6 @@ export interface GetOverviewBranch {
| undefined
>;

owner?: Promise<
| {
name: string;
email: string;
avatarUrl: string;
current: boolean;
timestamp?: number;
count: number;
stats?: {
files: number;
additions: number;
deletions: number;
};
}
| undefined
>;

contributors?: Promise<
{
name: string;
Expand Down

0 comments on commit e6f5a9a

Please sign in to comment.