diff --git a/src/main/java/envoy/client/data/Chat.java b/src/main/java/envoy/client/data/Chat.java index b08fb25..c1b8f37 100644 --- a/src/main/java/envoy/client/data/Chat.java +++ b/src/main/java/envoy/client/data/Chat.java @@ -114,8 +114,17 @@ public class Chat implements Serializable { messages.add(0, message); } + /** + * Increments the unreadMessagesAmount by 1 + * + * @since Envoy Client v0.1-beta + */ public void incrementUnreadAmount() { unreadAmount++; } + /** + * @return the amount of unreadMesages in this chat + * @since Envoy Client v0.1-beta + */ public int getUnreadAmount() { return unreadAmount; } /** diff --git a/src/main/java/envoy/client/ui/listcell/ChatControl.java b/src/main/java/envoy/client/ui/listcell/ChatControl.java index 5a8b9bc..98294a7 100644 --- a/src/main/java/envoy/client/ui/listcell/ChatControl.java +++ b/src/main/java/envoy/client/ui/listcell/ChatControl.java @@ -22,10 +22,10 @@ import envoy.data.User; public class ChatControl extends HBox { /** - * @param contact the contact that should be formatted + * @param chat the chat to display * @since Envoy Client v0.1-beta */ - public ChatControl(Chat chat, int unreadMessagesAmount) { + public ChatControl(Chat chat) { // Container with contact name final var vBox = new VBox(); final var nameLabel = new Label(chat.getRecipient().getName()); @@ -41,11 +41,11 @@ public class ChatControl extends HBox { vBox.getChildren().add(new Label(((Group) chat.getRecipient()).getContacts().size() + " members")); getChildren().add(vBox); - if (unreadMessagesAmount != 0) { + if (chat.getUnreadAmount() != 0) { Region spacing = new Region(); setHgrow(spacing, Priority.ALWAYS); getChildren().add(spacing); - final var unreadMessagesLabel = new Label("" + unreadMessagesAmount); + final var unreadMessagesLabel = new Label(Integer.toString(chat.getUnreadAmount())); unreadMessagesLabel.setMinSize(15, 15); var vBox2 = new VBox(); vBox2.setAlignment(Pos.CENTER_RIGHT); diff --git a/src/main/java/envoy/client/ui/listcell/ContactListCellFactory.java b/src/main/java/envoy/client/ui/listcell/ContactListCellFactory.java index acf116f..3d34aa9 100644 --- a/src/main/java/envoy/client/ui/listcell/ContactListCellFactory.java +++ b/src/main/java/envoy/client/ui/listcell/ContactListCellFactory.java @@ -36,7 +36,7 @@ public class ContactListCellFactory extends ListCell { setText(null); setGraphic(null); } else { - final var control = new ChatControl(chat, chat.getUnreadAmount()); + final var control = new ChatControl(chat); prefWidthProperty().bind(listView.widthProperty().subtract(40)); setGraphic(control); }