mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 10:10:30 +08:00
Fix repo cards failing to load when head commit with non-utf8 are loaded
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
<script lang="ts">
|
||||
import type { RepoInfo } from "./RepoCard";
|
||||
import type { BaseUrl } from "@http-client";
|
||||
|
||||
import { HttpdClient } from "@http-client";
|
||||
|
||||
import {
|
||||
absoluteTimestamp,
|
||||
@@ -15,6 +18,9 @@
|
||||
|
||||
export let compact = false;
|
||||
export let repoInfo: RepoInfo;
|
||||
export let baseUrl: BaseUrl;
|
||||
|
||||
const api = new HttpdClient(baseUrl);
|
||||
|
||||
$: repo = repoInfo.repo;
|
||||
$: project = repoInfo.repo.payloads["xyz.radicle.project"];
|
||||
@@ -174,14 +180,15 @@
|
||||
<Icon name="issue" />
|
||||
{project.meta.issues.open} ·
|
||||
<Icon name="patch" />
|
||||
<span
|
||||
style:overflow="hidden"
|
||||
style:text-overflow="ellipsis"
|
||||
title={absoluteTimestamp(repoInfo.lastCommit.commit.committer.time)}>
|
||||
{project.meta.patches.open} · Updated {formatTimestamp(
|
||||
repoInfo.lastCommit.commit.committer.time,
|
||||
)}
|
||||
</span>
|
||||
{project.meta.patches.open}
|
||||
{#await api.repo.getCommitBySha(repo.rid, project.meta.head) then { commit }}
|
||||
<span
|
||||
style:overflow="hidden"
|
||||
style:text-overflow="ellipsis"
|
||||
title={absoluteTimestamp(commit.committer.time)}>
|
||||
· Updated {formatTimestamp(commit.committer.time)}
|
||||
</span>
|
||||
{/await}
|
||||
<span
|
||||
title={repo.rid}
|
||||
style:color="var(--color-foreground-emphasized)"
|
||||
|
||||
+13
-15
@@ -1,13 +1,12 @@
|
||||
import type { Repo, RepoListQuery } from "@http-client";
|
||||
import type { BaseUrl, Repo, RepoListQuery } from "@http-client";
|
||||
|
||||
import { loadRepoActivity, type WeeklyActivity } from "@app/lib/commit";
|
||||
import { HttpdClient, type BaseUrl, type Commit } from "@http-client";
|
||||
import { HttpdClient } from "@http-client";
|
||||
|
||||
export interface RepoInfo {
|
||||
repo: Repo;
|
||||
baseUrl: BaseUrl;
|
||||
activity: WeeklyActivity[];
|
||||
lastCommit: Commit;
|
||||
}
|
||||
|
||||
export async function fetchRepoInfos(
|
||||
@@ -27,21 +26,20 @@ export async function fetchRepoInfos(
|
||||
repos
|
||||
.filter(r => Boolean(r.payloads["xyz.radicle.project"]))
|
||||
.map(async repo => {
|
||||
const [activity, lastCommit] = await Promise.all([
|
||||
loadRepoActivity(repo.rid, baseUrl),
|
||||
api.repo.getCommitBySha(
|
||||
repo.rid,
|
||||
repo["payloads"]["xyz.radicle.project"].meta.head,
|
||||
),
|
||||
]);
|
||||
return { repo, activity, lastCommit, baseUrl };
|
||||
const activity = await loadRepoActivity(repo.rid, baseUrl);
|
||||
return { repo, activity, baseUrl };
|
||||
}),
|
||||
);
|
||||
|
||||
return info.sort((a, b) => {
|
||||
const aLastCommit = a.lastCommit.commit.committer.time;
|
||||
const bLastCommit = b.lastCommit.commit.committer.time;
|
||||
|
||||
return bLastCommit - aLastCommit;
|
||||
if (a.activity.length === 0 && b.activity.length === 0) {
|
||||
return 0;
|
||||
} else if (a.activity.length === 0 && b.activity.length > 0) {
|
||||
return 1;
|
||||
} else if (b.activity.length === 0 && a.activity.length > 0) {
|
||||
return -1;
|
||||
} else {
|
||||
return b.activity[0].time - a.activity[0].time;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -415,7 +415,7 @@
|
||||
{#if repoInfos.length > 0}
|
||||
<div class="repo-grid">
|
||||
{#each repoInfos as repoInfo}
|
||||
<RepoCard {repoInfo} />
|
||||
<RepoCard {baseUrl} {repoInfo} />
|
||||
{/each}
|
||||
</div>
|
||||
<div class="subtitle">
|
||||
|
||||
@@ -360,7 +360,7 @@
|
||||
{#if repos.length > 0}
|
||||
<div class="repo-grid">
|
||||
{#each repos as repoInfo}
|
||||
<RepoCard {repoInfo}>
|
||||
<RepoCard {repoInfo} {baseUrl}>
|
||||
<svelte:fragment slot="delegate">
|
||||
<Badge
|
||||
title={`${node.alias || utils.formatNodeId(did.pubkey)} is a delegate of this repository`}
|
||||
|
||||
Reference in New Issue
Block a user