Don't render anything until gateway connection
This commit is contained in:
parent
71f3773488
commit
fcf25320cb
2 changed files with 26 additions and 13 deletions
|
@ -60,6 +60,7 @@ export default {
|
||||||
init(token) {
|
init(token) {
|
||||||
if (!token) {
|
if (!token) {
|
||||||
log("no auth token, skipping connection");
|
log("no auth token, skipping connection");
|
||||||
|
this.dispatch(GatewayEventType.Close, GatewayErrors.BAD_AUTH);
|
||||||
this.dispatch(GatewayEventType.BadAuth, 0);
|
this.dispatch(GatewayEventType.BadAuth, 0);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,21 +3,33 @@ import { getItem } from './storage';
|
||||||
import { authWithToken, useAuthHandlers } from './auth';
|
import { authWithToken, useAuthHandlers } from './auth';
|
||||||
import { initResponsiveHandlers } from './responsive';
|
import { initResponsiveHandlers } from './responsive';
|
||||||
import { useDebuggingApi } from './debuggingapi';
|
import { useDebuggingApi } from './debuggingapi';
|
||||||
|
import gateway, { GatewayEventType } from './gateway';
|
||||||
|
|
||||||
useDebuggingApi();
|
function handleGatewaySettlement() {
|
||||||
initResponsiveHandlers();
|
initResponsiveHandlers();
|
||||||
useAuthHandlers();
|
|
||||||
authWithToken(getItem("auth:token"));
|
|
||||||
|
|
||||||
// Remove loading screen
|
const loadingElement = document.getElementById("pre--loading-screen");
|
||||||
const loadingElement = document.getElementById("pre--loading-screen");
|
if (loadingElement) {
|
||||||
if (loadingElement) {
|
loadingElement.parentElement.removeChild(loadingElement);
|
||||||
loadingElement.parentElement.removeChild(loadingElement);
|
}
|
||||||
|
|
||||||
|
const app = new Main({
|
||||||
|
target: document.body
|
||||||
|
});
|
||||||
|
window.__waffle.app = app;
|
||||||
|
|
||||||
|
gateway.unsubscribe(GatewayEventType.Ready, handleGatewaySettlement);
|
||||||
|
gateway.unsubscribe(GatewayEventType.Close, handleGatewaySettlement);
|
||||||
}
|
}
|
||||||
|
|
||||||
const app = new Main({
|
function main() {
|
||||||
target: document.body
|
useDebuggingApi();
|
||||||
});
|
useAuthHandlers();
|
||||||
window.__waffle.app = app;
|
|
||||||
|
gateway.subscribe(GatewayEventType.Ready, handleGatewaySettlement);
|
||||||
|
gateway.subscribe(GatewayEventType.Close, handleGatewaySettlement);
|
||||||
|
|
||||||
|
authWithToken(getItem("auth:token"));
|
||||||
|
}
|
||||||
|
|
||||||
export default app;
|
main();
|
||||||
|
|
Loading…
Reference in a new issue