Skip to content

Commit

Permalink
ispras#971: fix edit_translations for react18
Browse files Browse the repository at this point in the history
  • Loading branch information
nataliauvarova committed Jun 15, 2023
1 parent f58b0b1 commit eeb12d9
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/pages/EditTranslations/EditAtoms.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,11 @@ class EditAtoms extends React.Component {
};
}

createAtom(atom) {
createAtom(atom, gistId) {
return {
mutation: createAtomMutation,
variables: {
parent_id: this.state.gistId,
parent_id: gistId || this.state.gistId,
locale_id: atom.locale_id,
content: atom.content
}
Expand All @@ -246,7 +246,7 @@ class EditAtoms extends React.Component {
}

executeSequence(mutations, newAtoms) {
if (mutations.length == 0) {
if (!mutations.length) {
this.initialState = { atoms: newAtoms };
this.setState({ atoms: newAtoms });
return;
Expand All @@ -267,7 +267,7 @@ class EditAtoms extends React.Component {
});
}

atomActions() {
atomActions(gistId) {
const { atoms } = this.initialState;
const { atoms: newAtoms } = this.state;

Expand All @@ -279,7 +279,7 @@ class EditAtoms extends React.Component {
mutations.push(this.updateAtom(oldItem.id, newAtom));
}
} else {
mutations.push(this.createAtom(newAtom));
mutations.push(this.createAtom(newAtom, gistId));
}
});
atoms.forEach(oldItem => {
Expand All @@ -288,7 +288,7 @@ class EditAtoms extends React.Component {
mutations.push(this.deleteAtom(oldItem));
}
});
if (mutations.length != 0) {
if (mutations.length) {
this.executeSequence(mutations, JSON.parse(JSON.stringify(newAtoms)));
}
}
Expand All @@ -297,15 +297,14 @@ class EditAtoms extends React.Component {
if (this.state.newGist) {
const mutationsGist = [];
mutationsGist.push(this.createTranslationGist());
if (mutationsGist.length != 0) {
if (mutationsGist.length) {
const that = this;
this.props.client.mutate(mutationsGist.shift()).then(result => {
const idGist = result.data.create_translationgist.translationgist.id;

/* idGist for method "createAtom" */
that.setState({ newGist: false, gistId: idGist });

that.atomActions();
that.atomActions(idGist);
});
}
} else {
Expand Down

0 comments on commit eeb12d9

Please sign in to comment.