Caches.clearLivingStoryThemeInfo(id);
}
@Override
public StartPageBundle getStartPageBundle() {
StartPageBundle bundle = Caches.getStartPageBundle();
if (bundle == null) {
List<LivingStory> unsortedLivingStories = getAllLivingStories(true);
Map<Long, List<BaseContentItem>> storyIdToUpdateMap =
new HashMap<Long, List<BaseContentItem>>();
List<LivingStoryAndLastUpdateTime> livingStoriesAndUpdateTimes =
new ArrayList<LivingStoryAndLastUpdateTime>();
// For each living story, get the last 3 updates - the updates are sorted in reverse
// chronological order
for (LivingStory livingStory : unsortedLivingStories) {
List<BaseContentItem> updates =
contentRpcService.getUpdatesForStartPage(livingStory.getId());
storyIdToUpdateMap.put(livingStory.getId(), updates);
livingStoriesAndUpdateTimes.add(
new LivingStoryAndLastUpdateTime(livingStory,
updates.isEmpty() ? null : updates.get(0).getTimestamp()));
}
// After we have the updates for each story, we want to sort them such that the story with
// the latest update is first
Collections.sort(livingStoriesAndUpdateTimes, LivingStoryAndLastUpdateTime.getComparator());
List<LivingStory> sortedLivingStories = new ArrayList<LivingStory>();
for (LivingStoryAndLastUpdateTime story : livingStoriesAndUpdateTimes) {
sortedLivingStories.add(story.livingStory);
}
bundle = new StartPageBundle(sortedLivingStories, storyIdToUpdateMap);
Caches.setStartPageBundle(bundle);
}
return bundle;
}