Skip to content

Commit

Permalink
fix(stp-24): Breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Clashsoft committed Feb 26, 2024
1 parent d22a9d7 commit 317e180
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion stp-24/src/main/java/io/github/sekassel/stp24/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -96,7 +96,7 @@ void onInit() {
final Member _member = member;
final List<Trait> _traits = traits;
})
.observeOn(scheduler())
.observeOn(FX_SCHEDULER)
.subscribe(result -> {
final EmpireTemplate empire = result._member.empire();
if (empire != null) {
Expand Down Expand Up @@ -190,7 +190,7 @@ void save() {
final Set<String> 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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -66,7 +66,7 @@ public void save() {
}
userService
.update(tokenStorage.getUserId(), new UpdateUserDto(username, password))
.observeOn(scheduler())
.observeOn(FX_SCHEDULER)
.subscribe(user -> {
backToLobby();
}, error -> {
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
});
}
Expand All @@ -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 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand All @@ -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());
}
}
Expand Down Expand Up @@ -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 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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());
});
}
Expand Down

0 comments on commit 317e180

Please sign in to comment.