Skip to content

Commit 97a3398

Browse files
committed
Avoids loading uncached avatars for now
Until we can dynamically update the Graph when scrolled into view
1 parent a07e85f commit 97a3398

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

src/avatars.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,31 +67,41 @@ const retryDecay = [
6767
millisecondsPerDay * 7,
6868
];
6969

70+
export function getAvatarUri(
71+
email: string | undefined,
72+
repoPathOrCommit: undefined,
73+
options?: { defaultStyle?: GravatarDefaultStyle; size?: number },
74+
): Uri;
75+
export function getAvatarUri(
76+
email: string | undefined,
77+
repoPathOrCommit: string | GitRevisionReference,
78+
options?: { defaultStyle?: GravatarDefaultStyle; size?: number },
79+
): Uri | Promise<Uri>;
7080
export function getAvatarUri(
7181
email: string | undefined,
7282
repoPathOrCommit: string | GitRevisionReference | undefined,
73-
{ defaultStyle, size = 16 }: { defaultStyle?: GravatarDefaultStyle; size?: number } = {},
83+
options?: { defaultStyle?: GravatarDefaultStyle; size?: number },
7484
): Uri | Promise<Uri> {
7585
ensureAvatarCache(avatarCache);
7686

7787
// Double the size to avoid blurring on the retina screen
78-
size *= 2;
88+
const size = (options?.size ?? 16) * 2;
7989

8090
if (!email) {
8191
const avatar = createOrUpdateAvatar(
8292
`${missingGravatarHash}:${size}`,
8393
undefined,
8494
size,
8595
missingGravatarHash,
86-
defaultStyle,
96+
options?.defaultStyle,
8797
);
8898
return avatar.uri ?? avatar.fallback!;
8999
}
90100

91101
const hash = md5(email.trim().toLowerCase(), 'hex');
92102
const key = `${hash}:${size}`;
93103

94-
const avatar = createOrUpdateAvatar(key, email, size, hash, defaultStyle);
104+
const avatar = createOrUpdateAvatar(key, email, size, hash, options?.defaultStyle);
95105
if (avatar.uri != null) return avatar.uri;
96106

97107
let query = avatarQueue.get(key);

src/env/node/git/localGitProvider.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type {
1212
Repository as BuiltInGitRepository,
1313
GitExtension,
1414
} from '../../../@types/vscode.git';
15+
import { getAvatarUri } from '../../../avatars';
1516
import { configuration } from '../../../configuration';
1617
import { CoreGitConfiguration, GlyphChars, Schemes } from '../../../constants';
1718
import type { Container } from '../../../container';
@@ -1735,7 +1736,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
17351736
);
17361737
}
17371738

1738-
private async getCommitsForGraphCore(
1739+
private getCommitsForGraphCore(
17391740
repoPath: string,
17401741
asWebviewUri: (uri: Uri) => Uri,
17411742
log: GitLog | undefined,
@@ -1747,7 +1748,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
17471748
mode?: 'single' | 'local' | 'all';
17481749
ref?: string;
17491750
},
1750-
): Promise<GitGraph> {
1751+
): GitGraph {
17511752
if (log == null) {
17521753
return {
17531754
repoPath: repoPath,
@@ -1849,7 +1850,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
18491850
sha: commit.sha,
18501851
parents: parents,
18511852
author: commit.author.name,
1852-
avatarUrl: !isStashCommit ? (await commit.getAvatarUri())?.toString(true) : undefined,
1853+
avatarUrl: !isStashCommit ? getAvatarUri(commit.author.email, undefined).toString(true) : undefined,
18531854
email: commit.author.email ?? '',
18541855
date: commit.committer.date.getTime(),
18551856
message: emojify(commit.message && String(commit.message).length ? commit.message : commit.summary),

0 commit comments

Comments
 (0)