diff --git a/distro/changelog.xml b/distro/changelog.xml index b770c5c..7d1fa95 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -8,6 +8,7 @@ Feature #11189: Social-Networking - citing a people (with '@') in comments loses the focus. + Feature #10192 allow to sort feeds per recent comments Support for ticket #11139 () { + newsService.getSingleFeed(postKey, new AsyncCallback() { @Override public void onSuccess(EnhancedFeed result) { if (result.getFeed().getType() == FeedType.DISABLED) { @@ -759,35 +766,35 @@ public class NewsFeedPanel extends Composite { newsPanel.insert(tt, 0); //insert in the view allUpdates.add(0, feed); //insert in the model -// //timer for the transition -// Timer t = new Timer() { -// @Override -// public void run() { -// tt.setcontentAreaStyle("visible"); -// -// // alert the user-statistics portlet to update statistics in case -// // one or more feed belongs to user himself -// if(tt.isUser()){ -// try{ -// -// NewsFeed.pageBusAdapter.PageBusPublish(PageBusEvents.postIncrement, "", Defaults.STRING_JSONIZER); -// -// int numComments = tt.numberOfComments(); -// int numLikes = tt.numberOfLikes(); -// -// for(int i = 0; i < numComments; i++) -// NewsFeed.pageBusAdapter.PageBusPublish(PageBusEvents.commentsIncrement, "", Defaults.STRING_JSONIZER); -// -// for(int i = 0; i < numLikes; i++) -// NewsFeed.pageBusAdapter.PageBusPublish(PageBusEvents.likesIncrement, "", Defaults.STRING_JSONIZER); -// -// }catch (PageBusAdapterException ex) { -// GWT.log(ex.toString()); -// } -// } -// } -// }; -// t.schedule(100); + // //timer for the transition + // Timer t = new Timer() { + // @Override + // public void run() { + // tt.setcontentAreaStyle("visible"); + // + // // alert the user-statistics portlet to update statistics in case + // // one or more feed belongs to user himself + // if(tt.isUser()){ + // try{ + // + // NewsFeed.pageBusAdapter.PageBusPublish(PageBusEvents.postIncrement, "", Defaults.STRING_JSONIZER); + // + // int numComments = tt.numberOfComments(); + // int numLikes = tt.numberOfLikes(); + // + // for(int i = 0; i < numComments; i++) + // NewsFeed.pageBusAdapter.PageBusPublish(PageBusEvents.commentsIncrement, "", Defaults.STRING_JSONIZER); + // + // for(int i = 0; i < numLikes; i++) + // NewsFeed.pageBusAdapter.PageBusPublish(PageBusEvents.likesIncrement, "", Defaults.STRING_JSONIZER); + // + // }catch (PageBusAdapterException ex) { + // GWT.log(ex.toString()); + // } + // } + // } + // }; + // t.schedule(100); } //after that I remove the ($updatesNo) from Window Title String currTitle = Document.get().getTitle(); @@ -1024,43 +1031,57 @@ public class NewsFeedPanel extends Composite { }); } else{ - - int from = (fromStartingPoint == null) ? allUpdates.size()+1 : fromStartingPoint; - final int quantity = 10; - GWT.log("StartingPoint = " + from); - newsService.getMoreFeeds(from, quantity, new AsyncCallback() { - @Override - public void onSuccess(MoreFeedsBean rangeFeeds) { - newsPanel.remove(showMoreUpdatesPanel); - if (rangeFeeds.getFeeds() != null) { - fromStartingPoint = rangeFeeds.getLastReturnedFeedTimelineIndex(); - int c = 1; - for (EnhancedFeed feed : rangeFeeds.getFeeds()) { - if (!isFeedPresent(feed)) { //avoid possible duplicates - newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view - allUpdates.add(feed); //in the model - } - c++; - } - if (c >= quantity) { //there could be more feeds - GWT.log("there could be more feeds"); - showMoreUpdatesPanel.clear(); - showMoreWidget = new ShowMoreFeeds(eventBus); - showMoreUpdatesPanel.add(showMoreWidget); - newsPanel.add(showMoreUpdatesPanel); + loadMorePosts(quantity, false); + } + } + /** + * + * @param quantity + */ + public void loadMorePosts(final int quantity, boolean isSortingByLastCommentedposts) { + if (isSortingByLastCommentedposts) + showLoader(); + int from = (fromStartingPoint == null) ? allUpdates.size()+1 : fromStartingPoint; + GWT.log("StartingPoint = " + from); + newsService.getMoreFeeds(from, quantity, new AsyncCallback() { + @Override + public void onSuccess(MoreFeedsBean rangeFeeds) { + newsPanel.remove(showMoreUpdatesPanel); + if (rangeFeeds.getFeeds() != null) { + fromStartingPoint = rangeFeeds.getLastReturnedFeedTimelineIndex(); + int c = 1; + for (EnhancedFeed feed : rangeFeeds.getFeeds()) { + if (!isFeedPresent(feed)) { //avoid possible duplicates + newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view + allUpdates.add(feed); //in the model } + c++; + } + if (c >= quantity) { //there could be more feeds + GWT.log("there could be more feeds"); + showMoreUpdatesPanel.clear(); + showMoreWidget = new ShowMoreFeeds(eventBus); + showMoreUpdatesPanel.add(showMoreWidget); + newsPanel.add(showMoreUpdatesPanel); + } + if (isSortingByLastCommentedposts) { + sortCurrentPostsByLatestComment(); + showMoreUpdatesPanel.clear(); + showMoreWidget = null; + if (getAllUpdatesSize() > 99) + newsPanel.add(new HTML(LIMIT_REACHED_FOR_SORTING_COMMENTS_TEXT)); } } - @Override - public void onFailure(Throwable caught) { - showMoreUpdatesPanel.clear(); - newsPanel.add(new HTML("
" + - "Ops! There were problems while retrieving your feeds!.
" + - "Please try again in a short while.
")); - } - }); - } + } + @Override + public void onFailure(Throwable caught) { + showMoreUpdatesPanel.clear(); + newsPanel.add(new HTML("
" + + "Ops! There were problems while retrieving your feeds!.
" + + "Please try again in a short while.
")); + } + }); } /** * @param widget the widget to check @@ -1127,7 +1148,7 @@ public class NewsFeedPanel extends Composite { /** * Only User Feeds */ - public void showOnlyMyFeeds() { + public void showOnlyMyPosts() { showLoader(); newsService.getOnlyMyUserFeeds(new AsyncCallback>() { @Override @@ -1164,9 +1185,9 @@ public class NewsFeedPanel extends Composite { }); } /** - * Only User Liked Feeds + * Only User Liked Posts */ - public void showOnlyLikedFeeds() { + public void showOnlyLikedPosts() { showLoader(); newsService.getOnlyLikedFeeds(new AsyncCallback>() { @Override @@ -1202,6 +1223,63 @@ public class NewsFeedPanel extends Composite { } }); } + /**: + * Sort the posts per recent comment + */ + private void sortCurrentPostsByLatestComment() { + showLoader(); + GWT.log(" number of posts " + allUpdates.size()); + ArrayList latestComments = new ArrayList<>(); + //thePostsMap is need so that later it is faster to get the post by id + HashMap theCommentedPostsMap = new HashMap<>(); + for (EnhancedFeed post : allUpdates) { + ArrayList postComments = post.getComments(); + if (postComments != null && !postComments.isEmpty()) { + theCommentedPostsMap.put(post.getFeed().getKey(), post); + Comment latest = postComments.get(postComments.size()-1); + latestComments.add(latest); //get the latest + } + } + //sort the comments + Collections.sort(latestComments, Collections.reverseOrder()); + ArrayList sortedPostsByLatestComment = new ArrayList<>(); + // evaluate unique posts' ids + HashSet postIds = new HashSet(); + for (Comment comment : latestComments) { + String postId = comment.getFeedid(); + if(!postIds.contains(postId)){ + postIds.add(postId); + sortedPostsByLatestComment.add(theCommentedPostsMap.get(postId)); + } + } + //at this point the sortedPostsByLatestComment list contains only the commented posts in the right order + //we need to add the remaining posts of the page in the latest post order + for (EnhancedFeed post : allUpdates) { + if (!theCommentedPostsMap.containsKey(post.getFeed().getKey())) + sortedPostsByLatestComment.add(post); + } + newsPanel.clear(); + if (sortedPostsByLatestComment.size() == 0) { + newsPanel.add(new HTML("
" + + "Looks like we've got nothing for you at the moment.
" + + "Set an update as your favorite to see it here
")); + isFirstTweet = true; + } + else { + newsPanel.setHeight(""); + newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT); + newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); + for (EnhancedFeed feed : sortedPostsByLatestComment) + newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); + if (sortedPostsByLatestComment.size() < 5) { + newsPanel.add(new Image(spacer)); + } + isFirstTweet = false; + } + + + } + @@ -1231,17 +1309,17 @@ public class NewsFeedPanel extends Composite { doShowSessionExpired(); } else{ -// // alert the User statistics portlet to increment the number of likes got -// if(owner.isUser()){ -// try { -// NewsFeed.pageBusAdapter.PageBusPublish( -// PageBusEvents.likesIncrement -// , "" -// , Defaults.STRING_JSONIZER); -// } catch (PageBusAdapterException ex) { -// GWT.log(ex.toString()); -// } -// } + // // alert the User statistics portlet to increment the number of likes got + // if(owner.isUser()){ + // try { + // NewsFeed.pageBusAdapter.PageBusPublish( + // PageBusEvents.likesIncrement + // , "" + // , Defaults.STRING_JSONIZER); + // } catch (PageBusAdapterException ex) { + // GWT.log(ex.toString()); + // } + // } } } @@ -1259,16 +1337,16 @@ public class NewsFeedPanel extends Composite { }else{ // alert the User statistics portlet to decrement the number of likes got -// if(owner.isUser()){ -// try { -// NewsFeed.pageBusAdapter.PageBusPublish( -// PageBusEvents.likesDecrement -// , "" -// , Defaults.STRING_JSONIZER); -// } catch (PageBusAdapterException ex) { -// GWT.log(ex.toString()); -// } -// } + // if(owner.isUser()){ + // try { + // NewsFeed.pageBusAdapter.PageBusPublish( + // PageBusEvents.likesDecrement + // , "" + // , Defaults.STRING_JSONIZER); + // } catch (PageBusAdapterException ex) { + // GWT.log(ex.toString()); + // } + // } } } @@ -1277,7 +1355,7 @@ public class NewsFeedPanel extends Composite { } private void doShowSessionExpired() { - + } private void doShowLikes(final String feedId) { @@ -1324,14 +1402,14 @@ public class NewsFeedPanel extends Composite { owner.updateCommentsNumberCount(); owner.showAddCommentForm(false); -// if(owner.isUser()){ -// // alert the User statistics portlet to increment the number of comments got -// try { -// NewsFeed.pageBusAdapter.PageBusPublish(PageBusEvents.commentsIncrement, "", Defaults.STRING_JSONIZER); -// } catch (PageBusAdapterException e) { -// GWT.log(e.toString()); -// } -// } + // if(owner.isUser()){ + // // alert the User statistics portlet to increment the number of comments got + // try { + // NewsFeed.pageBusAdapter.PageBusPublish(PageBusEvents.commentsIncrement, "", Defaults.STRING_JSONIZER); + // } catch (PageBusAdapterException e) { + // GWT.log(e.toString()); + // } + // } } } else { @@ -1407,14 +1485,14 @@ public class NewsFeedPanel extends Composite { doShowComments(owner, false); owner.updateCommentsNumberCount(); -// if(owner.isUser()){ -// // alert the User statistics portlet to decrement the number of comments got -// try { -// NewsFeed.pageBusAdapter.PageBusPublish(PageBusEvents.commentsDecrement, "", Defaults.STRING_JSONIZER); -// } catch (PageBusAdapterException ex) { -// GWT.log(ex.toString()); -// } -// } + // if(owner.isUser()){ + // // alert the User statistics portlet to decrement the number of comments got + // try { + // NewsFeed.pageBusAdapter.PageBusPublish(PageBusEvents.commentsDecrement, "", Defaults.STRING_JSONIZER); + // } catch (PageBusAdapterException ex) { + // GWT.log(ex.toString()); + // } + // } } else Window.alert("Comment could not be deleted, please try again in a short while."); } @@ -1437,23 +1515,23 @@ public class NewsFeedPanel extends Composite { toDelete.removeFromParent(); if(toDelete.isUser()){ -// try{ -// // alert the User statistics portlet to decrement the number of user's posts -// NewsFeed.pageBusAdapter.PageBusPublish(PageBusEvents.postDecrement, "", Defaults.STRING_JSONIZER); -// -// // alert the same portlet to decrement the number of likes/replies, if any -// int numComments = toDelete.numberOfComments(); -// int numLikes = toDelete.numberOfLikes(); -// -// for(int i = 0; i < numComments; i++) -// NewsFeed.pageBusAdapter.PageBusPublish(PageBusEvents.commentsDecrement, "", Defaults.STRING_JSONIZER); -// -// for(int i = 0; i < numLikes; i++) -// NewsFeed.pageBusAdapter.PageBusPublish(PageBusEvents.likesDecrement, "", Defaults.STRING_JSONIZER); -// -// }catch (PageBusAdapterException ex) { -// GWT.log(ex.toString()); -// } + // try{ + // // alert the User statistics portlet to decrement the number of user's posts + // NewsFeed.pageBusAdapter.PageBusPublish(PageBusEvents.postDecrement, "", Defaults.STRING_JSONIZER); + // + // // alert the same portlet to decrement the number of likes/replies, if any + // int numComments = toDelete.numberOfComments(); + // int numLikes = toDelete.numberOfLikes(); + // + // for(int i = 0; i < numComments; i++) + // NewsFeed.pageBusAdapter.PageBusPublish(PageBusEvents.commentsDecrement, "", Defaults.STRING_JSONIZER); + // + // for(int i = 0; i < numLikes; i++) + // NewsFeed.pageBusAdapter.PageBusPublish(PageBusEvents.likesDecrement, "", Defaults.STRING_JSONIZER); + // + // }catch (PageBusAdapterException ex) { + // GWT.log(ex.toString()); + // } } } else Window.alert("Feed could not be deleted, please try again in a short while."); @@ -1467,6 +1545,10 @@ public class NewsFeedPanel extends Composite { Window.Location.assign(Window.Location.getHref() + ((Window.Location.getHref().contains("?")) ? "&oid="+feedKey : "?oid="+feedKey)); } + public int getAllUpdatesSize() { + return allUpdates.size(); + } + /** * set the filter type status for automatic reloading of tweets * @param currentFilter @@ -1481,7 +1563,7 @@ public class NewsFeedPanel extends Composite { public static String getCurrentScope() { return currentScope; } - + public static String extractOrgFriendlyURL(String portalURL) { String groupRegEx = "/group/"; if (portalURL.contains(groupRegEx)) { diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/FilterPanel.java b/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/FilterPanel.java index d91a5c2..227e823 100644 --- a/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/FilterPanel.java +++ b/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/FilterPanel.java @@ -5,8 +5,8 @@ import org.gcube.portlets.user.newsfeed.client.NewsServiceAsync; import org.gcube.portlets.user.newsfeed.client.panels.NewsFeedPanel; import org.gcube.portlets.user.newsfeed.shared.UserSettings; +import com.github.gwtbootstrap.client.ui.NavLink; import com.google.gwt.core.client.GWT; -import com.google.gwt.dom.client.Style.Cursor; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; @@ -14,7 +14,6 @@ import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.Widget; public class FilterPanel extends Composite { @@ -35,85 +34,32 @@ public class FilterPanel extends Composite { initWidget(uiBinder.createAndBindUi(this)); this.caller = caller; this.service = newsService; - //connectionsLink.setHTML("Connections"); - allUpdatesLink.setHTML("All Updates"); - favoritesLink.setHTML("Favorites"); - onlyme.setHTML("Your Posts"); - //connectionsLink.getElement().getStyle().setCursor(Cursor.POINTER); - allUpdatesLink.getElement().getStyle().setCursor(Cursor.POINTER); - favoritesLink.getElement().getStyle().setCursor(Cursor.POINTER); - onlyme.getElement().getStyle().setCursor(Cursor.POINTER); - - allUpdatesLink.setStyleName("filter-selected"); } - -// @UiField -// HTML connectionsLink; - @UiField - HTML allUpdatesLink; - @UiField - HTML favoritesLink; - @UiField - HTML onlyme; - - -// @UiHandler("connectionsLink") -// void onConnectionsClick(ClickEvent e) { -// allUpdatesLink.removeStyleName("filter-selected"); -// onlyme.removeStyleName("filter-selected"); -// connectionsLink.setStyleName("filter-selected"); -// caller.setCurrentFilter(FilterType.CONNECTIONS); -// service.getUserInfo(new AsyncCallback() { -// @Override -// public void onFailure(Throwable caught) { -// Window.alert("Ops! we encountered some problems delivering your message, server is not responding, please try again in a short while."); -// } -// -// @Override -// public void onSuccess(UserInfo result) { -// if (result.getUsername().equals("test.user")) { -// Window.alert("Your session has expired, please log out and login again"); -// } -// else -// caller.showOnlyConnectionsFeeds(); -// } -// }); -// } -// - public void removeFilterSelected() { - allUpdatesLink.removeStyleName("filter-selected"); - onlyme.removeStyleName("filter-selected"); - favoritesLink.removeStyleName("filter-selected"); - } - - @UiHandler("favoritesLink") - void onFavoritesClick(ClickEvent e) { - allUpdatesLink.removeStyleName("filter-selected"); - onlyme.removeStyleName("filter-selected"); - favoritesLink.setStyleName("filter-selected"); - caller.setCurrentFilter(FilterType.LIKEDFEEDS); - service.getUserSettings(new AsyncCallback() { - @Override - public void onFailure(Throwable caught) { - Window.alert(ERROR_MESSAGE); - } - @Override - public void onSuccess(UserSettings result) { - if (result.getUserInfo().getUsername().equals("test.user")) { - Window.alert(SESSION_EXPIRED); - } - else - caller.showOnlyLikedFeeds(); - } - }); + @UiField + NavLink allUpdatesLink; + @UiField + NavLink recentCommentsLink; + + public void removeFilterSelected() { + allUpdatesLink.setActive(false); + recentCommentsLink.setActive(false); + } + + @UiHandler("recentCommentsLink") + void onRecentCommentsLinkClick(ClickEvent e) { + allUpdatesLink.setActive(false); + recentCommentsLink.setActive(true); + caller.setCurrentFilter(FilterType.RECENT_COMMENTS); + int loadedPostsInView = caller.getAllUpdatesSize(); + int quantity = loadedPostsInView < 100 ? 100 - loadedPostsInView : loadedPostsInView; + caller.loadMorePosts(quantity, true); } @UiHandler("allUpdatesLink") void onAllUpdatesClick(ClickEvent e) { - onlyme.removeStyleName("filter-selected"); - favoritesLink.removeStyleName("filter-selected"); - allUpdatesLink.setStyleName("filter-selected"); + allUpdatesLink.setActive(true); + recentCommentsLink.setActive(false); caller.setCurrentFilter(FilterType.ALL_UPDATES); service.getUserSettings(new AsyncCallback() { @Override @@ -131,27 +77,5 @@ public class FilterPanel extends Composite { } }); } - - @UiHandler("onlyme") - void onlyme(ClickEvent e) { - allUpdatesLink.removeStyleName("filter-selected"); - favoritesLink.removeStyleName("filter-selected"); - onlyme.setStyleName("filter-selected"); - caller.setCurrentFilter(FilterType.MINE); - service.getUserSettings(new AsyncCallback() { - @Override - public void onFailure(Throwable caught) { - Window.alert(ERROR_MESSAGE); - } - @Override - public void onSuccess(UserSettings result) { - if (result.getUserInfo().getUsername().equals("test.user")) { - Window.alert(SESSION_EXPIRED); - } - else - caller.showOnlyMyFeeds(); - } - }); - } } diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/FilterPanel.ui.xml b/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/FilterPanel.ui.xml index 2a781a7..ab734a2 100644 --- a/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/FilterPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/FilterPanel.ui.xml @@ -1,27 +1,42 @@ + xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"> - .important { - font-weight: bold; - } + .margin { + margin-bottom: 0; + margin-top: 0; + } -
-
    -
  • - -
  • - - + + Sort by newest: + Post + commented post + + + + + -
  • - -
  • -
  • - -
  • -
