Add timestamp and revisionCount to issue and patch listings

This commit is contained in:
Sebastian Martinez
2024-09-18 14:37:58 +02:00
committed by Rūdolfs Ošiņš
parent 58f2ec2f51
commit 91ba8ab390
7 changed files with 21 additions and 8 deletions
+1
View File
@@ -8,4 +8,5 @@ export type Issue = {
state: { status: "closed"; reason: "other" | "solved" } | { status: "open" };
assignees: Array<Author>;
labels: Array<string>;
timestamp: number;
};
+2
View File
@@ -23,4 +23,6 @@ export type Patch = {
};
assignees: Array<Author>;
labels: Array<string>;
timestamp: number;
revisionCount: number;
};
+1 -1
View File
@@ -59,7 +59,7 @@ impl AppState {
"issues": issues,
"patches": patches,
"head": head,
"lastCommit": commit.time().seconds(),
"lastCommit": commit.time().seconds() * 1000,
},
}))
});
+13 -3
View File
@@ -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(),
}
}
}
+2 -1
View File
@@ -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>
+2 -1
View File
@@ -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>
-2
View File
@@ -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",