mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-16 03:40:37 +08:00
Add edited label to patches
This commit is contained in:
@@ -128,7 +128,12 @@
|
||||
</span>
|
||||
{#if lastEdit}
|
||||
<div class="card-metadata">•</div>
|
||||
<div class="card-metadata" title={utils.formatEditedCaption(lastEdit)}>
|
||||
<div
|
||||
class="card-metadata"
|
||||
title={utils.formatEditedCaption(
|
||||
lastEdit.author,
|
||||
lastEdit.timestamp,
|
||||
)}>
|
||||
edited
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
+7
-6
@@ -1,4 +1,4 @@
|
||||
import type { BaseUrl, Comment } from "@httpd-client";
|
||||
import type { BaseUrl } from "@httpd-client";
|
||||
|
||||
import md5 from "md5";
|
||||
import bs58 from "bs58";
|
||||
@@ -85,12 +85,13 @@ export function formatCommit(oid: string): string {
|
||||
return oid.substring(0, 7);
|
||||
}
|
||||
|
||||
export function formatEditedCaption(lastEdit: Comment["edits"][0]) {
|
||||
export function formatEditedCaption(
|
||||
author: { id: string; alias?: string },
|
||||
timestamp: number,
|
||||
) {
|
||||
return `${
|
||||
lastEdit.author.alias
|
||||
? lastEdit.author.alias
|
||||
: formatNodeId(lastEdit.author.id)
|
||||
} edited ${absoluteTimestamp(lastEdit.timestamp)}`;
|
||||
author.alias ? author.alias : formatNodeId(author.id)
|
||||
} edited ${absoluteTimestamp(timestamp)}`;
|
||||
}
|
||||
|
||||
export function baseUrlToUrl(baseUrl: BaseUrl): URL {
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
|
||||
let expanded = initiallyExpanded;
|
||||
const api = new HttpdClient(baseUrl);
|
||||
const latestEdit = revisionEdits.pop();
|
||||
const lastEdit = revisionEdits.at(-1);
|
||||
|
||||
function formatVerdict(verdict?: Verdict | null) {
|
||||
switch (verdict) {
|
||||
@@ -198,6 +198,10 @@
|
||||
.revision-description {
|
||||
margin-left: 2rem;
|
||||
}
|
||||
.author-metadata {
|
||||
color: var(--color-fill-gray);
|
||||
font-size: var(--font-size-small);
|
||||
}
|
||||
.compare-dropdown-item {
|
||||
font-weight: var(--font-weight-regular);
|
||||
}
|
||||
@@ -414,6 +418,17 @@
|
||||
<span title={utils.absoluteTimestamp(revisionTimestamp)}>
|
||||
{utils.formatTimestamp(revisionTimestamp)}
|
||||
</span>
|
||||
{#if lastEdit}
|
||||
<div class="author-metadata">•</div>
|
||||
<div
|
||||
class="author-metadata"
|
||||
title={utils.formatEditedCaption(
|
||||
lastEdit.author,
|
||||
lastEdit.timestamp,
|
||||
)}>
|
||||
edited
|
||||
</div>
|
||||
{/if}
|
||||
<div style="display: flex; gap: 0.5rem; margin-left: auto;">
|
||||
{#if canEdit(revisionAuthor.id) && editRevision && revisionState === "read"}
|
||||
<IconButton
|
||||
@@ -424,11 +439,11 @@
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{#if editRevision && latestEdit && revisionState !== "read"}
|
||||
{#if editRevision && lastEdit && revisionState !== "read"}
|
||||
{@const editRevision_ = editRevision}
|
||||
<ExtendedTextarea
|
||||
enableAttachments
|
||||
embeds={parseEmbedIntoMap(latestEdit.embeds)}
|
||||
embeds={parseEmbedIntoMap(lastEdit.embeds)}
|
||||
rawPath={rawPath(revisionId)}
|
||||
body={revisionDescription}
|
||||
submitCaption="Save"
|
||||
|
||||
@@ -613,7 +613,10 @@
|
||||
<div class="author-metadata">•</div>
|
||||
<div
|
||||
class="author-metadata"
|
||||
title={utils.formatEditedCaption(lastDescriptionEdit)}>
|
||||
title={utils.formatEditedCaption(
|
||||
lastDescriptionEdit.author,
|
||||
lastDescriptionEdit.timestamp,
|
||||
)}>
|
||||
edited
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -96,7 +96,6 @@
|
||||
["Archive patch", { status: "archived" }],
|
||||
["Convert to draft", { status: "draft" }],
|
||||
];
|
||||
const latestEdit = patch.revisions[0].edits.pop();
|
||||
|
||||
async function editPatch(sessionId: string, title: string) {
|
||||
try {
|
||||
@@ -542,6 +541,7 @@
|
||||
"content",
|
||||
);
|
||||
$: description = patch.revisions[0].description;
|
||||
$: lastEdit = patch.revisions[0].edits.at(-1);
|
||||
$: newDescription = description;
|
||||
$: patchReviews = computeReviews(patch);
|
||||
$: selectedItem = patch.state.status === "open" ? items[1] : items[0];
|
||||
@@ -677,6 +677,10 @@
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.author-metadata {
|
||||
color: var(--color-fill-gray);
|
||||
font-size: var(--font-size-small);
|
||||
}
|
||||
.review {
|
||||
color: var(--color-fill-gray);
|
||||
display: inline-flex;
|
||||
@@ -764,11 +768,11 @@
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="description">
|
||||
<div class="revision-description">
|
||||
{#if session && patchState !== "read" && latestEdit}
|
||||
{#if session && patchState !== "read" && lastEdit}
|
||||
<ExtendedTextarea
|
||||
isValid={() => patch.title.length > 0}
|
||||
enableAttachments
|
||||
embeds={parseEmbedIntoMap(latestEdit.embeds)}
|
||||
embeds={parseEmbedIntoMap(lastEdit.embeds)}
|
||||
rawPath={rawPath(patch.revisions[0].id)}
|
||||
body={newDescription}
|
||||
submitCaption="Save"
|
||||
@@ -836,6 +840,17 @@
|
||||
<span title={utils.absoluteTimestamp(patch.revisions[0].timestamp)}>
|
||||
{utils.formatTimestamp(patch.revisions[0].timestamp)}
|
||||
</span>
|
||||
{#if lastEdit}
|
||||
<div class="author-metadata">•</div>
|
||||
<div
|
||||
class="author-metadata"
|
||||
title={utils.formatEditedCaption(
|
||||
lastEdit.author,
|
||||
lastEdit.timestamp,
|
||||
)}>
|
||||
edited
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</CobHeader>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user