Fix LoginScene popping

This commit is contained in:
Kai S. K. Engelbart 2020-09-02 10:07:02 +02:00
parent 8b204b3715
commit d0c8c685ab
2 changed files with 17 additions and 4 deletions

View File

@ -124,8 +124,12 @@ public final class SceneContext {
* @since Envoy Client v0.1-beta * @since Envoy Client v0.1-beta
*/ */
public void pop() { public void pop() {
if (!sceneStack.isEmpty()) sceneStack.pop();
if (!controllerStack.isEmpty()) controllerStack.pop(); // Pop scene and controller
sceneStack.pop();
controllerStack.pop();
// Apply new scene if present
if (!sceneStack.isEmpty()) { if (!sceneStack.isEmpty()) {
final var newScene = sceneStack.peek(); final var newScene = sceneStack.peek();
stage.setScene(newScene); stage.setScene(newScene);
@ -160,4 +164,10 @@ public final class SceneContext {
* @since Envoy Client v0.1-beta * @since Envoy Client v0.1-beta
*/ */
public Stage getStage() { return stage; } public Stage getStage() { return stage; }
/**
* @return whether the scene stack is empty
* @since Envoy Client v0.2-beta
*/
public boolean isEmpty() { return sceneStack.isEmpty(); }
} }

View File

@ -172,7 +172,6 @@ public final class Startup extends Application {
try { try {
localDB.initializeUserStorage(); localDB.initializeUserStorage();
localDB.loadUserData(); localDB.loadUserData();
context.initWriteProxy();
} catch (final FileNotFoundException e) { } catch (final FileNotFoundException e) {
// The local database file has not yet been created, probably first login // The local database file has not yet been created, probably first login
} catch (final Exception e) { } catch (final Exception e) {
@ -180,6 +179,7 @@ public final class Startup extends Application {
logger.log(Level.WARNING, "Could not load local database: ", e); logger.log(Level.WARNING, "Could not load local database: ", e);
} }
context.initWriteProxy();
localDB.synchronize(); localDB.synchronize();
if (client.isOnline()) context.getWriteProxy().flushCache(); if (client.isOnline()) context.getWriteProxy().flushCache();
@ -193,8 +193,11 @@ public final class Startup extends Application {
.forEach(u -> u.setStatus(UserStatus.OFFLINE)); .forEach(u -> u.setStatus(UserStatus.OFFLINE));
final var stage = context.getStage(); final var stage = context.getStage();
// Pop LoginScene if present
if (!context.getSceneContext().isEmpty()) context.getSceneContext().pop();
// Load ChatScene // Load ChatScene
context.getSceneContext().pop();
stage.setMinHeight(400); stage.setMinHeight(400);
stage.setMinWidth(843); stage.setMinWidth(843);
context.getSceneContext().load(SceneContext.SceneInfo.CHAT_SCENE); context.getSceneContext().load(SceneContext.SceneInfo.CHAT_SCENE);