diff --git a/client/src/components/portfolio/ProjectEntry.vue b/client/src/components/portfolio/ProjectEntry.vue index 0aa439fc..68cf2884 100644 --- a/client/src/components/portfolio/ProjectEntry.vue +++ b/client/src/components/portfolio/ProjectEntry.vue @@ -54,6 +54,16 @@ import {dateFilter, dateTimeFilter} from '@/filters/date-filter'; const DocumentBlock = () => import(/* webpackChunkName: "content-components" */'@/components/content-blocks/DocumentBlock'); + const insertAtIndexImmutably = (arr, el, idx) => { + + }; + const removeAtIndexImmutably = (arr, idx) => { + return [ + ...arr.slice(0, idx), + ...arr.slice(idx + 1) , + ]; + }; + export default { props: ['description', 'documentUrl', 'created', 'id', 'readOnly'], components: { @@ -89,9 +99,16 @@ const variables = { slug: projectEntry.$route.params.slug, }; - const data = store.readQuery({query, variables}); - if (data) { - data.project.entries.splice(data.project.entries.findIndex(entry => entry.id === projectEntry.id), 1); + const {project} = store.readQuery({query, variables}); + if (project) { + const index = project.entries.findIndex(entry => entry.id === projectEntry.id); + const entries = removeAtIndexImmutably(project.entries, index); + const data = { + project: { + ...project, + entries + } + }; store.writeQuery({query, variables, data}); } }