Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Display correct placeholder if blob endpoint returns 413 status code
Sebastian Martinez committed 1 year ago
commit 8c069387755298e634a8569dec6abafe3aa2e754
parent 83041c3e525e8419b474f353ff70030baa2cd281
3 files changed +24 -4
modified src/components/Placeholder.svelte
@@ -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>
modified src/views/projects/Source.svelte
@@ -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." />
modified src/views/projects/router.ts
@@ -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: {