Apply suggestions from @CyB3RC0nN0R's code review

This commit is contained in:
delvh 2020-06-25 11:17:25 +02:00
parent d80bc39221
commit bbd5f61486
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 final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm");
private static Map<MessageStatus, Image> statusImages; private static Map<MessageStatus, Image> statusImages;
private static User user; private static User client;
static { static {
try { try {
@ -55,7 +55,7 @@ public class MessageListCell extends ListCell<Message> {
setGraphic(null); setGraphic(null);
} else { } else {
final var cell = new VBox(new Label(dateFormat.format(message.getCreationDate())), new Label(message.getText())); 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.getChildren().add(new Label("", new ImageView(statusImages.get(message.getStatus()))));
cell.getStyleClass().add("own-message"); cell.getStyleClass().add("own-message");
} else cell.getStyleClass().add("received-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 * @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 @FXML
private void copyAndPostMessage() { private void copyAndPostMessage() {
try {
final var messageText = messageTextArea.getText(); final var messageText = messageTextArea.getText();
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(messageText), null); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(messageText), null);
postMessage(); postMessage();
messageTextArea.setText(messageText); messageTextArea.setText(messageText);
updateRemainingCharsLabel(); updateRemainingCharsLabel();
postButton.setDisable(messageText.isBlank()); postButton.setDisable(messageText.isBlank());
} catch (final NullPointerException e) {}
} }
} }