diff --git a/src/main/java/envoy/client/data/Chat.java b/src/main/java/envoy/client/data/Chat.java index c1b8f37..b1c2beb 100644 --- a/src/main/java/envoy/client/data/Chat.java +++ b/src/main/java/envoy/client/data/Chat.java @@ -115,14 +115,14 @@ public class Chat implements Serializable { } /** - * Increments the unreadMessagesAmount by 1 + * Increments the amount of unread messages. * * @since Envoy Client v0.1-beta */ public void incrementUnreadAmount() { unreadAmount++; } /** - * @return the amount of unreadMesages in this chat + * @return the amount of unread mesages in this chat * @since Envoy Client v0.1-beta */ public int getUnreadAmount() { return unreadAmount; } diff --git a/src/main/java/envoy/client/data/GroupChat.java b/src/main/java/envoy/client/data/GroupChat.java index 1bdbde3..76c0317 100644 --- a/src/main/java/envoy/client/data/GroupChat.java +++ b/src/main/java/envoy/client/data/GroupChat.java @@ -50,6 +50,7 @@ public class GroupChat extends Chat { } } } - super.unreadAmount = 0; + unreadAmount = 0; + } } diff --git a/src/main/java/envoy/client/ui/controller/ChatScene.java b/src/main/java/envoy/client/ui/controller/ChatScene.java index 703ec5d..a91436b 100644 --- a/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -166,7 +166,7 @@ public final class ChatScene implements Restorable { .stream() .filter(c -> c.getRecipient().getID() == e.getID()) .findAny() - .map(u -> u.getRecipient()) + .map(Chat::getRecipient) .ifPresent(u -> { ((User) u).setStatus(e.get()); Platform.runLater(userList::refresh); })); // Listen to contacts changes @@ -204,7 +204,7 @@ public final class ChatScene implements Restorable { this.client = client; this.writeProxy = writeProxy; - userList.setItems(FXCollections.observableList(localDB.getChats().stream().collect(Collectors.toList()))); + userList.setItems(FXCollections.observableList(localDB.getChats())); contactLabel.setText(localDB.getUser().getName()); MessageControl.setUser(localDB.getUser()); if (!client.isOnline()) updateInfoLabel("You are offline", "infoLabel-info"); @@ -462,8 +462,7 @@ public final class ChatScene implements Restorable { currentChat.insert(message); // Moving currentChat to the top Platform.runLater(() -> { - userList.getItems().remove(currentChat); - userList.getItems().add(0, currentChat); + userList.getItems().add(0, userList.getItems().remove(currentChat)); userList.getSelectionModel().select(0); localDB.getChats().remove(currentChat); localDB.getChats().add(0, currentChat);