Skip to content

Commit

Permalink
Deduplicate datasets before updating bouquet
Browse files Browse the repository at this point in the history
  • Loading branch information
narduin committed Sep 11, 2024
1 parent 70a305b commit fe21961
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/views/bouquets/BouquetDetailView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,22 @@ const onUpdateDatasets = () => {
throw Error('Trying to update null topic')
}
const loader = useLoading().show()
// Deduplicate datasets ids in case of same DS used multiple times
// API rejects PUT if the same id is used more than once
const dedupedDatasets = [
...new Set(
datasetsProperties.value
.filter((d) => d.id !== null && d.remoteDeleted !== true)
.map((d) => d.id)
)
]
store
.update(topic.value.id, {
// send the tags or payload will be rejected
tags: topic.value.tags,
datasets: datasetsProperties.value
.filter((d) => d.id !== null && d.remoteDeleted !== true)
.map((d) => d.id),
datasets: dedupedDatasets,
extras: updateTopicExtras(topic.value, {
datasets_properties: datasetsProperties.value.map(
({ remoteDeleted, ...data }) => data
Expand Down

0 comments on commit fe21961

Please sign in to comment.