Skip to content

Commit

Permalink
Fixed checkChanges
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Jun 11, 2021
1 parent 84ef2c9 commit e932b94
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
10 changes: 1 addition & 9 deletions ui/src/app/metadata/editor/MetadataEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ import { useTranslator } from '../../i18n/hooks';
import API_BASE_PATH from '../../App.constant';
import { MetadataObjectContext } from '../hoc/MetadataSelector';
import { FilterableProviders } from '../domain/provider';

import { detailedDiff } from 'deep-object-diff';
import { removeNull } from '../../core/utility/remove_null';
import { checkChanges } from '../hooks/utility';

export function MetadataEditor ({ current }) {

Expand All @@ -38,12 +36,6 @@ export function MetadataEditor ({ current }) {
const { state, dispatch } = React.useContext(MetadataFormContext);
const { metadata, errors } = state;

const checkChanges = (original, updates) => {
const diff = detailedDiff(original, removeNull(updates, true));
const hasChanges = Object.keys(diff).some(d => Object.keys(diff[d]).length > 0);
return hasChanges;
};

const onChange = (changes) => {
dispatch(setFormDataAction(changes.formData));
dispatch(setFormErrorAction(changes.errors));
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/metadata/hooks/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { detailedDiff } from "deep-object-diff";
import { removeNull } from "../../core/utility/remove_null";

export const checkChanges = (original, updates) => {
const diff = detailedDiff(original, removeNull(updates, true));
const diff = detailedDiff(removeNull(original, true), removeNull(updates, true));
const hasChanges = Object.keys(diff).some(d => Object.keys(diff[d]).length > 0);
return hasChanges;
}
Expand Down

0 comments on commit e932b94

Please sign in to comment.