vikunja-frontend/src/store/modules/attachments.js
Dominik Pschenitschni db49b9b532
fix: directly set arrays, objects and delete directly
Not needed since vue3 uses proxies
2021-10-01 18:45:42 +02:00

23 lines
No EOL
563 B
JavaScript

import {findIndexById} from '@/helpers/find'
export default {
namespaced: true,
state: () => ({
attachments: [],
}),
mutations: {
set(state, attachments) {
console.debug('Set attachments', attachments)
state.attachments = attachments
},
add(state, attachment) {
console.debug('Add attachement', attachment)
state.attachments.push(attachment)
},
removeById(state, id) {
const attachmentIndex = findIndexById(state.attachments, id)
state.attachments.splice(attachmentIndex, 1)
console.debug('Remove attachement', id)
},
},
}