diff --git a/src/main/java/ch/hepia/ui/MainWindowController.java b/src/main/java/ch/hepia/ui/MainWindowController.java index 843c2d3c2e826d7db87a0be6f31662f4bfbf03ea..e2988c5cde18397b6db0ea3f060704a05e3a0d33 100644 --- a/src/main/java/ch/hepia/ui/MainWindowController.java +++ b/src/main/java/ch/hepia/ui/MainWindowController.java @@ -283,14 +283,14 @@ public class MainWindowController implements Initializable { Integer pos = Integer.parseInt(pnl.getId()); WeatherAPI api = new WeatherAPI(); Connection connection = displayedConnections.get(pos); - System.out.println(connection.getTo().getLocation().getCoordinates()); + String wtd = api.getWeatherFrom(connection.getTo().getLocation().getCoordinates()).getConditionsIcon(); + String wtcd = api.getWeatherFrom(currentJourney.getTo().getLocation().getCoordinates()).getConditionsIcon(); if (!(currentJourney instanceof Connection.EmptyConnection)){ - leaveJourney(app, api.getWeatherFrom(connection.getTo().getLocation().getCoordinates()).getConditions()); + leaveJourney(app, wtcd); } - String weather = api.getWeatherFrom(connection.getTo().toString()).getConditions(); - JoinedJourney joinedJourney = new JoinedJourney(app.getUser().get(), connection, weather); + JoinedJourney joinedJourney = new JoinedJourney(app.getUser().get(), connection, wtd); app.getMessageManager().sendJoinedJourney(joinedJourney); currentJourney = displayedConnections.get(pos); @@ -308,12 +308,7 @@ public class MainWindowController implements Initializable { Optional<ButtonType> result = alert.showAndWait(); if (result.get().equals(oui)){ - try { - leaveJourney(app, api.getWeatherFrom(connection.getTo().getLocation().getCoordinates()).getConditions()); - } catch (IOException e) { - showSadMessage(AppConfig.ERROR_API_MQ); - e.printStackTrace(); - } + leaveJourney(app, wtcd); } }); }