mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
toggle between unread and all entries
This commit is contained in:
@@ -46,12 +46,11 @@ public class FeedEntryService extends GenericDAO<FeedEntry, Long> {
|
||||
return typedQuery.getResultList();
|
||||
}
|
||||
|
||||
public List<FeedEntry> getAllEntries(Feed feed, User user) {
|
||||
public List<FeedEntry> getAllEntries(Feed feed) {
|
||||
String query = "select e from FeedEntry e where e.feed=:feed";
|
||||
TypedQuery<FeedEntry> typedQuery = em.createQuery(query,
|
||||
FeedEntry.class);
|
||||
typedQuery.setParameter("feed", feed);
|
||||
typedQuery.setParameter("user", user);
|
||||
return typedQuery.getResultList();
|
||||
}
|
||||
|
||||
|
||||
@@ -30,11 +30,13 @@ public class EntriesREST extends AbstractREST {
|
||||
@PathParam("id") String id, @PathParam("readType") String readType) {
|
||||
|
||||
Entries entries = new Entries();
|
||||
boolean unreadOnly = "unread".equals(readType);
|
||||
|
||||
if ("feed".equals(type)) {
|
||||
FeedSubscription subscription = feedSubscriptionService
|
||||
.findById(Long.valueOf(id));
|
||||
entries.setName(subscription.getTitle());
|
||||
entries.getEntries().addAll(buildEntries(subscription));
|
||||
entries.getEntries().addAll(buildEntries(subscription, unreadOnly));
|
||||
|
||||
} else {
|
||||
FeedCategory feedCategory = "all".equals(id) ? null
|
||||
@@ -45,7 +47,8 @@ public class EntriesREST extends AbstractREST {
|
||||
|
||||
entries.setName("all".equals(id) ? "All" : feedCategory.getName());
|
||||
for (FeedSubscription subscription : subscriptions) {
|
||||
entries.getEntries().addAll(buildEntries(subscription));
|
||||
entries.getEntries().addAll(
|
||||
buildEntries(subscription, unreadOnly));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,9 +62,17 @@ public class EntriesREST extends AbstractREST {
|
||||
return entries;
|
||||
}
|
||||
|
||||
private List<Entry> buildEntries(FeedSubscription subscription) {
|
||||
List<FeedEntry> feedEntries = feedEntryService.getUnreadEntries(
|
||||
subscription.getFeed(), getUser());
|
||||
private List<Entry> buildEntries(FeedSubscription subscription,
|
||||
boolean unreadOnly) {
|
||||
List<FeedEntry> feedEntries = null;
|
||||
|
||||
if (unreadOnly) {
|
||||
feedEntries = feedEntryService.getUnreadEntries(
|
||||
subscription.getFeed(), getUser());
|
||||
} else {
|
||||
feedEntries = feedEntryService.getAllEntries(
|
||||
subscription.getFeed());
|
||||
}
|
||||
|
||||
List<Entry> entries = Lists.newArrayList();
|
||||
for (FeedEntry feedEntry : feedEntries) {
|
||||
|
||||
Reference in New Issue
Block a user