james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From man...@apache.org
Subject svn commit: r1671549 - /james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/ComposeActivity.java
Date Mon, 06 Apr 2015 15:21:26 GMT
Author: manolo
Date: Mon Apr  6 15:21:26 2015
New Revision: 1671549

URL: http://svn.apache.org/r1671549
Log:
Do not send messages twice

Modified:
    james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/ComposeActivity.java

Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/ComposeActivity.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/ComposeActivity.java?rev=1671549&r1=1671548&r2=1671549&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/ComposeActivity.java
(original)
+++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/ComposeActivity.java
Mon Apr  6 15:21:26 2015
@@ -83,6 +83,7 @@ public class ComposeActivity extends App
     private List<MessageAttachment> attachments = new ArrayList<MessageAttachment>();
     protected ComposePlace place;
     private User user;
+    private boolean sending;
 
     public Activity with(ComposePlace place) {
         this.place = place;
@@ -223,7 +224,7 @@ public class ComposeActivity extends App
         return ret;
     }
     protected void bindTo(EventBus eventBus) {
-        eventBus.addHandler(AddressClickEvent.TYPE, new AddressClickEventHandler() {
+        registerHandler(eventBus.addHandler(AddressClickEvent.TYPE, new AddressClickEventHandler()
{
             @Override
             public void onClick(AddressClickEvent event) {
                 String to = display.getTo().getText();
@@ -233,23 +234,23 @@ public class ComposeActivity extends App
                     display.getTo().setText(event.getEmail());
                 }
             }
-        });
-        eventBus.addHandler(SendClickEvent.TYPE, new SendClickEventHandler() {
+        }));
+        registerHandler(eventBus.addHandler(SendClickEvent.TYPE, new SendClickEventHandler()
{
             public void onSendClick(SendClickEvent event) {
                 send();
             }
-        });
-        eventBus.addHandler(LoginEvent.TYPE, new LoginEventHandler() {
+        }));
+        registerHandler(eventBus.addHandler(LoginEvent.TYPE, new LoginEventHandler() {
             public void onLogin(LoginEvent event) {
                 user = event.getUser();
             }
-        });
-        eventBus.addHandler(AttachClickEvent.TYPE, new AttachClickEventHandler() {
+        }));
+        registerHandler(eventBus.addHandler(AttachClickEvent.TYPE, new AttachClickEventHandler()
{
             public void onAttachClick(AttachClickEvent event) {
                 display.getAttachButton().fireEvent(new ClickEvent() {
                 });
             }
-        });
+        }));
         registerHandler(display.getSendClick().addClickHandler(sendClickHandler));
         registerHandler(display.getCancelClick().addClickHandler(cancelClickHandler));
 
@@ -305,12 +306,12 @@ public class ComposeActivity extends App
         registerHandler(display.getUploader().addOnFinishUploadHandler(onFinishUploadHandler));
         registerHandler(display.getUploader().addOnCancelUploadHandler(onCancelUploadHandler));
 
-        eventBus.addHandler(MailToEvent.TYPE, new MailToEventHandler() {
+        registerHandler(eventBus.addHandler(MailToEvent.TYPE, new MailToEventHandler() {
             @Override
             public void onMailTo(MailToEvent event) {
                 display.getTo().setText(event.getMailto());
             }
-        });
+        }));
 
         fillSuggestList();
 
@@ -378,6 +379,7 @@ public class ComposeActivity extends App
     protected void send() {
         if (!validate())
             return;
+        sending = true;
         hupaController.showTopLoading("Sending...");
 
         MessageDetails oldDetails = place.getParameters().getOldDetails();
@@ -429,7 +431,8 @@ public class ComposeActivity extends App
     }
     private boolean validate() {
         // Don't trust only in view validation
-        return display.validate() && display.getTo().getText().trim().length() >
0
+        return !sending
+                && display.validate() && display.getTo().getText().trim().length()
> 0
                 && EmailListValidator.isValidAddressList(display.getTo().getText())
                 && EmailListValidator.isValidAddressList(display.getCc().getText())
                 && EmailListValidator.isValidAddressList(display.getBcc().getText());
@@ -467,6 +470,7 @@ public class ComposeActivity extends App
     }
 
     private void afterSend(GenericResult response) {
+        sending = false;
         hupaController.hideTopLoading();
         hupaController.showNotice("Your mail has been sent.", 10000);
         History.back();



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message