add recalling of last project when navigating out from and into quest log.

This commit is contained in:
2021-02-07 12:35:55 +01:00
parent 4c8669a029
commit d3f17f867f
6 changed files with 35 additions and 18 deletions
+18 -1
View File
@@ -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) {
project = expiringProjects[0] || activeProjects[0] || completedProjects[0] || null;
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">