Fold client receivers into event handlers
This commit is contained in:
@ -173,26 +173,6 @@ public final class LocalDB implements EventListener {
|
||||
}, 2000, ClientConfig.getInstance().getLocalDBSaveInterval() * 60000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a contact name change if the corresponding contact is present.
|
||||
*
|
||||
* @param event the {@link NameChange} to process
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public void replaceContactName(NameChange event) {
|
||||
chats.stream().map(Chat::getRecipient).filter(c -> c.getID() == event.getID()).findAny().ifPresent(c -> c.setName(event.get()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a group resize operation if the corresponding group is present.
|
||||
*
|
||||
* @param event the {@link GroupResize} to process
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public void updateGroup(GroupResize event) {
|
||||
getChat(event.getGroupID()).map(Chat::getRecipient).map(Group.class::cast).ifPresent(event::apply);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores all users. If the client user is specified, their chats will be stored
|
||||
* as well. The message id generator will also be saved if present.
|
||||
@ -238,6 +218,14 @@ public final class LocalDB implements EventListener {
|
||||
if (evt.get().ordinal() < MessageStatus.RECEIVED.ordinal()) logger.warning("Received invalid " + evt);
|
||||
}
|
||||
|
||||
@Event(priority = 150)
|
||||
private void onGroupResize(GroupResize evt) { getChat(evt.getGroupID()).map(Chat::getRecipient).map(Group.class::cast).ifPresent(evt::apply); }
|
||||
|
||||
@Event(priority = 150)
|
||||
private void onNameChange(NameChange evt) {
|
||||
chats.stream().map(Chat::getRecipient).filter(c -> c.getID() == evt.getID()).findAny().ifPresent(c -> c.setName(evt.get()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a new authentication token.
|
||||
*
|
||||
@ -308,6 +296,7 @@ public final class LocalDB implements EventListener {
|
||||
* @param idGenerator the message ID generator to set
|
||||
* @since Envoy Client v0.3-alpha
|
||||
*/
|
||||
@Event(priority = 150)
|
||||
public void setIDGenerator(IDGenerator idGenerator) { this.idGenerator = idGenerator; }
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user