You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.4 KiB

  1. <script lang="ts">
  2. import { tick } from "svelte";
  3. import { navigate } from "svelte-routing";
  4. import QuestLog from "../components/QuestLog.svelte";
  5. import RefreshSelection from "../components/RefreshSelection.svelte";
  6. import projectGroupStore from "../stores/projectGroup";
  7. import { sortProjects } from "../utils/sorters";
  8. export let groupId = "";
  9. export let projectId = "";
  10. $: {
  11. if ($projectGroupStore.stale && !$projectGroupStore.loading) {
  12. projectGroupStore.load();
  13. }
  14. }
  15. $: {
  16. if ($projectGroupStore.groups.length > 0 && groupId === "") {
  17. const group = $projectGroupStore.groups[0];
  18. if (group.projects.length > 0) {
  19. const projects = [...group.projects].sort(sortProjects);
  20. navigate(`/questlog/${group.id}/${projects[0].id}`, {replace: true});
  21. // There's some weirdness with navigate. This hack will just do a
  22. // groups = [...groups] in the sttore to get the page to update.
  23. tick().then(() => {
  24. projectGroupStore.fakeRefresh();
  25. })
  26. } else {
  27. navigate(`/questlog/${group.id}`);
  28. }
  29. }
  30. }
  31. </script>
  32. <div class="page">
  33. <QuestLog groups={$projectGroupStore.groups} groupId={groupId} projectId={projectId} />
  34. </div>
  35. <RefreshSelection />
  36. <style>
  37. div.page {
  38. display: block;
  39. margin: auto;
  40. max-width: 100%;
  41. width: 1020px;
  42. margin-top: 0;
  43. box-sizing: border-box;
  44. }
  45. </style>