Преглед изворни кода

Avoids loading uncached avatars for now

Until we can dynamically update the Graph when scrolled into view
main
Eric Amodio пре 2 година
родитељ
комит
97a3398624
2 измењених фајлова са 18 додато и 7 уклоњено
  1. +14
    -4
      src/avatars.ts
  2. +4
    -3
      src/env/node/git/localGitProvider.ts

+ 14
- 4
src/avatars.ts Прегледај датотеку

@ -69,13 +69,23 @@ const retryDecay = [
export function getAvatarUri(
email: string | undefined,
repoPathOrCommit: undefined,
options?: { defaultStyle?: GravatarDefaultStyle; size?: number },
): Uri;
export function getAvatarUri(
email: string | undefined,
repoPathOrCommit: string | GitRevisionReference,
options?: { defaultStyle?: GravatarDefaultStyle; size?: number },
): Uri | Promise<Uri>;
export function getAvatarUri(
email: string | undefined,
repoPathOrCommit: string | GitRevisionReference | undefined,
{ defaultStyle, size = 16 }: { defaultStyle?: GravatarDefaultStyle; size?: number } = {},
options?: { defaultStyle?: GravatarDefaultStyle; size?: number },
): Uri | Promise<Uri> {
ensureAvatarCache(avatarCache);
// Double the size to avoid blurring on the retina screen
size *= 2;
const size = (options?.size ?? 16) * 2;
if (!email) {
const avatar = createOrUpdateAvatar(
@ -83,7 +93,7 @@ export function getAvatarUri(
undefined,
size,
missingGravatarHash,
defaultStyle,
options?.defaultStyle,
);
return avatar.uri ?? avatar.fallback!;
}
@ -91,7 +101,7 @@ export function getAvatarUri(
const hash = md5(email.trim().toLowerCase(), 'hex');
const key = `${hash}:${size}`;
const avatar = createOrUpdateAvatar(key, email, size, hash, defaultStyle);
const avatar = createOrUpdateAvatar(key, email, size, hash, options?.defaultStyle);
if (avatar.uri != null) return avatar.uri;
let query = avatarQueue.get(key);

+ 4
- 3
src/env/node/git/localGitProvider.ts Прегледај датотеку

@ -12,6 +12,7 @@ import type {
Repository as BuiltInGitRepository,
GitExtension,
} from '../../../@types/vscode.git';
import { getAvatarUri } from '../../../avatars';
import { configuration } from '../../../configuration';
import { CoreGitConfiguration, GlyphChars, Schemes } from '../../../constants';
import type { Container } from '../../../container';
@ -1735,7 +1736,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
);
}
private async getCommitsForGraphCore(
private getCommitsForGraphCore(
repoPath: string,
asWebviewUri: (uri: Uri) => Uri,
log: GitLog | undefined,
@ -1747,7 +1748,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
mode?: 'single' | 'local' | 'all';
ref?: string;
},
): Promise<GitGraph> {
): GitGraph {
if (log == null) {
return {
repoPath: repoPath,
@ -1849,7 +1850,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
sha: commit.sha,
parents: parents,
author: commit.author.name,
avatarUrl: !isStashCommit ? (await commit.getAvatarUri())?.toString(true) : undefined,
avatarUrl: !isStashCommit ? getAvatarUri(commit.author.email, undefined).toString(true) : undefined,
email: commit.author.email ?? '',
date: commit.committer.date.getTime(),
message: emojify(commit.message && String(commit.message).length ? commit.message : commit.summary),

Loading…
Откажи
Сачувај