fix the wait window while core is loading

This commit is contained in:
Zlatin Balevsky
2020-05-04 08:15:25 +01:00
parent 3de4c65d2f
commit fb59d1ca0c
3 changed files with 17 additions and 3 deletions

View File

@ -8,9 +8,11 @@ import net.i2p.router.RouterContext;
class MWStarter extends Thread {
private final Core core;
private final MuWireClient client;
MWStarter(Core core) {
MWStarter(Core core, MuWireClient client) {
this.core = core;
this.client = client;
setName("MW starter");
setDaemon(true);
}
@ -27,6 +29,7 @@ class MWStarter extends Thread {
}
core.startServices();
client.setCoreLoaded();
core.getEventBus().publish(new UILoadedEvent());
}
}

View File

@ -62,6 +62,7 @@ public class MuWireClient {
private final File mwProps;
private volatile Core core;
private volatile boolean coreLoaded;
public MuWireClient(RouterContext ctx, String home, String version, ServletContext servletContext) {
this.ctx = ctx;
@ -94,7 +95,7 @@ public class MuWireClient {
MuWireSettings settings = new MuWireSettings(props);
Core core = new Core(settings, new File(home), version);
setCore(core);
MWStarter starter = new MWStarter(core);
MWStarter starter = new MWStarter(core, this);
starter.start();
}
@ -106,6 +107,8 @@ public class MuWireClient {
this.core = null;
}
public boolean needsMWInit() {
return !mwProps.exists();
}
@ -202,6 +205,14 @@ public class MuWireClient {
return home;
}
void setCoreLoaded() {
coreLoaded = true;
}
public boolean isCoreLoaded() {
return coreLoaded;
}
public void onAllFilesLoadedEvent(AllFilesLoadedEvent e) {
core.getMuOptions().getTrustSubscriptions().forEach( p -> {

View File

@ -42,7 +42,7 @@ public class MuWireServlet extends HttpServlet {
if (client.needsMWInit()) {
resp.sendRedirect("/MuWire/MuWire");
} else {
if (client.getCore() == null) {
if (!client.isCoreLoaded()) {
resp.setContentType("text/html");
resp.setCharacterEncoding("UTF-8");
resp.getWriter().println("<html><head>\n" +