Skip to content

Commit

Permalink
big optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
vmonakhov committed Sep 6, 2024
1 parent eb41359 commit 199a7ac
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/components/PerspectiveView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ class P extends React.Component {
this.state = {
checkedRow: null,
checkedColumn: null,
checkedAll: null
checkedAll: null,
entriesTotal: null
};

this.onCheckRow = this.onCheckRow.bind(this);
Expand All @@ -269,6 +270,16 @@ class P extends React.Component {
//this.reRender = this.reRender.bind(this);
}

componentDidUpdate() {
const { data } = this.props;
if (!data.perspective) {
return;
}
if (this.state.entriesTotal === null) {
this.setState({ entriesTotal: !data.error ? data.perspective.perspective_page.entries_total : 0 });
}
}

//reRender() {
// this.props.data.refetch();
// console.log("Refetched 'queryLexicalEntries'");
Expand Down Expand Up @@ -385,7 +396,7 @@ class P extends React.Component {
}

const lexicalEntries = !error ? data.perspective.perspective_page.lexical_entries : [];
const entriesTotal = !error ? data.perspective.perspective_page.entries_total : 0;
const { entriesTotal } = this.state;

const addEntry = () => {
createLexicalEntry({
Expand All @@ -405,6 +416,7 @@ class P extends React.Component {
create_lexicalentry: { lexicalentry }
} = d;
addCreatedEntry(lexicalentry);
this.setState({entriesTotal: entriesTotal + 1});
}
});
};
Expand All @@ -423,6 +435,7 @@ class P extends React.Component {
]
}).then(() => {
resetSelection();
this.setState({entriesTotal: entriesTotal - selectedEntries.length + 1});
});
};

Expand All @@ -439,6 +452,7 @@ class P extends React.Component {
]
}).then(() => {
resetSelection();
this.setState({entriesTotal: entriesTotal - 1});
});
};

Expand Down

0 comments on commit 199a7ac

Please sign in to comment.