From 23c47983358d3e66653d4a201956d8f72930dfd9 Mon Sep 17 00:00:00 2001 From: "massimiliano.assante" Date: Wed, 2 Apr 2014 22:21:38 +0000 Subject: [PATCH] fixed bug multiple requests with same range git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/notifications@94134 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/view/NotificationsPanel.java | 12 +++++++++--- src/main/webapp/Notifications.css | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/NotificationsPanel.java b/src/main/java/org/gcube/portlets/user/notifications/client/view/NotificationsPanel.java index 0e6bbaf..7b1f84f 100644 --- a/src/main/java/org/gcube/portlets/user/notifications/client/view/NotificationsPanel.java +++ b/src/main/java/org/gcube/portlets/user/notifications/client/view/NotificationsPanel.java @@ -54,6 +54,8 @@ public class NotificationsPanel extends Composite { private ShowMoreNotifications showMoreWidget; //needed to know the next range start private int fromStartingPoint = 0; + //needed to avoid to call the doShowMoreNotifications when the forst call has not returned yet + private boolean lockNotificationUpdate = false; private VerticalPanel container = new VerticalPanel(); private HorizontalPanel settingsPanel = new HorizontalPanel(); @@ -120,8 +122,9 @@ public class NotificationsPanel extends Composite { @Override public void onWindowScroll(ScrollEvent event) { boolean isInView = isScrolledIntoView(showMoreWidget); - if (isInView) { + if (isInView && !lockNotificationUpdate) { doShowMoreNotifications(); + lockNotificationUpdate = true; } } }); @@ -189,13 +192,14 @@ public class NotificationsPanel extends Composite { /** * called when a user scroll down the page to the bottom */ - private void doShowMoreNotifications() { + private void doShowMoreNotifications() { + GWT.log("doShowMoreNotifications()"); showMoreNotificationsPanel.remove(0); loadingImage.getElement().getStyle().setMargin(10, Unit.PX); showMoreNotificationsPanel.add(loadingImage); int from = (fromStartingPoint == 0) ? NotificationConstants.NOTIFICATION_NUMBER+1 : fromStartingPoint; fromStartingPoint = from; - final int quantity = 20; + final int quantity = 10; GWT.log("StartingPoint = " + from); notificationService.getUserNotificationsByRange(from, quantity, new AsyncCallback>>() { @@ -220,9 +224,11 @@ public class NotificationsPanel extends Composite { GWT.log("Show MORE "); showMoreNotificationsPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER); showMoreWidget = new ShowMoreNotifications(); + showMoreNotificationsPanel.clear(); showMoreNotificationsPanel.add(showMoreWidget); mainPanel.add(showMoreNotificationsPanel); } + lockNotificationUpdate = false; } } @Override diff --git a/src/main/webapp/Notifications.css b/src/main/webapp/Notifications.css index d4fb6af..51fd301 100644 --- a/src/main/webapp/Notifications.css +++ b/src/main/webapp/Notifications.css @@ -54,7 +54,7 @@ a.link:hover { .new-notifications-show { opacity: 1; background: #D6E2FC; - height: 18px; + height: 38px; }