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; }