add recalling of last project when navigating out from and into quest log.
This commit is contained in:
@@ -2,14 +2,6 @@
|
||||
import { link } from "svelte-routing";
|
||||
import selectionStore from "../stores/selection";
|
||||
|
||||
export let location: string = window.location.pathname.split("?")[0];
|
||||
|
||||
function updateLocation() {
|
||||
setTimeout(() => {
|
||||
location = window.location.pathname.split("?")[0];
|
||||
}, 0);
|
||||
}
|
||||
|
||||
$: selected = {
|
||||
home: $selectionStore.path === "/",
|
||||
goals: $selectionStore.path.startsWith("/goals"),
|
||||
@@ -21,12 +13,12 @@
|
||||
</script>
|
||||
|
||||
<nav>
|
||||
<a on:click={updateLocation} class:selected={selected.home} use:link href="/">Stufflog</a>
|
||||
<a on:click={updateLocation} class:selected={selected.goals} use:link href="/goals">Goals</a>
|
||||
<a class="desktop" on:click={updateLocation} class:selected={selected.questlog} use:link href="/questlog">Projects</a>
|
||||
<a class="mobile" on:click={updateLocation} class:selected={selected.projects} use:link href="/projects">Projects</a>
|
||||
<a on:click={updateLocation} class:selected={selected.items} use:link href="/items">Items</a>
|
||||
<a on:click={updateLocation} class:selected={selected.logs} use:link href="/logs">Logs</a>
|
||||
<a class:selected={selected.home} use:link href="/">Stufflog</a>
|
||||
<a class:selected={selected.goals} use:link href="/goals">Goals</a>
|
||||
<a class="desktop" class:selected={selected.questlog} use:link href="/questlog">Projects</a>
|
||||
<a class="mobile" class:selected={selected.projects} use:link href="/projects">Projects</a>
|
||||
<a class:selected={selected.items} use:link href="/items">Items</a>
|
||||
<a class:selected={selected.logs} use:link href="/logs">Logs</a>
|
||||
</nav>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -35,6 +35,7 @@ import TimeProgress from "./TimeProgress.svelte";
|
||||
export let hideIcon: boolean = false;
|
||||
export let showTimeProgress: boolean = false;
|
||||
export let annotations: IconName[] = [];
|
||||
export let removeHook: boolean = false;
|
||||
|
||||
let iconName: IconName;
|
||||
|
||||
@@ -50,7 +51,9 @@ import TimeProgress from "./TimeProgress.svelte";
|
||||
</script>
|
||||
|
||||
<div class="parent-entry" class:full={full}>
|
||||
{#if !removeHook}
|
||||
<LinkHook id={entry.id} />
|
||||
{/if}
|
||||
{#if !hideIcon}
|
||||
<div class="icon" class:completed={entry.active === false}>
|
||||
{#if entry.active != null}
|
||||
|
||||
@@ -16,6 +16,7 @@ import IS_MOBILE from "../utils/phone-check";
|
||||
export let linkProject: boolean = false;
|
||||
export let hideIcon: boolean = false;
|
||||
export let isFake: boolean = false;
|
||||
export let removeHook: boolean = false;
|
||||
|
||||
let mdAddTask: ModalData;
|
||||
let mdProjectEdit: ModalData;
|
||||
@@ -56,6 +57,7 @@ import IS_MOBILE from "../utils/phone-check";
|
||||
hideProgress={hideProgress}
|
||||
hideIcon={hideIcon}
|
||||
showTimeProgress={!hideProgress}
|
||||
removeHook={removeHook}
|
||||
annotations={isFake ? ["list"] : []}
|
||||
>
|
||||
{#if showAllOptions}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
let completed: boolean;
|
||||
|
||||
function handleClick() {
|
||||
window.location.hash = "#" + project.id;
|
||||
selectionStore.change("hash", project.id);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
<script lang="ts" context="module">
|
||||
let lastQuest = "";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import type { ProjectResult } from "../models/project";
|
||||
import selectionStore from "../stores/selection";
|
||||
@@ -26,12 +30,25 @@
|
||||
|
||||
$: {
|
||||
if (project === null && projects.length > 0) {
|
||||
if (lastQuest !== "") {
|
||||
project = projects.find(p => p.id === lastQuest) || null;
|
||||
}
|
||||
|
||||
if (project === null) {
|
||||
project = expiringProjects[0] || activeProjects[0] || completedProjects[0] || null;
|
||||
}
|
||||
|
||||
if (project !== null) {
|
||||
selectionStore.change("hash", project.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$: {
|
||||
if ($selectionStore.hash.startsWith("P")) {
|
||||
lastQuest = $selectionStore.hash;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="quest-log">
|
||||
|
||||
@@ -22,6 +22,10 @@ function createSelectionStore() {
|
||||
},
|
||||
|
||||
change(key: keyof(SelectionData), value: string) {
|
||||
if (key === "hash") {
|
||||
window.location.hash = "#" + value;
|
||||
}
|
||||
|
||||
update(d => ({...d, [key]: value}));
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user