forked from Archives/Athou_commafeed
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) {
|
} else if (type == Type.feed) {
|
||||||
Feed feed = feedSubscriptionService.findById(Long.valueOf(id))
|
Feed feed = feedSubscriptionService.findById(Long.valueOf(id))
|
||||||
.getFeed();
|
.getFeed();
|
||||||
if (read) {
|
List<FeedEntryWithStatus> entries = feedEntryService.getEntries(
|
||||||
List<FeedEntryWithStatus> entries = feedEntryService
|
feed, getUser(), false);
|
||||||
.getEntries(feed, getUser(), false);
|
for (FeedEntryWithStatus entry : entries) {
|
||||||
for (FeedEntryWithStatus entry : entries) {
|
markEntry(entry, read);
|
||||||
markEntry(entry.getEntry(), true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} 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();
|
return Response.ok(Status.OK).build();
|
||||||
}
|
}
|
||||||
@@ -172,4 +185,15 @@ public class EntriesREST extends AbstractREST {
|
|||||||
feedEntryStatusService.saveOrUpdate(status);
|
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