Fix "infinite" amount of messages being displayed

Fixes #105
pull/103/head
delvh 2 years ago
parent cd8971b6b4
commit 241e5def03
Signed by: delvh
GPG Key ID: 3DECE05F6D9A647C
  1. 16
      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");
}