@@ -22,7 +22,6 @@ import smpActions from '../../actions/page/submission_management';
22
22
23
23
const { getService } = services . submissions ;
24
24
25
- const TIME_DELAY = 750 ;
26
25
const theme = {
27
26
container : style . modalContainer ,
28
27
} ;
@@ -34,6 +33,8 @@ class SubmissionManagementPageContainer extends React.Component {
34
33
35
34
this . state = {
36
35
needReload : false ,
36
+ initialState : true ,
37
+ submissions : [ ] ,
37
38
} ;
38
39
}
39
40
@@ -76,13 +77,30 @@ class SubmissionManagementPageContainer extends React.Component {
76
77
77
78
componentDidUpdate ( prevProps ) {
78
79
const {
79
- loadMySubmissions, authTokens, deletionSucceed, challengeId,
80
+ deletionSucceed,
81
+ toBeDeletedId,
82
+ mySubmissions,
80
83
} = this . props ;
84
+ const { initialState } = this . state ;
85
+
86
+ if ( initialState && mySubmissions ) {
87
+ // eslint-disable-next-line react/no-did-update-set-state
88
+ this . setState ( {
89
+ submissions : [ ...mySubmissions ] ,
90
+ initialState : false ,
91
+ } ) ;
92
+ return ;
93
+ }
94
+ const { submissions } = this . state ;
81
95
82
96
if ( deletionSucceed !== prevProps . deletionSucceed ) {
83
- setTimeout ( ( ) => {
84
- loadMySubmissions ( authTokens , challengeId ) ;
85
- } , TIME_DELAY ) ;
97
+ _ . remove ( submissions , submission => (
98
+ submission . id === toBeDeletedId
99
+ ) ) ;
100
+ // eslint-disable-next-line react/no-did-update-set-state
101
+ this . setState ( {
102
+ submissions,
103
+ } ) ;
86
104
}
87
105
}
88
106
@@ -96,7 +114,6 @@ class SubmissionManagementPageContainer extends React.Component {
96
114
loadingSubmissionsForChallengeId,
97
115
submissionPhaseStartDate,
98
116
isLoadingChallenge,
99
- mySubmissions,
100
117
onCancelSubmissionDelete,
101
118
onShowDetails,
102
119
onSubmissionDelete,
@@ -105,6 +122,9 @@ class SubmissionManagementPageContainer extends React.Component {
105
122
showModal,
106
123
toBeDeletedId,
107
124
} = this . props ;
125
+
126
+ const { submissions } = this . state ;
127
+
108
128
if ( ! challenge . isRegistered ) return < AccessDenied redirectLink = { `${ challengesUrl } /${ challenge . id } ` } cause = { ACCESS_DENIED_REASON . HAVE_NOT_SUBMITTED_TO_THE_CHALLENGE } /> ;
109
129
110
130
const isEmpty = _ . isEmpty ( challenge ) ;
@@ -139,7 +159,7 @@ class SubmissionManagementPageContainer extends React.Component {
139
159
challenge = { challenge }
140
160
challengesUrl = { challengesUrl }
141
161
loadingSubmissions = { Boolean ( loadingSubmissionsForChallengeId ) }
142
- submissions = { mySubmissions }
162
+ submissions = { submissions }
143
163
showDetails = { showDetails }
144
164
submissionPhaseStartDate = { submissionPhaseStartDate }
145
165
{ ...smConfig }
0 commit comments