aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--juick-common/src/main/java/com/juick/Message.java9
-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
3 files changed, 36 insertions, 5 deletions
diff --git a/juick-common/src/main/java/com/juick/Message.java b/juick-common/src/main/java/com/juick/Message.java
index 155c1747..8aa8219e 100644
--- a/juick-common/src/main/java/com/juick/Message.java
+++ b/juick-common/src/main/java/com/juick/Message.java
@@ -43,6 +43,7 @@ public class Message implements Comparable {
private final List<Tag> tags;
private Instant ts;
private Instant updated;
+ private boolean unread;
@XmlTransient
@JsonIgnore
public int TimeAgo = 0;
@@ -291,4 +292,12 @@ public class Message implements Comparable {
public void setUpdated(Instant updated) {
this.updated = updated;
}
+
+ public boolean isUnread() {
+ return unread;
+ }
+
+ public void setUnread(boolean unread) {
+ this.unread = unread;
+ }
}
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>