diff options
author | Vitaly Takmazov | 2018-04-12 12:16:47 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-04-12 12:16:47 +0300 |
commit | e24f7a7ce9eb765aa2f581defbe20433a647700d (patch) | |
tree | 7b2ecf44396504df8c577a18c9347c563a73fb0d /juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java | |
parent | b23f3b9182d78dfabb37b6a1c21d060a365b2574 (diff) |
www: badge for unread thread
Diffstat (limited to 'juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java')
-rw-r--r-- | juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java b/juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java index 80be605f..3c3c5d43 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java +++ b/juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java @@ -67,7 +67,6 @@ public class MessagesWWW { private CrosspostService crosspostService; void fillUserModel(ModelMap model, com.juick.User user, com.juick.User visitor) { - user.setUnreadCount(messagesService.getUnread(visitor).size()); model.addAttribute("user", user); model.addAttribute("isSubscribed", userService.isSubscribed(visitor.getUid(), user.getUid())); model.addAttribute("isInBL", userService.isInBL(visitor.getUid(), user.getUid())); @@ -156,9 +155,14 @@ public class MessagesWWW { if (visitor.getUid() != 0) { fillUserModel(model, visitor, visitor); + List<Integer> unread = messagesService.getUnread(visitor); + visitor.setUnreadCount(unread.size()); List<Integer> blUIDs = userService.checkBL(visitor.getUid(), msgs.stream().map(m -> m.getUser().getUid()).collect(Collectors.toList())); - msgs.forEach(m -> m.ReadOnly |= blUIDs.contains(m.getUser().getUid())); + msgs.forEach(m -> { + m.ReadOnly |= blUIDs.contains(m.getUser().getUid()); + m.setUnread(unread.contains(m.getMid())); + }); } model.addAttribute("msgs", msgs); model.addAttribute("tags", tagService.getPopularTags()); @@ -266,9 +270,14 @@ public class MessagesWWW { List<com.juick.Message> msgs = messagesService.getMessages(mids); if (visitor.getUid() != 0) { + List<Integer> unread = messagesService.getUnread(visitor); + visitor.setUnreadCount(unread.size()); List<Integer> blUIDs = userService.checkBL(visitor.getUid(), msgs.stream().map(m -> m.getUser().getUid()).collect(Collectors.toList())); - msgs.forEach(m -> m.ReadOnly |= blUIDs.contains(m.getUser().getUid())); + msgs.forEach(m -> { + m.ReadOnly |= blUIDs.contains(m.getUser().getUid()); + m.setUnread(unread.contains(m.getMid())); + }); } model.addAttribute("msgs", msgs); model.addAttribute("headers", head); @@ -396,11 +405,16 @@ public class MessagesWWW { List<Integer> mids = messagesService.getTag(paramTag.TID, visitor_uid, before, (visitor_uid == 0) ? 40 : 20); List<com.juick.Message> msgs = messagesService.getMessages(mids); if (visitor.getUid() != 0) { + List<Integer> unread = messagesService.getUnread(visitor); + visitor.setUnreadCount(unread.size()); List<Integer> blUIDs = userService.checkBL( visitor.getUid(), msgs.stream().map(m -> m.getUser().getUid()).collect(Collectors.toList()) ); - msgs.forEach(m -> m.ReadOnly |= blUIDs.contains(m.getUser().getUid())); + msgs.forEach(m -> { + m.ReadOnly |= blUIDs.contains(m.getUser().getUid()); + m.setUnread(unread.contains(m.getMid())); + }); fillUserModel(model, visitor, visitor); } @@ -494,6 +508,8 @@ public class MessagesWWW { } msg.VisitorCanComment = visitor.getUid() > 0; if (visitor.getUid() > 0) { + List<Integer> unread = messagesService.getUnread(visitor); + visitor.setUnreadCount(unread.size()); boolean isMsgAuthor = visitor.getUid() == msg.getUser().getUid(); boolean isInBL = userService.isInBLAny(msg.getUser().getUid(), visitor.getUid()); msg.VisitorCanComment = isMsgAuthor || !(msg.ReadOnly || isInBL); |