From 317e18094d54e92da1e7705c3fe4d6e5d3d7a037 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Mon, 26 Feb 2024 13:57:14 +0100 Subject: [PATCH] fix(stp-24): Breaking changes --- stp-24/src/main/java/io/github/sekassel/stp24/App.java | 2 +- .../stp24/controller/EditEmpireController.java | 6 +++--- .../sekassel/stp24/controller/EditUserController.java | 6 +++--- .../sekassel/stp24/controller/GameListController.java | 8 ++++---- .../sekassel/stp24/controller/GameLobbyController.java | 10 +++++----- .../sekassel/stp24/controller/LoginController.java | 4 ++-- .../sekassel/stp24/controller/NewGameController.java | 4 ++-- .../sekassel/stp24/controller/SignupController.java | 4 ++-- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/stp-24/src/main/java/io/github/sekassel/stp24/App.java b/stp-24/src/main/java/io/github/sekassel/stp24/App.java index 97d15821..19d5892e 100644 --- a/stp-24/src/main/java/io/github/sekassel/stp24/App.java +++ b/stp-24/src/main/java/io/github/sekassel/stp24/App.java @@ -66,7 +66,7 @@ public void start(Stage primaryStage) { } } catch (Exception e) { - logger().log(Level.SEVERE, "An error occurred while starting the application: " + e.getMessage(), e); + LOGGER.log(Level.SEVERE, "An error occurred while starting the application: " + e.getMessage(), e); } } diff --git a/stp-24/src/main/java/io/github/sekassel/stp24/controller/EditEmpireController.java b/stp-24/src/main/java/io/github/sekassel/stp24/controller/EditEmpireController.java index bd841b61..a1bf14d7 100644 --- a/stp-24/src/main/java/io/github/sekassel/stp24/controller/EditEmpireController.java +++ b/stp-24/src/main/java/io/github/sekassel/stp24/controller/EditEmpireController.java @@ -38,7 +38,7 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; -import static org.fulib.fx.FulibFxApp.scheduler; +import static org.fulib.fx.FulibFxApp.FX_SCHEDULER; @Controller public class EditEmpireController { @@ -96,7 +96,7 @@ void onInit() { final Member _member = member; final List _traits = traits; }) - .observeOn(scheduler()) + .observeOn(FX_SCHEDULER) .subscribe(result -> { final EmpireTemplate empire = result._member.empire(); if (empire != null) { @@ -190,7 +190,7 @@ void save() { final Set traits = selectedTraitList.getItems().stream().map(Trait::id).collect(Collectors.toSet()); final EmpireTemplate empire = new EmpireTemplate(name, color, flag, portrait, traits); memberApiService.update(game, user, new UpdateMemberDto(true, empire)) - .observeOn(scheduler()) + .observeOn(FX_SCHEDULER) .subscribe(result -> backToGame()); } diff --git a/stp-24/src/main/java/io/github/sekassel/stp24/controller/EditUserController.java b/stp-24/src/main/java/io/github/sekassel/stp24/controller/EditUserController.java index bacc8861..de21c982 100644 --- a/stp-24/src/main/java/io/github/sekassel/stp24/controller/EditUserController.java +++ b/stp-24/src/main/java/io/github/sekassel/stp24/controller/EditUserController.java @@ -18,7 +18,7 @@ import javax.inject.Inject; import java.util.ResourceBundle; -import static org.fulib.fx.FulibFxApp.scheduler; +import static org.fulib.fx.FulibFxApp.FX_SCHEDULER; @Controller public class EditUserController { @@ -66,7 +66,7 @@ public void save() { } userService .update(tokenStorage.getUserId(), new UpdateUserDto(username, password)) - .observeOn(scheduler()) + .observeOn(FX_SCHEDULER) .subscribe(user -> { backToLobby(); }, error -> { @@ -89,7 +89,7 @@ public void delete() { ButtonType.YES, ButtonType.NO).showAndWait().ifPresent(response -> { if (response == ButtonType.YES) { - userService.delete(tokenStorage.getUserId()).observeOn(scheduler()).subscribe(user -> { + userService.delete(tokenStorage.getUserId()).observeOn(FX_SCHEDULER).subscribe(user -> { logout(); }, error -> { this.error.set(error.getMessage()); diff --git a/stp-24/src/main/java/io/github/sekassel/stp24/controller/GameListController.java b/stp-24/src/main/java/io/github/sekassel/stp24/controller/GameListController.java index 29037576..af490795 100644 --- a/stp-24/src/main/java/io/github/sekassel/stp24/controller/GameListController.java +++ b/stp-24/src/main/java/io/github/sekassel/stp24/controller/GameListController.java @@ -20,7 +20,7 @@ import java.util.Map; import java.util.ResourceBundle; -import static org.fulib.fx.FulibFxApp.scheduler; +import static org.fulib.fx.FulibFxApp.FX_SCHEDULER; @Controller public class GameListController { @@ -47,7 +47,7 @@ public GameListController() { @onInit void onInit() { - gameApiService.findAll().observeOn(scheduler()).subscribe(games -> { + gameApiService.findAll().observeOn(FX_SCHEDULER).subscribe(games -> { gameList.getItems().setAll(games); }); } @@ -62,12 +62,12 @@ public void join() { final String game = gameList.getSelectionModel().getSelectedItem()._id(); final String user = tokenStorage.getUserId(); memberApiService.findOne(game, user) - .observeOn(scheduler()) + .observeOn(FX_SCHEDULER) .onErrorResumeNext(throwable -> { final String password = promptPassword(); return memberApiService.create(game, new CreateMemberDto(password, false, null)); }) - .observeOn(scheduler()) + .observeOn(FX_SCHEDULER) .subscribe(result -> { app.show("/games/:game", Map.of("game", game)); }, error -> { diff --git a/stp-24/src/main/java/io/github/sekassel/stp24/controller/GameLobbyController.java b/stp-24/src/main/java/io/github/sekassel/stp24/controller/GameLobbyController.java index 278ca300..9737e291 100644 --- a/stp-24/src/main/java/io/github/sekassel/stp24/controller/GameLobbyController.java +++ b/stp-24/src/main/java/io/github/sekassel/stp24/controller/GameLobbyController.java @@ -26,7 +26,7 @@ import java.util.Map; import java.util.ResourceBundle; -import static org.fulib.fx.FulibFxApp.scheduler; +import static org.fulib.fx.FulibFxApp.FX_SCHEDULER; @Controller public class GameLobbyController { @@ -64,13 +64,13 @@ public GameLobbyController() { @onRender void loadGame(@Param("game") String gameId) { gameApiService.findOne(gameId) - .observeOn(scheduler()) + .observeOn(FX_SCHEDULER) .subscribe(game -> { this.game = game; titleText.setText(game.name()); }); memberApiService.findAll(gameId) - .observeOn(scheduler()) + .observeOn(FX_SCHEDULER) .subscribe(members -> { memberList.getItems().setAll(members); final long readyCount = members.stream().filter(Member::ready).count(); @@ -94,7 +94,7 @@ void start() { } if (game.owner().equals(tokenStorage.getUserId())) { gameApiService.updateOne(game._id(), new UpdateGameDto(null, null, true, null)) - .observeOn(scheduler()) + .observeOn(FX_SCHEDULER) .subscribe(g -> showIngame()); } } @@ -147,7 +147,7 @@ protected void updateItem(Member item, boolean empty) { } userService.getUser(item.user()) - .observeOn(scheduler()) + .observeOn(FX_SCHEDULER) .subscribe(user -> { setText(user.name()); }, e -> { diff --git a/stp-24/src/main/java/io/github/sekassel/stp24/controller/LoginController.java b/stp-24/src/main/java/io/github/sekassel/stp24/controller/LoginController.java index ae42c946..8dc1e954 100644 --- a/stp-24/src/main/java/io/github/sekassel/stp24/controller/LoginController.java +++ b/stp-24/src/main/java/io/github/sekassel/stp24/controller/LoginController.java @@ -20,7 +20,7 @@ import java.util.Map; import java.util.ResourceBundle; -import static org.fulib.fx.FulibFxApp.scheduler; +import static org.fulib.fx.FulibFxApp.FX_SCHEDULER; @Controller public class LoginController { @@ -65,7 +65,7 @@ public void signup() { public void login() { loginService .login(usernameInput.getText(), passwordInput.getText(), rememberMe.isSelected()) - .observeOn(scheduler()) // FIXME @Paul: the method should include "fx" in its name + .observeOn(FX_SCHEDULER) // FIXME @Paul: the method should include "fx" in its name .subscribe(result -> app.show("/main-menu"), error -> { error.printStackTrace(); errorLabel.setText(error.getMessage()); diff --git a/stp-24/src/main/java/io/github/sekassel/stp24/controller/NewGameController.java b/stp-24/src/main/java/io/github/sekassel/stp24/controller/NewGameController.java index f4b0f121..9db54ffc 100644 --- a/stp-24/src/main/java/io/github/sekassel/stp24/controller/NewGameController.java +++ b/stp-24/src/main/java/io/github/sekassel/stp24/controller/NewGameController.java @@ -21,7 +21,7 @@ import java.util.Map; import java.util.ResourceBundle; -import static org.fulib.fx.FulibFxApp.scheduler; +import static org.fulib.fx.FulibFxApp.FX_SCHEDULER; @Controller public class NewGameController { @@ -64,7 +64,7 @@ public void create() { final String password = passwordInput.getText(); final int size = sizeInput.getValue(); gameApiService.create(new CreateGameDto(name, password, new GameSettings(size))) - .observeOn(scheduler()) + .observeOn(FX_SCHEDULER) .subscribe(game -> { app.show("/games/:game", Map.of("game", game._id())); }, throwable -> { diff --git a/stp-24/src/main/java/io/github/sekassel/stp24/controller/SignupController.java b/stp-24/src/main/java/io/github/sekassel/stp24/controller/SignupController.java index a8233f02..fa1f5e1b 100644 --- a/stp-24/src/main/java/io/github/sekassel/stp24/controller/SignupController.java +++ b/stp-24/src/main/java/io/github/sekassel/stp24/controller/SignupController.java @@ -19,7 +19,7 @@ import java.util.Map; import java.util.ResourceBundle; -import static org.fulib.fx.FulibFxApp.scheduler; +import static org.fulib.fx.FulibFxApp.FX_SCHEDULER; @Controller public class SignupController { @@ -66,7 +66,7 @@ protected void onRender() { public void signUp() { String username = usernameInput.getText(); String password = passwordInput.getText(); - userService.register(username, password).observeOn(scheduler()).subscribe(user -> login(), error -> { + userService.register(username, password).observeOn(FX_SCHEDULER).subscribe(user -> login(), error -> { this.error.set(error.getMessage()); }); }