@@ -216,17 +216,19 @@ function initBranchSelector() {
216216 } ) ;
217217}
218218
219- function updateIssuesMeta ( url , action , issueIds , elementId , afterSuccess ) {
220- $ . ajax ( {
221- type : "POST" ,
222- url : url ,
223- data : {
224- "_csrf" : csrf ,
225- "action" : action ,
226- "issue_ids" : issueIds ,
227- "id" : elementId
228- } ,
229- success : afterSuccess
219+ function updateIssuesMeta ( url , action , issueIds , elementId ) {
220+ return new Promise ( function ( resolve ) {
221+ $ . ajax ( {
222+ type : "POST" ,
223+ url : url ,
224+ data : {
225+ "_csrf" : csrf ,
226+ "action" : action ,
227+ "issue_ids" : issueIds ,
228+ "id" : elementId
229+ } ,
230+ success : resolve ,
231+ } )
230232 } )
231233}
232234
@@ -348,6 +350,10 @@ function uploadFile(file, callback) {
348350 xhr . send ( formData ) ;
349351}
350352
353+ function reload ( ) {
354+ window . location . reload ( ) ;
355+ }
356+
351357function initImagePaste ( target ) {
352358 target . each ( function ( i , field ) {
353359 field . addEventListener ( 'paste' , function ( event ) {
@@ -385,18 +391,20 @@ function initCommentForm() {
385391 $ ( '.' + selector ) . dropdown ( 'setting' , 'onHide' , function ( ) {
386392 hasLabelUpdateAction = $listMenu . data ( 'action' ) == 'update' ; // Update the var
387393 if ( hasLabelUpdateAction ) {
394+ var promises = [ ] ;
388395 for ( var elementId in labels ) {
389396 if ( labels . hasOwnProperty ( elementId ) ) {
390397 var label = labels [ elementId ] ;
391- updateIssuesMeta (
398+ var promise = updateIssuesMeta (
392399 label [ "update-url" ] ,
393400 label [ "action" ] ,
394401 label [ "issue-id" ] ,
395402 elementId
396403 ) ;
404+ promises . push ( promise ) ;
397405 }
398406 }
399- location . reload ( ) ;
407+ Promise . all ( promises ) . then ( reload ) ;
400408 }
401409 } ) ;
402410
@@ -519,8 +527,7 @@ function initCommentForm() {
519527 "" ,
520528 $menu . data ( 'issue-id' ) ,
521529 $ ( this ) . data ( 'id' ) ,
522- function ( ) { location . reload ( ) ; }
523- ) ;
530+ ) . then ( reload ) ;
524531 }
525532 switch ( input_id ) {
526533 case '#milestone_id' :
@@ -546,8 +553,7 @@ function initCommentForm() {
546553 "" ,
547554 $menu . data ( 'issue-id' ) ,
548555 $ ( this ) . data ( 'id' ) ,
549- function ( ) { location . reload ( ) ; }
550- ) ;
556+ ) . then ( reload ) ;
551557 }
552558
553559 $list . find ( '.selected' ) . html ( '' ) ;
@@ -801,7 +807,7 @@ function initRepository() {
801807 function ( data ) {
802808 $editInput . val ( data . title ) ;
803809 $issueTitle . text ( data . title ) ;
804- location . reload ( ) ;
810+ reload ( ) ;
805811 } ) ;
806812 return false ;
807813 } ) ;
@@ -1786,7 +1792,7 @@ function u2fRegistered(resp) {
17861792 data : JSON . stringify ( resp ) ,
17871793 contentType : "application/json; charset=utf-8" ,
17881794 success : function ( ) {
1789- window . location . reload ( ) ;
1795+ reload ( ) ;
17901796 } ,
17911797 fail : function ( xhr , textStatus ) {
17921798 u2fError ( 1 ) ;
@@ -2073,9 +2079,7 @@ $(document).ready(function () {
20732079 return this . dataset . issueId ;
20742080 } ) . get ( ) . join ( ) ;
20752081 var url = this . dataset . url
2076- updateIssuesMeta ( url , action , issueIDs , elementId , function ( ) {
2077- location . reload ( ) ;
2078- } ) ;
2082+ updateIssuesMeta ( url , action , issueIDs , elementId ) . then ( reload ) ;
20792083 } ) ;
20802084
20812085 buttonsClickOnEnter ( ) ;
@@ -2912,7 +2916,7 @@ function updateDeadline(deadlineString) {
29122916 contentType : 'application/json' ,
29132917 type : 'POST' ,
29142918 success : function ( ) {
2915- window . location . reload ( ) ;
2919+ reload ( ) ;
29162920 } ,
29172921 error : function ( ) {
29182922 $ ( '#deadline-loader' ) . removeClass ( 'loading' ) ;
0 commit comments