2022-10-02 21:16:17 +02:00
|
|
|
|
|
|
|
export const state = () => ({
|
2023-04-02 23:13:18 +02:00
|
|
|
tasks: [],
|
|
|
|
queuedEmbedLIds: []
|
2022-10-02 21:16:17 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
export const getters = {
|
2023-04-02 23:13:18 +02:00
|
|
|
getTasksByLibraryItemId: (state) => (libraryItemId) => {
|
|
|
|
return state.tasks.filter(t => t.data && t.data.libraryItemId === libraryItemId)
|
2022-10-02 21:16:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const actions = {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export const mutations = {
|
|
|
|
setTasks(state, tasks) {
|
|
|
|
state.tasks = tasks
|
|
|
|
},
|
|
|
|
addUpdateTask(state, task) {
|
2023-04-02 23:13:18 +02:00
|
|
|
const index = state.tasks.findIndex(d => d.id === task.id)
|
2022-10-02 21:16:17 +02:00
|
|
|
if (index >= 0) {
|
|
|
|
state.tasks.splice(index, 1, task)
|
|
|
|
} else {
|
2023-04-02 23:13:18 +02:00
|
|
|
// Remove duplicate (only have one library item per action)
|
|
|
|
state.tasks = state.tasks.filter(_task => {
|
|
|
|
if (!_task.data?.libraryItemId || _task.action !== task.action) return true
|
|
|
|
return _task.data.libraryItemId !== task.data.libraryItemId
|
|
|
|
})
|
|
|
|
|
2022-10-02 21:16:17 +02:00
|
|
|
state.tasks.push(task)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
removeTask(state, task) {
|
|
|
|
state.tasks = state.tasks.filter(d => d.id !== task.id)
|
2023-04-02 23:13:18 +02:00
|
|
|
},
|
|
|
|
setQueuedEmbedLIds(state, libraryItemIds) {
|
|
|
|
state.queuedEmbedLIds = libraryItemIds
|
|
|
|
},
|
|
|
|
addQueuedEmbedLId(state, libraryItemId) {
|
|
|
|
if (!state.queuedEmbedLIds.some(lid => lid === libraryItemId)) {
|
|
|
|
state.queuedEmbedLIds.push(libraryItemId)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
removeQueuedEmbedLId(state, libraryItemId) {
|
|
|
|
state.queuedEmbedLIds = state.queuedEmbedLIds.filter(lid => lid !== libraryItemId)
|
2022-10-02 21:16:17 +02:00
|
|
|
}
|
|
|
|
}
|