Uploader clears all finished files when it is not visible (issue #2442)
authorChristos Stathis <chstath@ebs.gr>
Fri, 25 May 2012 12:08:47 +0000 (15:08 +0300)
committerChristos Stathis <chstath@ebs.gr>
Fri, 25 May 2012 12:08:47 +0000 (15:08 +0300)
src/gr/grnet/pithos/web/client/FileUploadDialog.java
src/gr/grnet/pithos/web/client/Pithos.java

index 052ce30..7b5d021 100644 (file)
@@ -243,14 +243,21 @@ public class FileUploadDialog extends DialogBox {
                                        },
                                        
                                        UploadComplete: function(up, files) {
-                                               if ($wnd.console && $wnd.console.log)
+                                               if ($wnd.console && $wnd.console.log) {
                                                        $wnd.console.log('All files finished');
+                                               }
                                                dlg.@gr.grnet.pithos.web.client.FileUploadDialog::setInProgress(Z)(false);
                                                dlg.@gr.grnet.pithos.web.client.FileUploadDialog::hideUploadIndicator()();
                                                app.@gr.grnet.pithos.web.client.Pithos::hideUploadAlert()();
                                                var uris = [];
-                                               for (var i = 0; i<files.length; i++)
-                                                       uris.push(files[i].url);
+                                               if (!dlg.@gr.grnet.pithos.web.client.FileUploadDialog::isVisible()())
+                                                       while (files.length > 0) {
+                                                               uris.push(files[0].url);
+                                                               up.removeFile(files[0]);
+                                                       }
+                                               else
+                                                       for (var i=0; i<files.length; i++)
+                                                               uris.push(files[i].url);
                                                app.@gr.grnet.pithos.web.client.Pithos::updateUploadFolder(Lcom/google/gwt/core/client/JsArrayString;)(uris);
                                        },
                                        
@@ -346,10 +353,18 @@ public class FileUploadDialog extends DialogBox {
        void close() {
                setVisible(false);
                setModal(false);
+               clearUploader();
                if (isUploading())
                        app.showUploadIndicator();
                setGlobalDropArea();
        }
+
+       private native void clearUploader() /*-{
+               var uploader = $wnd.$("#uploader").pluploadQueue();
+               var files = uploader.files;
+               while (files.length > 0)
+                       uploader.removeFile(files[0]);
+       }-*/;
        
        native void setGlobalDropArea() /*-{
                var uploader = $wnd.$("#uploader").pluploadQueue();
index ef70a38..8deaac3 100644 (file)
@@ -1398,7 +1398,8 @@ public class Pithos implements EntryPoint, ResizeHandler {
        }
        
        public void hideUploadAlert() {
-               uploadAlert.hide();
+               if (uploadAlert != null && uploadAlert.isShowing())
+                       uploadAlert.hide();
        }
        
        public void selectUploadedFiles(JsArrayString urls) {