Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default defineComponent({
const allModes = ['Tasks', 'Projects'];

const project = ref('');
const projects: ComputedRef<string[]> = computed(() => store.getters.projects);
const projects: ComputedRef<string[]> = computed(() => store.getters.activeProjects);
watch(projects, () => {
if (projects.value.includes(project.value))
return;
Expand Down
11 changes: 10 additions & 1 deletion frontend/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,17 @@ export const state = () => ({

export type RootState = ReturnType<typeof state>;

const projectsFromTasks = (tasks: Task[]) => Array.from(new Set(
tasks
.map(task => task.project)
.filter((project): project is string => project !== undefined)
));

export const getters: GetterTree<RootState, RootState> = {
projects: state => state.tasks.map(task => task.project).filter(p => p !== undefined),
projects: state => projectsFromTasks(state.tasks),
activeProjects: state => projectsFromTasks(
state.tasks.filter(task => task.status !== 'completed' && task.status !== 'deleted')
),
tags: state => state.tasks.reduce((tags: string[], task) => {
return task.tags ? tags.concat(task.tags) : tags;
}, [])
Expand Down