mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
mark all as read for categories
This commit is contained in:
@@ -149,13 +149,26 @@ public class EntriesREST extends AbstractREST {
|
||||
} else if (type == Type.feed) {
|
||||
Feed feed = feedSubscriptionService.findById(Long.valueOf(id))
|
||||
.getFeed();
|
||||
if (read) {
|
||||
List<FeedEntryWithStatus> entries = feedEntryService
|
||||
.getEntries(feed, getUser(), false);
|
||||
for (FeedEntryWithStatus entry : entries) {
|
||||
markEntry(entry.getEntry(), true);
|
||||
}
|
||||
List<FeedEntryWithStatus> entries = feedEntryService.getEntries(
|
||||
feed, getUser(), false);
|
||||
for (FeedEntryWithStatus entry : entries) {
|
||||
markEntry(entry, read);
|
||||
}
|
||||
} else if (type == Type.category) {
|
||||
FeedCategory feedCategory = null;
|
||||
if (!ALL.equals(id)) {
|
||||
feedCategory = feedCategoryService.findById(getUser(),
|
||||
Long.valueOf(id));
|
||||
}
|
||||
List<FeedCategory> childrenCategories = feedCategoryService
|
||||
.findAllChildrenCategories(getUser(), feedCategory);
|
||||
|
||||
List<FeedEntryWithStatus> entries = feedEntryService.getEntries(
|
||||
childrenCategories, getUser(), false);
|
||||
for (FeedEntryWithStatus entry : entries) {
|
||||
markEntry(entry, true);
|
||||
}
|
||||
|
||||
}
|
||||
return Response.ok(Status.OK).build();
|
||||
}
|
||||
@@ -172,4 +185,15 @@ public class EntriesREST extends AbstractREST {
|
||||
feedEntryStatusService.saveOrUpdate(status);
|
||||
}
|
||||
|
||||
private void markEntry(FeedEntryWithStatus entryWithStatus, boolean read) {
|
||||
FeedEntryStatus status = entryWithStatus.getStatus();
|
||||
if (status == null) {
|
||||
status = new FeedEntryStatus();
|
||||
status.setUser(getUser());
|
||||
status.setEntry(entryWithStatus.getEntry());
|
||||
}
|
||||
status.setRead(read);
|
||||
feedEntryStatusService.saveOrUpdate(status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user