Refactored IsWriting to IsTyping

This commit is contained in:
delvh
2020-07-25 17:12:24 +02:00
parent e382a86623
commit 5a5e6e2086
6 changed files with 27 additions and 36 deletions

View File

@ -34,7 +34,7 @@ public class Chat implements Serializable {
protected int unreadAmount;
/**
* Stores the last time an {@link envoy.event.IsWriting} event has been sent.
* Stores the last time an {@link envoy.event.IsTyping} event has been sent.
*/
protected transient long lastWritingEvent;
@ -145,7 +145,7 @@ public class Chat implements Serializable {
public Contact getRecipient() { return recipient; }
/**
* @return the last known time a {@link envoy.event.IsWriting} event has been
* @return the last known time a {@link envoy.event.IsTyping} event has been
* sent
* @since Envoy Client v0.2-beta
*/

View File

@ -155,8 +155,8 @@ public class Client implements Closeable {
// Process group size changes
receiver.registerProcessor(GroupResize.class, evt -> { localDB.updateGroup(evt); eventBus.dispatch(evt); });
// Process IsWriting events
receiver.registerProcessor(IsWriting.class, eventBus::dispatch);
// Process IsTyping events
receiver.registerProcessor(IsTyping.class, eventBus::dispatch);
// Send event
eventBus.register(SendEvent.class, evt -> {

View File

@ -445,10 +445,10 @@ public final class ChatScene implements Restorable {
private void checkKeyCombination(KeyEvent e) {
// Checks whether the text is too long
messageTextUpdated();
// Sending an IsWriting event if none has been sent for
// IsWriting#millisecondsActive
if (client.isOnline() && currentChat.getLastWritingEvent() + IsWriting.millisecondsActive <= System.currentTimeMillis()) {
eventBus.dispatch(new SendEvent(new IsWriting(getChatID(), currentChat.getRecipient().getID(), client.getSender().getName())));
// Sending an IsTyping event if none has been sent for
// IsTyping#millisecondsActive
if (client.isOnline() && currentChat.getLastWritingEvent() + IsTyping.millisecondsActive <= System.currentTimeMillis()) {
eventBus.dispatch(new SendEvent(new IsTyping(getChatID(), currentChat.getRecipient().getID())));
currentChat.lastWritingEventWasNow();
}
// Automatic sending of messages via (ctrl +) enter