Skip to content
Snippets Groups Projects
Commit 1d779beb authored by ml bonhomme's avatar ml bonhomme :bee: Committed by Erwan Rouchet
Browse files

this.datasetElementPagination[datasetId] can be undefined when removing an...

this.datasetElementPagination[datasetId] can be undefined when removing an element from a dataset from the element details
parent 305db5b1
No related branches found
No related tags found
1 merge request!1641this.datasetElementPagination[datasetId] can be undefined when removing an element from a dataset from the element details
......@@ -170,10 +170,13 @@ export const useDatasetStore = defineStore('dataset', {
async removeDatasetElement (datasetId: UUID, elementId: UUID, set: string) {
try {
await deleteDatasetElement(datasetId, elementId, set)
const currentPage = this.datasetElementPagination[datasetId][set]
if (currentPage) {
const index = currentPage.datasetElements.findIndex(datasetElement => datasetElement.element.id === elementId)
if (index >= 0) currentPage.datasetElements.splice(index, 1)
// When the action is called from the element details panel, this.datasetElementPagination[datasetId] can be undefined
if (this.datasetElementPagination[datasetId]) {
const currentPage = this.datasetElementPagination[datasetId][set]
if (currentPage) {
const index = currentPage.datasetElements.findIndex(datasetElement => datasetElement.element.id === elementId)
if (index >= 0) currentPage.datasetElements.splice(index, 1)
}
}
// Update dataset sets count
const setElements = this.datasets[datasetId]?.set_elements
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment