implemented GUI update on cloning items
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -49,11 +49,11 @@ public class MessageApi extends BaseHandler{
|
||||
if (++counter > 300) counter = sendBeacon(addr,stream);
|
||||
} else {
|
||||
var event = eventQueue.removeFirst();
|
||||
//if (event.isIntendedFor(user.get())) {
|
||||
if (event.isIntendedFor(user.get())) {
|
||||
LOG.log(DEBUG, "sending event to {0}", addr);
|
||||
sendEvent(stream, event);
|
||||
counter = 0;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG.log(INFO,"{0} disconnected from event stream.",addr);
|
||||
|
||||
@@ -12,7 +12,7 @@ public class MessageBus {
|
||||
|
||||
private MessageBus(){}
|
||||
|
||||
public void dispatch(Event event){
|
||||
public void dispatch(Event<?> event){
|
||||
new Thread(() -> { // TODO: use thread pool
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package de.srsoftware.umbrella.messagebus.events;
|
||||
|
||||
import de.srsoftware.umbrella.core.ModuleRegistry;
|
||||
import de.srsoftware.umbrella.core.api.Owner;
|
||||
import de.srsoftware.umbrella.core.constants.Field;
|
||||
import de.srsoftware.umbrella.core.model.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static de.srsoftware.umbrella.core.constants.Field.*;
|
||||
import static de.srsoftware.umbrella.core.model.Translatable.t;
|
||||
|
||||
public class ItemEvent extends Event<Item>{
|
||||
public ItemEvent(UmbrellaUser initiator, String module, Item item, EventType type) {
|
||||
super(initiator, module, item, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<UmbrellaUser> audience() {
|
||||
Owner owner = payload().location().resolve().owner().resolve();
|
||||
if (owner instanceof UmbrellaUser user) return List.of(user);
|
||||
if (owner instanceof Company company) return ModuleRegistry.companyService().getMembers(company.id());
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Translatable describe() {
|
||||
return switch (eventType()){
|
||||
case CREATE -> describeCreate();
|
||||
case null, default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
private Translatable describeCreate() {
|
||||
var loc = payload().location().resolve().name();
|
||||
return t("{user} added \"{item}\" to \"{location}\"", USER,initiator().name(), ITEM, payload().name(), LOCATION, loc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Translatable subject() {
|
||||
var loc = payload().location().resolve().name();
|
||||
return switch (eventType()){
|
||||
case CREATE -> t("A new item has been added to \"{location}\":",LOCATION,loc);
|
||||
case null, default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user