Browse Source

improve remembering of last project to be per-group.

main
Gisle Aune 3 years ago
parent
commit
c074d270e8
  1. 11
      svelte-ui/src/components/ProjectGroupMenu.svelte
  2. 9
      svelte-ui/src/pages/QLPage.svelte

11
svelte-ui/src/components/ProjectGroupMenu.svelte

@ -11,8 +11,6 @@
export let groups: ProjectGroupResult[] = [];
export let selected: string;
let failedCount = 0;
function onClickAdd() {
modalStore.set({name: "projectgroup.add"});
}
@ -21,12 +19,17 @@
if (group.projects.length === 0) {
navigate(`/questlog/${group.id}`);
} else {
const projetcs = [...group.projects].sort(sortProjects);
const preferredId = localStorage.getItem(`sl2.projectgroup.${group.id}.last_project_id`);
const projects = [...group.projects].sort(sortProjects);
const project = projects.find(p => p.id === preferredId) || projects[0];
navigate(`/questlog/${group.id}/${projetcs[0].id}`);
navigate(`/questlog/${group.id}/${project.id}`);
// There's some weirdness with navigate. This hack will just do a
// groups = [...groups] in the sttore to get the page to update.
//
// Edit: It doesn't seem to be needed anymore? Idk why, but I'll keep this in just in case.
tick().then(() => {
projectGroupStore.fakeRefresh();
})

9
svelte-ui/src/pages/QLPage.svelte

@ -25,8 +25,8 @@
}
$: {
const lastGroupId = localStorage.getItem("stufflog3.questlog.last_group_id") || "";
const lastProjectId = localStorage.getItem("stufflog3.questlog.last_project_id") || "";
const lastGroupId = localStorage.getItem("sl2.questlogpage.last_group_id") || "";
const lastProjectId = localStorage.getItem("sl2.questlogpage.last_project_id") || "";
if ($projectGroupStore.groups.length > 0) {
// Try to restore last selection
@ -60,8 +60,9 @@
navigate(`/questlog/${group.id}`);
}
} else {
localStorage.setItem("stufflog3.questlog.last_group_id", groupId);
localStorage.setItem("stufflog3.questlog.last_project_id", projectId);
localStorage.setItem("sl2.questlogpage.last_group_id", groupId);
localStorage.setItem("sl2.questlogpage.last_project_id", projectId);
localStorage.setItem(`sl2.projectgroup.${groupId}.last_project_id`, projectId);
}
}
}

Loading…
Cancel
Save