mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
persist read status instead of unread status
This commit is contained in:
@@ -19,8 +19,8 @@ public class FeedEntryService {
|
||||
|
||||
@Inject
|
||||
FeedSubscriptionDAO feedSubscriptionDAO;
|
||||
|
||||
@Inject
|
||||
|
||||
@Inject
|
||||
FeedEntryDAO feedEntryDAO;
|
||||
|
||||
public void markEntry(User user, Long entryId, Long subscriptionId,
|
||||
@@ -38,24 +38,8 @@ public class FeedEntryService {
|
||||
|
||||
FeedEntryStatus status = feedEntryStatusDAO.getStatus(sub, entry);
|
||||
|
||||
if (read) {
|
||||
if (status.getId() != null) {
|
||||
if (status.isStarred()) {
|
||||
status.setRead(true);
|
||||
feedEntryStatusDAO.saveOrUpdate(status);
|
||||
} else {
|
||||
feedEntryStatusDAO.delete(status);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (status.getId() == null) {
|
||||
status = new FeedEntryStatus(user, sub, entry);
|
||||
status.setSubscription(sub);
|
||||
}
|
||||
status.setRead(false);
|
||||
feedEntryStatusDAO.saveOrUpdate(status);
|
||||
}
|
||||
|
||||
status.setRead(read);
|
||||
feedEntryStatusDAO.saveOrUpdate(status);
|
||||
}
|
||||
|
||||
public void starEntry(User user, Long entryId, Long subscriptionId,
|
||||
@@ -74,23 +58,8 @@ public class FeedEntryService {
|
||||
|
||||
FeedEntryStatus status = feedEntryStatusDAO.getStatus(sub, entry);
|
||||
|
||||
if (!starred) {
|
||||
if (status.getId() != null) {
|
||||
if (!status.isRead()) {
|
||||
status.setStarred(false);
|
||||
feedEntryStatusDAO.saveOrUpdate(status);
|
||||
} else {
|
||||
feedEntryStatusDAO.delete(status);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (status.getId() == null) {
|
||||
status = new FeedEntryStatus(user, sub, entry);
|
||||
status.setSubscription(sub);
|
||||
status.setRead(true);
|
||||
}
|
||||
status.setStarred(true);
|
||||
feedEntryStatusDAO.saveOrUpdate(status);
|
||||
}
|
||||
status.setStarred(starred);
|
||||
feedEntryStatusDAO.saveOrUpdate(status);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,8 @@ public class FeedSubscriptionService {
|
||||
Map<Long, Long> map = cache.getUnreadCounts(user);
|
||||
if (map == null) {
|
||||
log.debug("unread count cache miss for {}", Models.getId(user));
|
||||
map = feedEntryStatusDAO.getUnreadCount(user);
|
||||
List<FeedSubscription> subs = feedSubscriptionDAO.findAll(user);
|
||||
map = feedEntryStatusDAO.getUnreadCount(subs);
|
||||
cache.setUnreadCounts(user, map);
|
||||
}
|
||||
return map;
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.commafeed.backend.feeds.FeedUtils;
|
||||
import com.commafeed.backend.model.Feed;
|
||||
import com.commafeed.backend.model.FeedEntry;
|
||||
import com.commafeed.backend.model.FeedEntryContent;
|
||||
import com.commafeed.backend.model.FeedEntryStatus;
|
||||
import com.commafeed.backend.model.FeedFeedEntry;
|
||||
import com.commafeed.backend.model.FeedSubscription;
|
||||
import com.commafeed.backend.model.User;
|
||||
@@ -72,20 +71,13 @@ public class FeedUpdateService {
|
||||
}
|
||||
|
||||
if (update != null) {
|
||||
List<FeedEntryStatus> statusUpdateList = Lists.newArrayList();
|
||||
List<User> users = Lists.newArrayList();
|
||||
for (FeedSubscription sub : subscriptions) {
|
||||
User user = sub.getUser();
|
||||
FeedEntryStatus status = new FeedEntryStatus(user, sub, update);
|
||||
status.setSubscription(sub);
|
||||
statusUpdateList.add(status);
|
||||
users.add(user);
|
||||
users.add(sub.getUser());
|
||||
}
|
||||
cache.invalidateUserData(users.toArray(new User[0]));
|
||||
feedEntryDAO.saveOrUpdate(update);
|
||||
feedEntryStatusDAO.saveOrUpdate(statusUpdateList);
|
||||
em.persist(ffe);
|
||||
metricsBean.entryUpdated(statusUpdateList.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user