mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-15 11:20:36 +08:00
Use dedicated commitId parameter for commits route
We use the new parameter instead of the shared revision parameter. Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>
This commit is contained in:
+1
-2
@@ -253,7 +253,6 @@ export function routeToPath(route: Route): string {
|
||||
} else {
|
||||
if (
|
||||
(route.params.view.resource === "tree" ||
|
||||
route.params.view.resource === "commits" ||
|
||||
route.params.view.resource === "history") &&
|
||||
route.params.revision
|
||||
) {
|
||||
@@ -274,7 +273,7 @@ export function routeToPath(route: Route): string {
|
||||
}
|
||||
return `${seed}/${route.params.id}${peer}`;
|
||||
} else if (route.params.view.resource === "commits") {
|
||||
return `${seed}/${route.params.id}${peer}/commits${suffix}`;
|
||||
return `${seed}/${route.params.id}${peer}/commits/${route.params.view.commitId}`;
|
||||
} else if (route.params.view.resource === "history") {
|
||||
return `${seed}/${route.params.id}${peer}/history${suffix}`;
|
||||
} else if (
|
||||
|
||||
@@ -302,8 +302,7 @@
|
||||
<Avatar inline nodeId={authorId} />
|
||||
<ProjectLink
|
||||
projectParams={{
|
||||
view: { resource: "commits" },
|
||||
revision: commit.id,
|
||||
view: { resource: "commits", commitId: commit.id },
|
||||
}}>
|
||||
<div class="commit-summary" use:twemoji>
|
||||
<InlineMarkdown
|
||||
|
||||
@@ -96,8 +96,7 @@
|
||||
<div class="message">
|
||||
<ProjectLink
|
||||
projectParams={{
|
||||
view: { resource: "commits" },
|
||||
revision: commit.id,
|
||||
view: { resource: "commits", commitId: commit.id },
|
||||
}}>
|
||||
<div class="summary" use:twemoji>
|
||||
<InlineMarkdown content={commit.summary} />
|
||||
|
||||
@@ -35,7 +35,7 @@ export interface ProjectsParams {
|
||||
id: string;
|
||||
view:
|
||||
| { resource: "tree" }
|
||||
| { resource: "commits" }
|
||||
| { resource: "commits"; commitId: string }
|
||||
| { resource: "history" }
|
||||
| { resource: "issue"; params: { issue: string } }
|
||||
| {
|
||||
@@ -96,6 +96,8 @@ export type ProjectLoadedView =
|
||||
| {
|
||||
resource: "commits";
|
||||
params: LoadedSourceBrowsingParams;
|
||||
// FIXME: We need the ID so that `updateProjectRoute()` type checks.
|
||||
commitId: string;
|
||||
commit: Commit;
|
||||
}
|
||||
| {
|
||||
@@ -170,11 +172,7 @@ export async function loadProjectRoute(
|
||||
): Promise<ProjectLoadedRoute | LoadError> {
|
||||
const api = new HttpdClient(params.baseUrl);
|
||||
try {
|
||||
if (
|
||||
params.view.resource === "tree" ||
|
||||
params.view.resource === "history" ||
|
||||
params.view.resource === "commits"
|
||||
) {
|
||||
if (params.view.resource === "tree" || params.view.resource === "history") {
|
||||
const projectPromise = api.project.getById(params.id);
|
||||
const peersPromise = api.project.getAllRemotes(params.id);
|
||||
const branchesPromise = (async () => {
|
||||
@@ -298,27 +296,64 @@ export async function loadProjectRoute(
|
||||
},
|
||||
},
|
||||
};
|
||||
} else if (params.view.resource === "commits") {
|
||||
const loadedCommit = await api.project.getCommitBySha(
|
||||
params.id,
|
||||
commit,
|
||||
);
|
||||
|
||||
return {
|
||||
resource: "projects",
|
||||
params: {
|
||||
...params,
|
||||
project,
|
||||
view: {
|
||||
resource: params.view.resource,
|
||||
params: viewParams,
|
||||
commit: loadedCommit,
|
||||
},
|
||||
},
|
||||
};
|
||||
} else {
|
||||
return params.view;
|
||||
}
|
||||
} else if (params.view.resource === "commits") {
|
||||
const projectPromise = api.project.getById(params.id);
|
||||
const peersPromise = api.project.getAllRemotes(params.id);
|
||||
const branchesPromise = (async () => {
|
||||
if (params.peer) {
|
||||
try {
|
||||
return (await api.project.getRemoteByPeer(params.id, params.peer))
|
||||
.heads;
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
const [project, peers, maybeBranches] = await Promise.all([
|
||||
projectPromise,
|
||||
peersPromise,
|
||||
branchesPromise,
|
||||
]);
|
||||
|
||||
let branches: Record<string, string>;
|
||||
if (maybeBranches) {
|
||||
branches = maybeBranches;
|
||||
} else {
|
||||
branches = project.head
|
||||
? { [project.defaultBranch]: project.head }
|
||||
: {};
|
||||
}
|
||||
|
||||
const tree = await api.project.getTree(params.id, params.view.commitId);
|
||||
const viewParams = {
|
||||
loadedBranches: branches,
|
||||
loadedPeers: peers,
|
||||
loadedTree: tree,
|
||||
selectedCommit: params.view.commitId,
|
||||
};
|
||||
const loadedCommit = await api.project.getCommitBySha(
|
||||
params.id,
|
||||
params.view.commitId,
|
||||
);
|
||||
|
||||
return {
|
||||
resource: "projects",
|
||||
params: {
|
||||
...params,
|
||||
revision: params.view.commitId,
|
||||
project,
|
||||
view: {
|
||||
resource: params.view.resource,
|
||||
params: viewParams,
|
||||
commitId: params.view.commitId,
|
||||
commit: loadedCommit,
|
||||
},
|
||||
},
|
||||
};
|
||||
} else if (params.view.resource === "issue") {
|
||||
try {
|
||||
const projectPromise = api.project.getById(params.id);
|
||||
@@ -546,13 +581,13 @@ export function resolveProjectRoute(
|
||||
};
|
||||
} else if (content === "commits") {
|
||||
return {
|
||||
view: { resource: "commits" },
|
||||
view: { resource: "commits", commitId: segments[0] },
|
||||
baseUrl,
|
||||
id,
|
||||
peer,
|
||||
path: undefined,
|
||||
revision: undefined,
|
||||
route: segments.join("/"),
|
||||
route: undefined,
|
||||
};
|
||||
} else if (content === "issues") {
|
||||
const issueOrAction = segments.shift();
|
||||
|
||||
Reference in New Issue
Block a user