mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-16 03:40:37 +08:00
Refactor usage of authorSchema
This commit is contained in:
@@ -9,6 +9,7 @@ import type {
|
||||
TreeStats,
|
||||
} from "./lib/project.js";
|
||||
import type {
|
||||
Author,
|
||||
Config,
|
||||
SeedingPolicy,
|
||||
DefaultSeedingPolicy,
|
||||
@@ -50,6 +51,7 @@ import {
|
||||
} from "./lib/shared.js";
|
||||
|
||||
export type {
|
||||
Author,
|
||||
BaseUrl,
|
||||
Blob,
|
||||
ChangesetWithDiff,
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
} from "./project/commit.js";
|
||||
import { issueSchema, issuesSchema } from "./project/issue.js";
|
||||
import { patchSchema, patchesSchema } from "./project/patch.js";
|
||||
import { authorSchema } from "./shared.js";
|
||||
|
||||
const repoSchema = object({
|
||||
rid: string(),
|
||||
@@ -34,7 +35,7 @@ const repoSchema = object({
|
||||
description: string(),
|
||||
defaultBranch: string(),
|
||||
}),
|
||||
delegates: array(object({ id: string(), alias: optional(string()) })),
|
||||
delegates: array(authorSchema),
|
||||
head: string(),
|
||||
threshold: number(),
|
||||
visibility: union([
|
||||
|
||||
@@ -117,6 +117,8 @@ export const codeLocationSchema = object({
|
||||
new: rangeSchema.nullable(),
|
||||
});
|
||||
|
||||
export type Author = z.infer<typeof authorSchema>;
|
||||
|
||||
export const authorSchema = object({
|
||||
id: string(),
|
||||
alias: string().optional(),
|
||||
|
||||
+2
-5
@@ -1,4 +1,4 @@
|
||||
import type { BaseUrl } from "@http-client";
|
||||
import type { Author, BaseUrl } from "@http-client";
|
||||
|
||||
import md5 from "md5";
|
||||
import bs58 from "bs58";
|
||||
@@ -80,10 +80,7 @@ export function formatCommit(oid: string): string {
|
||||
return oid.substring(0, 7);
|
||||
}
|
||||
|
||||
export function formatEditedCaption(
|
||||
author: { id: string; alias?: string },
|
||||
timestamp: number,
|
||||
) {
|
||||
export function formatEditedCaption(author: Author, timestamp: number) {
|
||||
return `${
|
||||
author.alias ? author.alias : formatNodeId(author.id)
|
||||
} edited ${absoluteTimestamp(timestamp)}`;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import type {
|
||||
Author,
|
||||
BaseUrl,
|
||||
Comment,
|
||||
DiffResponse,
|
||||
@@ -44,7 +45,7 @@
|
||||
export let revisionOid: string;
|
||||
export let revisionTimestamp: number;
|
||||
export let revisionReactions: Comment["reactions"];
|
||||
export let revisionAuthor: { id: string; alias?: string | undefined };
|
||||
export let revisionAuthor: Author;
|
||||
export let revisionDescription: string;
|
||||
export let timelines: Timeline[];
|
||||
export let previousRevBase: string | undefined = undefined;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts" context="module">
|
||||
import type {
|
||||
Author,
|
||||
Comment,
|
||||
Review,
|
||||
Merge,
|
||||
@@ -168,7 +169,7 @@
|
||||
revisionOid: string;
|
||||
revisionEdits: Revision["edits"];
|
||||
revisionReactions: Revision["reactions"];
|
||||
revisionAuthor: { id: string; alias?: string | undefined };
|
||||
revisionAuthor: Author;
|
||||
revisionDescription: string;
|
||||
},
|
||||
Timeline[],
|
||||
|
||||
Reference in New Issue
Block a user