-
+ + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/ShowMoreFeeds.java b/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/ShowMoreFeeds.java index b145793..43cfa0f 100644 --- a/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/ShowMoreFeeds.java +++ b/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/ShowMoreFeeds.java @@ -2,7 +2,6 @@ package org.gcube.portlets.user.newsfeed.client.ui; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Style.Unit; -import com.google.gwt.dom.client.Style.Visibility; import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; @@ -32,7 +31,7 @@ public class ShowMoreFeeds extends Composite { caption.getElement().getStyle().setFontSize(14, Unit.PX); caption.setHTML("Show more feeds"); //done after - panel.getElement().getStyle().setVisibility(Visibility.HIDDEN); + //panel.getElement().getStyle().setVisibility(Visibility.HIDDEN); } diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java b/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java index ce4f921..6cf8958 100644 --- a/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java @@ -103,7 +103,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService */ private ElasticSearchClient escl; - private final static int MAX_FEEDS_NO = 30; + private final static int MAX_POSTS_NO = 30; public void init() { store = new DBCassandraAstyanaxImpl(); @@ -237,8 +237,8 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService ArrayList toReturn = new ArrayList(); //return only feeds - if (toMerge.size() > MAX_FEEDS_NO) - for (int i = 0; i < MAX_FEEDS_NO; i++) + if (toMerge.size() > MAX_POSTS_NO) + for (int i = 0; i < MAX_POSTS_NO; i++) toReturn.add(toMerge.get(i)); else { return enhanceFeeds(toMerge, 2); @@ -323,8 +323,8 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService ArrayList toReturn = new ArrayList(); //return only feeds - if (toMerge.size() > MAX_FEEDS_NO) - for (int i = 0; i < MAX_FEEDS_NO; i++) + if (toMerge.size() > MAX_POSTS_NO) + for (int i = 0; i < MAX_POSTS_NO; i++) toReturn.add(toMerge.get(i)); else { return enhanceFeeds(toMerge, 2); @@ -434,8 +434,8 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService Collections.sort(toMerge, Collections.reverseOrder()); ArrayList toReturn = new ArrayList(); //return only feeds - if (toMerge.size() > MAX_FEEDS_NO) - for (int i = 0; i < MAX_FEEDS_NO; i++) + if (toMerge.size() > MAX_POSTS_NO) + for (int i = 0; i < MAX_POSTS_NO; i++) toReturn.add(toMerge.get(i)); else return enhanceFeeds(toMerge, 2);