clear upload bar correctly after upload completes by fixing a race and moving the upload_finished dispatch after clearing up the inprogress uploads data structure. I have zero idea how this ever worked... :/
							parent
							
								
									014acbab1f
								
							
						
					
					
						commit
						af5a866596
					
				| 
						 | 
					@ -92,6 +92,7 @@ class ContentMessages {
 | 
				
			||||||
        this.inprogress.push(upload);
 | 
					        this.inprogress.push(upload);
 | 
				
			||||||
        dis.dispatch({action: 'upload_started'});
 | 
					        dis.dispatch({action: 'upload_started'});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        var error;
 | 
				
			||||||
        var self = this;
 | 
					        var self = this;
 | 
				
			||||||
        return def.promise.then(function() {
 | 
					        return def.promise.then(function() {
 | 
				
			||||||
            upload.promise = matrixClient.uploadContent(file);
 | 
					            upload.promise = matrixClient.uploadContent(file);
 | 
				
			||||||
| 
						 | 
					@ -103,11 +104,10 @@ class ContentMessages {
 | 
				
			||||||
                dis.dispatch({action: 'upload_progress', upload: upload});
 | 
					                dis.dispatch({action: 'upload_progress', upload: upload});
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }).then(function(url) {
 | 
					        }).then(function(url) {
 | 
				
			||||||
            dis.dispatch({action: 'upload_finished', upload: upload});
 | 
					 | 
				
			||||||
            content.url = url;
 | 
					            content.url = url;
 | 
				
			||||||
            return matrixClient.sendMessage(roomId, content);
 | 
					            return matrixClient.sendMessage(roomId, content);
 | 
				
			||||||
        }, function(err) {
 | 
					        }, function(err) {
 | 
				
			||||||
            dis.dispatch({action: 'upload_failed', upload: upload});
 | 
					            error = err;
 | 
				
			||||||
            if (!upload.canceled) {
 | 
					            if (!upload.canceled) {
 | 
				
			||||||
                var desc = "The file '"+upload.fileName+"' failed to upload.";
 | 
					                var desc = "The file '"+upload.fileName+"' failed to upload.";
 | 
				
			||||||
                if (err.http_status == 413) {
 | 
					                if (err.http_status == 413) {
 | 
				
			||||||
| 
						 | 
					@ -128,6 +128,12 @@ class ContentMessages {
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            if (error) {
 | 
				
			||||||
 | 
					                dis.dispatch({action: 'upload_failed', upload: upload});
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else {
 | 
				
			||||||
 | 
					                dis.dispatch({action: 'upload_finished', upload: upload});
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue