aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src
diff options
context:
space:
mode:
Diffstat (limited to 'juick-www/src')
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java24
-rw-r--r--juick-www/src/main/resources/templates/views/partial/message.html8
2 files changed, 27 insertions, 5 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);
diff --git a/juick-www/src/main/resources/templates/views/partial/message.html b/juick-www/src/main/resources/templates/views/partial/message.html
index 9e3ede6c..2e3667f2 100644
--- a/juick-www/src/main/resources/templates/views/partial/message.html
+++ b/juick-www/src/main/resources/templates/views/partial/message.html
@@ -54,7 +54,13 @@
<a href="/{{ msg.mid }}" class="a-comment msg-button">
<span class="msg-button-icon">
<i data-icon="ei-comment" data-size="s"></i>
- {% if msg.Replies > 0 %}&nbsp;{{ msg.Replies }}{% endif %}
+ {% if msg.Replies > 0 %}&nbsp;
+ {% if msg.unread %}
+ <span class="badge">{{ msg.Replies }}</span>
+ {% else %}
+ {{ msg.Replies }}
+ {% endif %}
+ {% endif %}
</span>
<span>&nbsp;{{ i18n("messages","message.comment") }}</span>
</a>