From 53901d51096d6830490055e9be69586e960c6a09 Mon Sep 17 00:00:00 2001 From: delvh Date: Sat, 25 Jul 2020 16:51:46 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: CyB3RC0nN0R --- .../src/main/java/envoy/client/data/Chat.java | 23 +++++-------------- .../envoy/client/ui/listcell/ChatControl.java | 2 +- .../src/main/java/envoy/event/IsWriting.java | 7 +++--- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/client/src/main/java/envoy/client/data/Chat.java b/client/src/main/java/envoy/client/data/Chat.java index d35993a..fd87050 100644 --- a/client/src/main/java/envoy/client/data/Chat.java +++ b/client/src/main/java/envoy/client/data/Chat.java @@ -7,9 +7,10 @@ import java.util.List; import java.util.Objects; import envoy.client.net.WriteProxy; -import envoy.data.*; +import envoy.data.Contact; +import envoy.data.Message; import envoy.data.Message.MessageStatus; -import envoy.event.IsWriting; +import envoy.data.User; import envoy.event.MessageStatusChange; /** @@ -33,8 +34,7 @@ public class Chat implements Serializable { protected int unreadAmount; /** - * Counts the milliseconds until another {@link IsWriting} event will be sent if - * something is typed. + * Stores the last time an {@link envoy.event.IsWriting} event has been sent. */ protected transient long lastWritingEvent; @@ -145,19 +145,8 @@ public class Chat implements Serializable { public Contact getRecipient() { return recipient; } /** - * @return whether this {@link Chat} points at a {@link User} - * @since Envoy Client v0.1-beta - */ - public boolean isUserChat() { return recipient instanceof User; } - - /** - * @return whether this {@link Chat} points at a {@link Group} - * @since Envoy Client v0.1-beta - */ - public boolean isGroupChat() { return recipient instanceof Group; } - - /** - * @return the last known time a {@link IsWriting} event has been sent + * @return the last known time a {@link envoy.event.IsWriting} event has been + * sent * @since Envoy Client v0.2-beta */ public long getLastWritingEvent() { return lastWritingEvent; } diff --git a/client/src/main/java/envoy/client/ui/listcell/ChatControl.java b/client/src/main/java/envoy/client/ui/listcell/ChatControl.java index 9e20eb7..e19cd54 100644 --- a/client/src/main/java/envoy/client/ui/listcell/ChatControl.java +++ b/client/src/main/java/envoy/client/ui/listcell/ChatControl.java @@ -31,7 +31,7 @@ public class ChatControl extends HBox { // Unread messages if (chat.getUnreadAmount() != 0) { - final Region spacing = new Region(); + final var spacing = new Region(); setHgrow(spacing, Priority.ALWAYS); getChildren().add(spacing); final var unreadMessagesLabel = new Label(Integer.toString(chat.getUnreadAmount())); diff --git a/common/src/main/java/envoy/event/IsWriting.java b/common/src/main/java/envoy/event/IsWriting.java index 7efe32b..88b62d2 100644 --- a/common/src/main/java/envoy/event/IsWriting.java +++ b/common/src/main/java/envoy/event/IsWriting.java @@ -21,6 +21,8 @@ public class IsWriting extends Event { /** * The number of milliseconds that this event will be active.
* Currently set to 3.5 seconds. + * + * @since Envoy Common v0.2-beta */ public static final int millisecondsActive = 3500; @@ -30,7 +32,7 @@ public class IsWriting extends Event { * @param sourceID the id of the originator * @param displayName the name of the originator * @param destinationID the id of the contact the user wrote to - * @since Envoy Client v0.2-beta + * @since Envoy Common v0.2-beta */ public IsWriting(Long sourceID, long destinationID, String displayName) { super(sourceID); @@ -40,7 +42,7 @@ public class IsWriting extends Event { /** * @return the id of the contact in whose chat the user wrote something - * @since Envoy Client v0.2-beta + * @since Envoy Common v0.2-beta */ public long getDestinationID() { return destinationID; } @@ -49,5 +51,4 @@ public class IsWriting extends Event { * @since Envoy Common v0.2-beta */ public String getDisplayName() { return displayName; } - }