Apply suggestions from @CyB3RC0nN0R's code review

This commit is contained in:
delvh 2020-06-25 11:17:25 +02:00
parent c2b4ddaea9
commit 374f23c3c3
2 changed files with 10 additions and 12 deletions

View File

@ -31,7 +31,7 @@ public class MessageListCell extends ListCell<Message> {
private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm");
private static Map<MessageStatus, Image> statusImages;
private static User user;
private static User client;
static {
try {
@ -55,7 +55,7 @@ public class MessageListCell extends ListCell<Message> {
setGraphic(null);
} else {
final var cell = new VBox(new Label(dateFormat.format(message.getCreationDate())), new Label(message.getText()));
if (message.getRecipientID() == user.getID()) {
if (message.getRecipientID() == client.getID()) {
cell.getChildren().add(new Label("", new ImageView(statusImages.get(message.getStatus()))));
cell.getStyleClass().add("own-message");
} else cell.getStyleClass().add("received-message");
@ -65,8 +65,8 @@ public class MessageListCell extends ListCell<Message> {
}
/**
* @param user the user to set
* @param client the user who chats with another person
* @since Envoy Client v0.1-beta
*/
public static void setUser(User user) { MessageListCell.user = user; }
public static void setUser(User client) { MessageListCell.client = client; }
}

View File

@ -342,14 +342,12 @@ public final class ChatScene {
@FXML
private void copyAndPostMessage() {
try {
final var messageText = messageTextArea.getText();
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(messageText), null);
postMessage();
messageTextArea.setText(messageText);
updateRemainingCharsLabel();
postButton.setDisable(messageText.isBlank());
} catch (final NullPointerException e) {}
final var messageText = messageTextArea.getText();
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(messageText), null);
postMessage();
messageTextArea.setText(messageText);
updateRemainingCharsLabel();
postButton.setDisable(messageText.isBlank());
}
}