Apply suggestions from code review

Co-authored-by: CyB3RC0nN0R <CyB3RC0nN0R@users.noreply.github.com>
This commit is contained in:
DieGurke 2020-07-12 16:27:20 +02:00 committed by GitHub
parent 52766a37ce
commit fb4c58f9ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 7 deletions

View File

@ -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 * @since Envoy Client v0.1-beta
*/ */
public void incrementUnreadAmount() { unreadAmount++; } 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 * @since Envoy Client v0.1-beta
*/ */
public int getUnreadAmount() { return unreadAmount; } public int getUnreadAmount() { return unreadAmount; }

View File

@ -50,6 +50,7 @@ public class GroupChat extends Chat {
} }
} }
} }
super.unreadAmount = 0; unreadAmount = 0;
} }
} }

View File

@ -166,7 +166,7 @@ public final class ChatScene implements Restorable {
.stream() .stream()
.filter(c -> c.getRecipient().getID() == e.getID()) .filter(c -> c.getRecipient().getID() == e.getID())
.findAny() .findAny()
.map(u -> u.getRecipient()) .map(Chat::getRecipient)
.ifPresent(u -> { ((User) u).setStatus(e.get()); Platform.runLater(userList::refresh); })); .ifPresent(u -> { ((User) u).setStatus(e.get()); Platform.runLater(userList::refresh); }));
// Listen to contacts changes // Listen to contacts changes
@ -204,7 +204,7 @@ public final class ChatScene implements Restorable {
this.client = client; this.client = client;
this.writeProxy = writeProxy; this.writeProxy = writeProxy;
userList.setItems(FXCollections.observableList(localDB.getChats().stream().collect(Collectors.toList()))); userList.setItems(FXCollections.observableList(localDB.getChats()));
contactLabel.setText(localDB.getUser().getName()); contactLabel.setText(localDB.getUser().getName());
MessageControl.setUser(localDB.getUser()); MessageControl.setUser(localDB.getUser());
if (!client.isOnline()) updateInfoLabel("You are offline", "infoLabel-info"); if (!client.isOnline()) updateInfoLabel("You are offline", "infoLabel-info");
@ -462,8 +462,7 @@ public final class ChatScene implements Restorable {
currentChat.insert(message); currentChat.insert(message);
// Moving currentChat to the top // Moving currentChat to the top
Platform.runLater(() -> { Platform.runLater(() -> {
userList.getItems().remove(currentChat); userList.getItems().add(0, userList.getItems().remove(currentChat));
userList.getItems().add(0, currentChat);
userList.getSelectionModel().select(0); userList.getSelectionModel().select(0);
localDB.getChats().remove(currentChat); localDB.getChats().remove(currentChat);
localDB.getChats().add(0, currentChat); localDB.getChats().add(0, currentChat);