Radish alpha
r
rad:z4D5UCArafTzTQpDZNQRuqswh3ury
Radicle desktop app
Radicle
Git
Sort repos by activity
Open did:key:z6MkkfM3...sVz5 opened 1 year ago
6 files changed +11 -9 5c8844db ebc8b323
modified crates/radicle-types/bindings/repo/ProjectPayloadMeta.ts
@@ -4,5 +4,4 @@ export type ProjectPayloadMeta = {
  head: string;
  issues: { open: number; closed: number };
  patches: { open: number; draft: number; archived: number; merged: number };
-
  lastCommitTimestamp: number;
};
modified crates/radicle-types/bindings/repo/RepoInfo.ts
@@ -10,4 +10,5 @@ export type RepoInfo = {
  visibility: Visibility;
  rid: string;
  seeding: number;
+
  lastCommitTimestamp: number;
};
modified crates/radicle-types/src/repo.rs
@@ -10,6 +10,7 @@ use crate::cobs::Author;
use crate::error;

#[derive(Serialize, TS)]
+
#[serde(rename_all = "camelCase")]
#[ts(export)]
#[ts(export_to = "repo/")]
pub struct RepoInfo {
@@ -20,6 +21,8 @@ pub struct RepoInfo {
    #[ts(as = "String")]
    pub rid: identity::RepoId,
    pub seeding: usize,
+
    #[ts(type = "number")]
+
    pub last_commit_timestamp: i64,
}

#[derive(Default, Serialize, TS)]
@@ -110,8 +113,6 @@ pub struct ProjectPayloadMeta {
    pub issues: issue::IssueCounts,
    #[ts(type = "{ open: number, draft: number, archived: number, merged: number }")]
    pub patches: patch::PatchCounts,
-
    #[ts(type = "number")]
-
    pub last_commit_timestamp: i64,
}

#[derive(Clone, Serialize, TS, Debug, PartialEq)]
modified crates/radicle-types/src/traits/repo.rs
@@ -49,7 +49,7 @@ pub trait Repo: Profile {
            entries.push(repo_info)
        }

-
        entries.sort_by_key(|repo::RepoInfo { rid, .. }| *rid);
+
        entries.sort_by(|a, b| b.last_commit_timestamp.cmp(&a.last_commit_timestamp));

        Ok::<_, Error>(entries)
    }
@@ -97,12 +97,12 @@ pub trait Repo: Profile {
            .collect::<Vec<_>>();
        let db = profile.database()?;
        let seeding = db.count(&repo.id).unwrap_or_default();
+
        let (_, head) = repo.head()?;
+
        let commit = repo.commit(head)?;
        let project = doc
            .payload()
            .get(&doc::PayloadId::project())
            .and_then(|payload| {
-
                let (_, head) = repo.head().ok()?;
-
                let commit = repo.commit(head).ok()?;
                let patches = profile.patches(repo).ok()?;
                let patches = patches.counts().ok()?;
                let issues = profile.issues(repo).ok()?;
@@ -113,7 +113,6 @@ pub trait Repo: Profile {
                    issues,
                    patches,
                    head,
-
                    last_commit_timestamp: commit.time().seconds() * 1000,
                };

                Some(repo::ProjectPayload::new(data, meta))
@@ -126,6 +125,7 @@ pub trait Repo: Profile {
            visibility: doc.visibility().clone().into(),
            rid: repo.id,
            seeding,
+
            last_commit_timestamp: commit.time().seconds() * 1000,
        })
    }

modified src/components/RepoCard.svelte
@@ -68,7 +68,7 @@
        </div>
      </div>
      <span style:color="var(--color-fill-gray)">
-
        Updated {formatTimestamp(project.meta.lastCommitTimestamp)}
+
        Updated {formatTimestamp(repo.lastCommitTimestamp)}
      </span>
    </div>
  </div>
modified tests/e2e/clipboard.spec.ts
@@ -1,6 +1,7 @@
import { chromium } from "playwright";

import { expect, markdownRid, test } from "@tests/support/fixtures.js";
+
import { formatRepositoryId } from "@app/lib/utils";

// We explicitly run all clipboard tests withing the context of a single test
// so that we don't run into race conditions, because there is no way to isolate
@@ -18,7 +19,7 @@ test("copy to clipboard", async () => {

  // Repo ID.
  {
-
    await page.getByLabel("repo-id").first().click();
+
    await page.getByText(formatRepositoryId(markdownRid)).click();
    const clipboardContent = await page.evaluate<string>(
      "navigator.clipboard.readText()",
    );