Skip to content

Commit

Permalink
Add timestamp and revisionCount to issue and patch listings
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastinez committed Sep 18, 2024
1 parent 797a64b commit 54ae465
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 8 deletions.
1 change: 1 addition & 0 deletions src-tauri/bindings/Issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export type Issue = {
state: { status: "closed"; reason: "other" | "solved" } | { status: "open" };
assignees: Array<Author>;
labels: Array<string>;
timestamp: number;
};
2 changes: 2 additions & 0 deletions src-tauri/bindings/Patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ export type Patch = {
};
assignees: Array<Author>;
labels: Array<string>;
timestamp: number;
revisionCount: number;
};
2 changes: 1 addition & 1 deletion src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl AppState {
"issues": issues,
"patches": patches,
"head": head,
"lastCommit": commit.time().seconds(),
"lastCommit": commit.time().seconds() * 1000,
},
}))
});
Expand Down
16 changes: 13 additions & 3 deletions src-tauri/src/types/cobs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use radicle::cob::Label;
use radicle::cob;
use radicle::identity;
use radicle::issue;
use radicle::node::{Alias, AliasStore};
Expand Down Expand Up @@ -27,6 +27,7 @@ impl Author {

#[derive(TS, Serialize)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct Issue {
#[ts(as = "String")]
id: String,
Expand All @@ -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 {
Expand All @@ -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,
Expand All @@ -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 {
Expand All @@ -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(),
}
}
}
3 changes: 2 additions & 1 deletion src/components/IssueTeaser.svelte
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -68,6 +68,7 @@
alias={issue.author.alias} />
opened
<div class="global-oid">{formatOid(issue.id)}</div>
{formatTimestamp(issue.timestamp)}
</div>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/components/PatchTeaser.svelte
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -73,6 +73,7 @@
alias={patch.author.alias} />
opened
<div class="global-oid">{formatOid(patch.id)}</div>
{formatTimestamp(patch.timestamp)}
</div>
</div>
</div>
Expand Down
2 changes: 0 additions & 2 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 54ae465

Please sign in to comment.