better uplink behavior
This commit is contained in:
parent
78152c94d6
commit
36d3479f0d
1 changed files with 13 additions and 6 deletions
|
@ -1,11 +1,12 @@
|
|||
<script lang="ts">
|
||||
import { getContext } from "svelte";
|
||||
|
||||
import { Link, useLocation, useParams } from "svelte-navigator";
|
||||
import { useNavigate, useLocation, useParams } from "svelte-navigator";
|
||||
import type { Writable } from "svelte/store";
|
||||
import type { Address, VALUE_TYPE } from "upend/types";
|
||||
const params = useParams();
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
|
||||
export let to: {
|
||||
entity?: Address;
|
||||
|
@ -15,24 +16,30 @@
|
|||
|
||||
const { index } = getContext("browse") as { index: Writable<number> };
|
||||
|
||||
let routerTo = "#";
|
||||
$: {
|
||||
function onClick() {
|
||||
if ($location.pathname.startsWith("/browse") && to.entity) {
|
||||
let addresses = $params.addresses.split(",");
|
||||
|
||||
routerTo =
|
||||
const routerTo =
|
||||
"/browse/" +
|
||||
addresses
|
||||
.slice(0, $index + 1)
|
||||
.concat([to.entity])
|
||||
.join(",");
|
||||
|
||||
navigate(routerTo);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Link class="uplink" to={routerTo}>
|
||||
<a
|
||||
class="uplink"
|
||||
href="/#/browse/{to.entity}"
|
||||
on:click|preventDefault={onClick}
|
||||
>
|
||||
<slot />
|
||||
</Link>
|
||||
</a>
|
||||
|
||||
<style lang="scss">
|
||||
:global(.uplink) {
|
||||
|
|
Loading…
Reference in a new issue