From c65dbd72cb50212f47e653f601d63cdab5027457 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Th=C3=A9o=20Pirkl?= <pirkl.theo@gmail.com>
Date: Sun, 3 Feb 2019 18:57:04 +0100
Subject: [PATCH] Implements a e s t h e t i c s

---
 .../java/ch/hepia/ui/MainWindowController.java    | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/main/java/ch/hepia/ui/MainWindowController.java b/src/main/java/ch/hepia/ui/MainWindowController.java
index 843c2d3..e2988c5 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);
             }
         });
     }
-- 
GitLab