fixed incorrect array being used in comparison

Use `symmetricDifference` instead of `difference`.
- `difference` only returns values that are present in the edited attributes, but not in the originally fetched attribute vales. This always ends up returning an empty array.
- I used `symmetricDifference` as it returns an intersection of `difference` from both sides and works perfectly for this use case, as the original attributes never change.
This commit is contained in:
Safwan Parkar
2023-08-08 23:44:51 +04:00
parent a8ec722089
commit da004545d2
@@ -13,7 +13,7 @@
import { collection, type Attributes } from '../../store';
import { Container } from '$lib/layout';
import AttributeItem from '../attributeItem.svelte';
import { difference, symmetricDifference } from '$lib/helpers/array';
import { symmetricDifference } from '$lib/helpers/array';
import { isRelationship, isRelationshipToMany } from '../attributes/store';
const databaseId = $page.params.database;
@@ -77,7 +77,7 @@
const docAttribute = $doc?.[attribute.key];
if (attribute.array) {
return !difference(Array.from(workAttribute), Array.from(docAttribute)).length;
return !symmetricDifference(Array.from(workAttribute), Array.from(docAttribute)).length;
}
if (isRelationship(attribute)) {