Make project head optional

This is useful since some seeds may not have delegates synced.

Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
Alexis Sellier
2022-03-02 14:41:04 +01:00
parent cfc5f4a095
commit 0a830432f7
6 changed files with 25 additions and 23 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import type { Readable } from 'svelte/store';
import * as proj from '@app/project';
import type * as proj from '@app/project';
import Loading from '@app/Loading.svelte';
import Placeholder from '@app/Placeholder.svelte';
import * as utils from '@app/utils';
@@ -21,10 +21,11 @@
export let project: proj.Project;
export let tree: proj.Tree;
export let browserStore: Readable<proj.Browser>;
export let commit: string;
$: browser = $browserStore;
$: path = browser.path || "/";
$: revision = browser.revision || project.branches[project.head];
$: revision = browser.revision;
// When the component is loaded the first time, the blob is yet to be loaded.
let state: State = { status: Status.Loading, path };
@@ -70,7 +71,6 @@
mobileFileTree = !mobileFileTree;
};
$: commit = proj.getOid(revision, project.branches) || project.head;
$: getBlob = loadBlob(path);
$: loadingPath = state.status == Status.Loading ? state.path : null;
</script>
+1 -1
View File
@@ -141,7 +141,7 @@
<Header {tree} {commit} {browserStore} {project} peerSelector={! project.profile} />
{#if content == proj.ProjectContent.Tree}
<Browser {project} {tree} {browserStore} />
<Browser {project} {commit} {tree} {browserStore} />
{:else if content == proj.ProjectContent.History}
<History {project} {commit} />
{:else if content == proj.ProjectContent.Commit}
+2 -2
View File
@@ -93,7 +93,7 @@
{#if project.head}
{project.head}
{:else}
<span class="subtle">Could not retrieve HEAD</span>
<span class="subtle">✗ No head</span>
{/if}
</slot>
</span>
@@ -104,7 +104,7 @@
</span>
<span class="anchor-badge">
<slot name="anchor">
{#if anchor}
{#if anchor && project.head}
<AnchorBadge
commit={project.head}
head={project.head} noText noBg