Stop handling URL hash through routing

We stop handling the URL hash through the routing system. Hashes are
local to the current view and can be handled by the shown components.

Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>
This commit is contained in:
Thomas Scholtes
2023-07-10 15:15:22 +02:00
parent 74fa05cf26
commit a7f267932d
7 changed files with 6 additions and 21 deletions
-1
View File
@@ -55,7 +55,6 @@
id: project.id,
peer: undefined,
baseUrl,
hash: undefined,
},
});
} else {
+4 -3
View File
@@ -11,7 +11,6 @@
import { Renderer } from "@app/lib/markdown";
export let content: string;
export let hash: string | undefined = undefined;
// If present, resolve all relative links with respect to this URL
export let linkBaseUrl: string | undefined = undefined;
export let path: string = "/";
@@ -69,8 +68,6 @@
}
}
if (hash) scrollIntoView(hash);
// Iterate over all images, and replace the source with a canonicalized URL
// pointing at the projects /raw endpoint.
if (rawPath) {
@@ -112,6 +109,10 @@
}
await Promise.allSettled(treeChanges);
if (window.location.hash) {
scrollIntoView(window.location.hash.substring(1));
}
});
</script>
+1 -3
View File
@@ -16,7 +16,6 @@
export let peer: string | undefined;
export let revision: string | undefined;
export let path: string;
export let hash: string | undefined = undefined;
export let blob: Blob;
export let highlighted: Syntax.Root | undefined;
export let rawPath: string;
@@ -267,8 +266,7 @@
{revision}
content={blob.content}
{rawPath}
{path}
{hash} />
{path} />
{:else if content}
<table class="code no-scrollbar">
{@html toHtml(content)}
-2
View File
@@ -18,7 +18,6 @@
export let commit: string;
export let commitCount: number;
export let contributorCount: number;
export let hash: string | undefined;
export let path: string;
export let peer: string | undefined;
export let peers: Remote[];
@@ -181,7 +180,6 @@
{peer}
{revision}
{path}
{hash}
blob={blobResult.blob}
highlighted={blobResult.highlighted}
rawPath={utils.getRawBasePath(project.id, baseUrl, commit)} />
+1 -2
View File
@@ -9,7 +9,6 @@
export let baseUrl: BaseUrl;
export let revision: string | undefined;
export let content: string;
export let hash: string | undefined = undefined;
export let path: string;
export let rawPath: string;
@@ -53,5 +52,5 @@
</style>
<article>
<Markdown {linkBaseUrl} {content} {hash} {rawPath} {path} />
<Markdown {linkBaseUrl} {content} {rawPath} {path} />
</article>
-2
View File
@@ -20,7 +20,6 @@
export let project: Project;
export let view: ProjectLoadedView;
export let hash: string | undefined = undefined;
export let peer: string | undefined = undefined;
export let revision: string | undefined = undefined;
</script>
@@ -69,7 +68,6 @@
peers={view.params.loadedPeers}
tree={view.params.loadedTree}
{baseUrl}
{hash}
{peer}
{project}
{revision}
-8
View File
@@ -55,7 +55,6 @@ export interface ProjectsParams {
params: { patch: string; revision?: string; search?: string };
};
hash?: string;
path?: string;
peer?: string;
revision?: string;
@@ -68,7 +67,6 @@ export interface ProjectLoadedParams {
project: Project;
view: ProjectLoadedView;
hash?: string;
peer?: string;
revision?: string;
}
@@ -474,7 +472,6 @@ export function resolveProjectRoute(
}
if (!content || content === "tree") {
const hash = url.href.match(/#{1}[^#.]+$/)?.pop();
return {
view: { resource: "tree" },
baseUrl,
@@ -482,7 +479,6 @@ export function resolveProjectRoute(
peer,
path: undefined,
revision: undefined,
hash: hash?.substring(1),
route: segments.join("/"),
};
} else if (content === "history") {
@@ -607,10 +603,6 @@ export function projectRouteToPath(params: ProjectsParams): string {
}
}
if (params.hash) {
suffix += `#${params.hash}`;
}
if (params.view.resource === "tree") {
if (suffix) {
return `${seed}/${params.id}${peer}/tree${suffix}`;