mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 22:30:41 +08:00
Display correct placeholder if blob endpoint returns 413 status code
Also makes sure we don't highlight files that are too big
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
<style>
|
||||
.placeholder {
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
color: var(--color-foreground-dim);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -26,5 +27,8 @@
|
||||
|
||||
<div class="placeholder" class:inline>
|
||||
<Icon name={iconName} size={iconSize} />
|
||||
{caption}
|
||||
{#each caption.split("\n") as line}
|
||||
{line}
|
||||
<br />
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
@@ -195,6 +195,13 @@
|
||||
blob={blobResult.blob}
|
||||
highlighted={blobResult.highlighted}
|
||||
rawPath={rawPath(tree.lastCommit.id)} />
|
||||
{:else if blobResult.error.status === 413}
|
||||
<div class="placeholder">
|
||||
<Placeholder
|
||||
iconName="exclamation-circle"
|
||||
caption="This file is too big to be displayed.
|
||||
If you want to explore this file clone this repository locally." />
|
||||
</div>
|
||||
{:else if path === "/"}
|
||||
<div class="placeholder">
|
||||
<Placeholder iconName="no-file" caption="No README found." />
|
||||
|
||||
@@ -198,7 +198,7 @@ export type ProjectLoadedRoute =
|
||||
|
||||
export type BlobResult =
|
||||
| { ok: true; blob: Blob; highlighted: Syntax.Root | undefined }
|
||||
| { ok: false; error: { message: string; path: string } };
|
||||
| { ok: false; error: { status?: number; message: string; path: string } };
|
||||
|
||||
export type PatchView =
|
||||
| {
|
||||
@@ -477,8 +477,17 @@ async function loadBlob(
|
||||
? await Syntax.highlight(blob.content, blob.path.split(".").pop() ?? "")
|
||||
: undefined,
|
||||
};
|
||||
} catch {
|
||||
if (path === "/") {
|
||||
} catch (e: unknown) {
|
||||
if (e instanceof ResponseError) {
|
||||
return {
|
||||
ok: false,
|
||||
error: {
|
||||
status: e.status,
|
||||
message: "Not able to load file",
|
||||
path,
|
||||
},
|
||||
};
|
||||
} else if (path === "/") {
|
||||
return {
|
||||
ok: false,
|
||||
error: {
|
||||
|
||||
Reference in New Issue
Block a user