fix(tasks): do not show import hint when using a filter as home tasks and already imported

This fixes a bug where the "import your tasks from other platforms" would be shown even if the user had already imported tasks. The bug was caused by the heuristic "there are tasks" was not evaluated when tasks were loaded through a filter

Resolves https://github.com/go-vikunja/vikunja/issues/372
This commit is contained in:
kolaente 2024-12-11 18:28:29 +01:00
parent c9a68d3a63
commit 6f9b0ddfe7
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
3 changed files with 22 additions and 13 deletions

View File

@ -28,7 +28,7 @@ import {useKanbanStore} from '@/stores/kanban'
import {useBaseStore} from '@/stores/base'
import ProjectUserService from '@/services/projectUsers'
import {useAuthStore} from '@/stores/auth'
import {type TaskFilterParams} from '@/services/taskCollection'
import TaskCollectionService, {type TaskFilterParams} from '@/services/taskCollection'
import {getRandomColorHex} from '@/helpers/color/randomColor'
import {REPEAT_TYPES} from '@/types/IRepeatAfter'
import {TASK_REPEAT_MODES} from '@/types/IRepeatMode'
@ -134,15 +134,16 @@ export const useTaskStore = defineStore('task', () => {
if (!params.filter_timezone || params.filter_timezone === '') {
params.filter_timezone = authStore.settings.timezone
}
if (projectId !== null) {
params.filter = 'project = '+projectId+' && (' + params.filter +')'
}
const cancel = setModuleLoading(setIsLoading)
try {
const taskService = new TaskService()
tasks.value = await taskService.getAll({}, params)
const model = {}
let taskCollectionService = new TaskService()
if (projectId !== null) {
model.projectId = projectId
taskCollectionService = new TaskCollectionService()
}
tasks.value = await taskCollectionService.getAll(model, params)
baseStore.setHasTasks(tasks.value.length > 0)
return tasks.value
} finally {

View File

@ -23,7 +23,7 @@
class="is-max-width-desktop"
@taskAdded="updateTaskKey"
/>
<template v-if="!hasTasks && !loading && migratorsEnabled">
<template v-if="tasksLoaded && !hasTasks && !loading && migratorsEnabled">
<p class="mt-4">
{{ $t('home.project.importText') }}
</p>
@ -49,6 +49,7 @@
v-if="projectStore.hasProjects"
:key="showTasksKey"
class="show-tasks"
@tasksLoaded="tasksLoaded = true"
/>
</div>
</template>
@ -91,6 +92,8 @@ const projectHistory = computed(() => {
.filter(l => Boolean(l))
})
const tasksLoaded = ref(false)
const migratorsEnabled = computed(() => configStore.availableMigrators?.length > 0)
const hasTasks = computed(() => baseStore.hasTasks)
const loading = computed(() => taskStore.isLoading)

View File

@ -98,8 +98,14 @@ const props = withDefaults(defineProps<{
showOverdue: false,
})
const emit = defineEmits<{
'tasksLoaded': true,
}>()
const authStore = useAuthStore()
const taskStore = useTaskStore()
const projectStore = useProjectStore()
const route = useRoute()
const router = useRouter()
const {t} = useI18n({useScope: 'global'})
@ -108,8 +114,6 @@ const tasks = ref<ITask[]>([])
const showNothingToDo = ref<boolean>(false)
const taskCollectionService = ref(new TaskCollectionService())
const projectStore = useProjectStore()
setTimeout(() => showNothingToDo.value = true, 100)
const showAll = computed(() => typeof props.dateFrom === 'undefined' || typeof props.dateTo === 'undefined')
@ -200,13 +204,14 @@ async function loadPendingTasks(from: Date|string, to: Date|string) {
}
}
let projectId = null
const filterId = authStore.settings.frontendSettings.filterIdUsedOnOverview
if (showAll.value && filterId && typeof projectStore.projects[filterId] !== 'undefined') {
tasks.value = await taskCollectionService.value.getAll({projectId: filterId}, params)
return
projectId = filterId
}
tasks.value = await taskStore.loadTasks(params)
tasks.value = await taskStore.loadTasks(params, projectId)
emit('tasksLoaded', true)
}
// FIXME: this modification should happen in the store