[ui] uplink now works outside of /browse
parent
ec691b3717
commit
849c697061
|
@ -7,14 +7,14 @@
|
|||
|
||||
<div class="entry">
|
||||
<div class="entity">
|
||||
<UpObject address={entry.entity} />
|
||||
<UpObject link address={entry.entity} />
|
||||
</div>
|
||||
<div class="attribute">
|
||||
{entry.attribute}
|
||||
</div>
|
||||
<div class="value value-{entry.value.t.toLowerCase()}">
|
||||
{#if entry.value.t === "Address"}
|
||||
<UpObject address={String(entry.value.c)} />
|
||||
<UpObject link address={String(entry.value.c)} />
|
||||
{:else}
|
||||
{entry.value.c}
|
||||
{/if}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import { getContext } from "svelte";
|
||||
|
||||
import { useNavigate, useLocation, useParams } from "svelte-navigator";
|
||||
import type { Writable } from "svelte/store";
|
||||
import { readable, Writable } from "svelte/store";
|
||||
import type { Address, VALUE_TYPE } from "upend/types";
|
||||
const params = useParams();
|
||||
const location = useLocation();
|
||||
|
@ -14,21 +14,29 @@
|
|||
value?: { t: VALUE_TYPE; c: string };
|
||||
};
|
||||
|
||||
const { index } = getContext("browse") as { index: Writable<number> };
|
||||
const context = getContext("browse") as
|
||||
| { index: Writable<number> }
|
||||
| undefined;
|
||||
|
||||
const index = Boolean(context) ? context.index : readable(0);
|
||||
|
||||
function onClick() {
|
||||
if ($location.pathname.startsWith("/browse") && to.entity) {
|
||||
let addresses = $params.addresses.split(",");
|
||||
if (to.entity) {
|
||||
if ($location.pathname.startsWith("/browse")) {
|
||||
let addresses = $params.addresses.split(",");
|
||||
|
||||
const routerTo =
|
||||
"/browse/" +
|
||||
addresses
|
||||
.slice(0, $index + 1)
|
||||
.concat([to.entity])
|
||||
.join(",");
|
||||
const routerTo =
|
||||
"/browse/" +
|
||||
addresses
|
||||
.slice(0, $index + 1)
|
||||
.concat([to.entity])
|
||||
.join(",");
|
||||
|
||||
navigate(routerTo);
|
||||
return true;
|
||||
navigate(routerTo);
|
||||
return true;
|
||||
} else {
|
||||
navigate(`/browse/${to.entity}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue