From 241e5def03cc7881af33870849516a07dde467d6 Mon Sep 17 00:00:00 2001 From: delvh Date: Thu, 22 Oct 2020 16:15:34 +0200 Subject: [PATCH] Fix "infinite" amount of messages being displayed Fixes #105 --- .../envoy/client/ui/control/ChatControl.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/client/src/main/java/envoy/client/ui/control/ChatControl.java b/client/src/main/java/envoy/client/ui/control/ChatControl.java index de50085..6c45d44 100644 --- a/client/src/main/java/envoy/client/ui/control/ChatControl.java +++ b/client/src/main/java/envoy/client/ui/control/ChatControl.java @@ -32,12 +32,12 @@ public final class ChatControl extends HBox { setPadding(new Insets(0, 0, 3, 0)); // Profile picture - final var contactProfilePic = + var contactProfilePic = new ProfilePicImageView(chat instanceof GroupChat ? groupIcon : userIcon, 32); getChildren().add(contactProfilePic); // Spacing - final var leftSpacing = new Region(); + var leftSpacing = new Region(); leftSpacing.setPrefSize(8, 0); leftSpacing.setMinSize(8, 0); leftSpacing.setMaxSize(8, 0); @@ -48,17 +48,15 @@ public final class ChatControl extends HBox { // Unread messages if (chat.getUnreadAmount() != 0) { - final var spacing = new Region(); + var spacing = new Region(); setHgrow(spacing, Priority.ALWAYS); getChildren().add(spacing); - final var unreadMessagesLabel = new Label(Integer.toString(chat.getUnreadAmount())); + var unreadMessagesLabel = new Label( + chat.getUnreadAmount() > 99 ? "99+" : String.valueOf(chat.getUnreadAmount())); unreadMessagesLabel.setMinSize(15, 15); - final var vbox = new VBox(); - vbox.setAlignment(Pos.CENTER_RIGHT); - unreadMessagesLabel.setAlignment(Pos.CENTER); + unreadMessagesLabel.setAlignment(Pos.CENTER_RIGHT); unreadMessagesLabel.getStyleClass().add("unread-messages-amount"); - vbox.getChildren().add(unreadMessagesLabel); - getChildren().add(vbox); + getChildren().add(unreadMessagesLabel); } getStyleClass().add("list-element"); }