Add Ability to Delete Messages Locally #70
@ -74,7 +74,7 @@ public class Chat implements Serializable {
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof Chat)) return false;
|
||||
final Chat other = (Chat) obj;
|
||||
final var other = (Chat) obj;
|
||||
return Objects.equals(recipient, other.recipient);
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ public class Chat implements Serializable {
|
||||
*/
|
||||
public void read(WriteProxy writeProxy) {
|
||||
for (int i = messages.size() - 1; i >= 0; --i) {
|
||||
final Message m = messages.get(i);
|
||||
final var m = messages.get(i);
|
||||
if (m.getSenderID() == recipient.getID()) if (m.getStatus() == MessageStatus.READ) break;
|
||||
else {
|
||||
m.setStatus(MessageStatus.READ);
|
||||
@ -122,10 +122,10 @@ public class Chat implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the message with the given ID
|
||||
* Removes the message with the given ID.
|
||||
delvh marked this conversation as resolved
Outdated
|
||||
*
|
||||
* @param messageID the ID of the message to remove
|
||||
* @return whether any message has been removed
|
||||
* @return whether the message has been found and removed
|
||||
delvh marked this conversation as resolved
Outdated
kske
commented
You might consider changing this to "whether the message has been removed", as "any" implies the removal of random messages. You might consider changing this to "whether the message has been removed", as "any" implies the removal of random messages.
delvh
commented
While I do see your point, I'd also point out that the current tag is pretty much equivalent to While I do see your point, I'd also point out that the current tag is pretty much equivalent to `Collection.removeIf`, which only states that it returns true if any element was removed.
But okay, I can change it.
kske
commented
That's true, because That's true, because `Collection.removeIf` acts on arbitrary collections, while a list of messages has the property that the message IDs are unique.
|
||||
* @since Envoy Client v0.3-beta
|
||||
*/
|
||||
public boolean remove(long messageID) { return messages.removeIf(m -> m.getID() == messageID); }
|
||||
|
@ -275,12 +275,12 @@ public final class LocalDB implements EventListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the message with the given ID, if any is present.
|
||||
* Deletes the message with the given ID, if present.
|
||||
delvh marked this conversation as resolved
Outdated
kske
commented
Again, consider rewording this to "... if present", as there is no such thing as multiple messages with the same ID. Again, consider rewording this to "... if present", as there is no such thing as multiple messages with the same ID.
|
||||
*
|
||||
* @param message the event that was
|
||||
* @since Envoy Client v0.3-beta
|
||||
*/
|
||||
@Event()
|
||||
@Event
|
||||
delvh marked this conversation as resolved
Outdated
kske
commented
The parentheses after The parentheses after `@Event` are unnecessary here.
|
||||
private void onMessageDeletion(MessageDeletion message) {
|
||||
Platform.runLater(() -> {
|
||||
|
||||
|
@ -3,7 +3,7 @@ package envoy.client.event;
|
||||
import envoy.event.Event;
|
||||
|
||||
/**
|
||||
* Conveys the deletion of a message between clients and server.
|
||||
* Conveys the deletion of a message.
|
||||
delvh marked this conversation as resolved
Outdated
kske
commented
This does not make sense as this is a client-sided event. This does not make sense as this is a client-sided event.
delvh
commented
That's an artifact from when it was an Event in Common. That's an artifact from when it was an Event in Common.
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Common v0.3-beta
|
||||
|
@ -772,7 +772,7 @@ public final class ChatScene implements EventListener, Restorable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the current message selection
|
||||
* Clears the current message selection.
|
||||
delvh marked this conversation as resolved
Outdated
kske
commented
Append a dot to the end of the sentence. Append a dot to the end of the sentence.
|
||||
*
|
||||
* @since Envoy Client v0.3-beta
|
||||
*/
|
||||
|
@ -47,7 +47,7 @@ public class MessageUtil {
|
||||
public static void deleteMessage(Message message) {
|
||||
final var messageDeletionEvent = new MessageDeletion(message.getID());
|
||||
final var controller = Context.getInstance().getSceneContext().getController();
|
||||
if (controller.getClass().equals(ChatScene.class)) ((ChatScene) controller).clearMessageSelection();
|
||||
if (controller instanceof ChatScene) ((ChatScene) controller).clearMessageSelection();
|
||||
delvh marked this conversation as resolved
Outdated
kske
commented
You can use You can use `instanceof` here, which is faster and more readable. Also, consider to comment this line.
|
||||
|
||||
// Removing the message locally
|
||||
EventBus.getInstance().dispatch(messageDeletionEvent);
|
||||
@ -62,7 +62,7 @@ public class MessageUtil {
|
||||
* @param message the message to forward
|
||||
* @since Envoy Client v0.3-beta
|
||||
*/
|
||||
public static void forwardMessage(Message message) { logger.log(Level.FINEST, "message forwarding was requested for " + message); }
|
||||
public static void forwardMessage(Message message) { logger.log(Level.FINEST, "Message forwarding was requested for " + message); }
|
||||
delvh marked this conversation as resolved
Outdated
kske
commented
Why are we adding context menu actions and methods that are not implemented on a branch that has nothing to do with it? By the way, most logger statements start with a capital letter, so if you decide to keep the method, please consider that. Why are we adding context menu actions and methods that are not implemented on a branch that has nothing to do with it?
By the way, most logger statements start with a capital letter, so if you decide to keep the method, please consider that.
|
||||
|
||||
/**
|
||||
* Quotes the given message.
|
||||
@ -71,7 +71,7 @@ public class MessageUtil {
|
||||
* @param message the message to quote
|
||||
* @since Envoy Client v0.3-beta
|
||||
*/
|
||||
public static void quoteMessage(Message message) { logger.log(Level.FINEST, "message quotation was requested for " + message); }
|
||||
public static void quoteMessage(Message message) { logger.log(Level.FINEST, "Message quotation was requested for " + message); }
|
||||
|
||||
/**
|
||||
* Saves the attachment of a message, if present.
|
||||
@ -81,7 +81,7 @@ public class MessageUtil {
|
||||
* @since Envoy Client v0.3-beta
|
||||
*/
|
||||
public static void saveAttachment(Message message) {
|
||||
if (!message.hasAttachment()) throw new IllegalStateException("Cannot save a non-existing attachment");
|
||||
if (!message.hasAttachment()) throw new IllegalArgumentException("Cannot save a non-existing attachment");
|
||||
delvh marked this conversation as resolved
Outdated
kske
commented
This would rather be an This would rather be an `IllegalArgumentException`.
|
||||
File file;
|
||||
final var fileName = message.getAttachment().getName();
|
||||
final var downloadLocation = Settings.getInstance().getDownloadLocation();
|
||||
|
@ -9,7 +9,7 @@ import envoy.data.User.UserStatus;
|
||||
import envoy.server.net.ConnectionManager;
|
||||
|
||||
/**
|
||||
* Contains operations used for data retrieval.
|
||||
* Contains operations used for persistence.
|
||||
delvh marked this conversation as resolved
Outdated
kske
commented
As its not only retrieval, but also storage, maybe change this to "... for persistence." As its not only retrieval, but also storage, maybe change this to "... for persistence."
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @author Maximilian Käfer
|
||||
|
Append a dot to the end of the sentence.