Radish alpha
r
rad:z4D5UCArafTzTQpDZNQRuqswh3ury
Radicle desktop app
Radicle
Git
Add `timestamp` and `revisionCount` to issue and patch listings
Merged did:key:z6MkkfM3...sVz5 opened 1 year ago
7 files changed +21 -8 58f2ec2f ccd4c280
modified src-tauri/bindings/Issue.ts
@@ -8,4 +8,5 @@ export type Issue = {
  state: { status: "closed"; reason: "other" | "solved" } | { status: "open" };
  assignees: Array<Author>;
  labels: Array<string>;
+
  timestamp: number;
};
modified src-tauri/bindings/Patch.ts
@@ -23,4 +23,6 @@ export type Patch = {
      };
  assignees: Array<Author>;
  labels: Array<string>;
+
  timestamp: number;
+
  revisionCount: number;
};
modified src-tauri/src/lib.rs
@@ -53,7 +53,7 @@ impl AppState {
                    "issues": issues,
                    "patches": patches,
                    "head": head,
-
                    "lastCommit": commit.time().seconds(),
+
                    "lastCommit": commit.time().seconds() * 1000,
                },
            }))
        });
modified src-tauri/src/types/cobs.rs
@@ -1,4 +1,4 @@
-
use radicle::cob::Label;
+
use radicle::cob;
use radicle::identity;
use radicle::issue;
use radicle::node::{Alias, AliasStore};
@@ -27,6 +27,7 @@ impl Author {

#[derive(TS, Serialize)]
#[ts(export)]
+
#[serde(rename_all = "camelCase")]
pub struct Issue {
    #[ts(as = "String")]
    id: String,
@@ -36,7 +37,9 @@ pub struct Issue {
    state: issue::State,
    assignees: Vec<Author>,
    #[ts(as = "Vec<String>")]
-
    labels: Vec<Label>,
+
    labels: Vec<cob::Label>,
+
    #[ts(type = "number")]
+
    timestamp: cob::Timestamp,
}

impl Issue {
@@ -51,12 +54,14 @@ impl Issue {
                .map(|did| Author::new(*did, aliases))
                .collect::<Vec<_>>(),
            labels: issue.labels().cloned().collect::<Vec<_>>(),
+
            timestamp: issue.timestamp(),
        }
    }
}

#[derive(TS, Serialize)]
#[ts(export)]
+
#[serde(rename_all = "camelCase")]
pub struct Patch {
    #[ts(as = "String")]
    id: String,
@@ -75,7 +80,10 @@ pub struct Patch {
    state: patch::State,
    assignees: Vec<Author>,
    #[ts(as = "Vec<String>")]
-
    labels: Vec<Label>,
+
    labels: Vec<cob::Label>,
+
    #[ts(type = "number")]
+
    timestamp: cob::Timestamp,
+
    revision_count: usize,
}

impl Patch {
@@ -90,6 +98,8 @@ impl Patch {
                .map(|did| Author::new(did, aliases))
                .collect::<Vec<_>>(),
            labels: patch.labels().cloned().collect::<Vec<_>>(),
+
            timestamp: patch.timestamp(),
+
            revision_count: patch.revisions().count(),
        }
    }
}
modified src/components/IssueTeaser.svelte
@@ -1,7 +1,7 @@
<script lang="ts">
  import type { Issue } from "@bindings/Issue";

-
  import { formatOid } from "@app/lib/utils";
+
  import { formatOid, formatTimestamp } from "@app/lib/utils";

  import Icon from "./Icon.svelte";
  import InlineTitle from "./InlineTitle.svelte";
@@ -68,6 +68,7 @@
          alias={issue.author.alias} />
        opened
        <div class="global-oid">{formatOid(issue.id)}</div>
+
        {formatTimestamp(issue.timestamp)}
      </div>
    </div>
  </div>
modified src/components/PatchTeaser.svelte
@@ -1,7 +1,7 @@
<script lang="ts">
  import type { Patch } from "@bindings/Patch";

-
  import { formatOid } from "@app/lib/utils";
+
  import { formatOid, formatTimestamp } from "@app/lib/utils";

  import Icon from "./Icon.svelte";
  import InlineTitle from "./InlineTitle.svelte";
@@ -73,6 +73,7 @@
          alias={patch.author.alias} />
        opened
        <div class="global-oid">{formatOid(patch.id)}</div>
+
        {formatTimestamp(patch.timestamp)}
      </div>
    </div>
  </div>
modified src/lib/utils.ts
@@ -51,8 +51,6 @@ export const formatTimestamp = (
    second: 1000,
  };

-
  // Multiplying timestamp with 1000 to convert from seconds to milliseconds
-
  timestamp = timestamp * 1000;
  const rtf = new Intl.RelativeTimeFormat("en", {
    numeric: "auto",
    style: "long",