Skip to content

Commit

Permalink
fix: prevent flash of Resume Latest Draft on Revise click
Browse files Browse the repository at this point in the history
  • Loading branch information
kriscooke committed May 26, 2021
1 parent 39f8049 commit b2033ed
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class ViewApplication extends Component<Props> {
}
`;

state = {newerDraftExists: undefined};

render() {
const {session} = this.props.query;
const {query, router} = this.props;
Expand Down Expand Up @@ -104,8 +106,14 @@ class ViewApplication extends Component<Props> {
const latestDraftRevision = application.latestDraftRevision?.versionNumber;

const newerSubmissionExists = latestSubmittedRevision > thisVersion;
const newerDraftExists = latestDraftRevision > latestSubmittedRevision;

if (this.state.newerDraftExists === undefined) {
this.setState((state) => {
return {
...state,
newerDraftExists: latestDraftRevision > latestSubmittedRevision
};;
});
}
const latestSubmissionHref = getViewApplicationPageRoute(
router.query.applicationId.toString(),
latestSubmittedRevision
Expand Down Expand Up @@ -176,12 +184,12 @@ class ViewApplication extends Component<Props> {
>
{changesRequested &&
!newerSubmissionExists &&
!newerDraftExists && (
!this.state.newerDraftExists && (
<ReviseApplicationButton
application={query.application}
/>
)}
{newerDraftExists &&
{this.state.newerDraftExists &&
!newerSubmissionExists &&
resumeLatestDraftButton}
</ApplicationDecision>
Expand Down

0 comments on commit b2033ed

Please sign in to comment.