From a832b93c8a87580c3b30c51ff2feccc9f967d40f Mon Sep 17 00:00:00 2001
From: Alexis Durgnat <alexis.durgnat@etu.hesge.ch>
Date: Sun, 3 Feb 2019 13:16:26 +0100
Subject: [PATCH] Add leftJourney sub

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

diff --git a/src/main/java/ch/hepia/ui/MainWindowController.java b/src/main/java/ch/hepia/ui/MainWindowController.java
index 2bc9e50..3c57b1b 100644
--- a/src/main/java/ch/hepia/ui/MainWindowController.java
+++ b/src/main/java/ch/hepia/ui/MainWindowController.java
@@ -336,5 +336,20 @@ public class MainWindowController implements Initializable {
         }, 
         joinedJourney -> !(app.getUser().get().getIgnoredUserList().contains(joinedJourney.getUser())) 
         );
+
+        // Subscribe to left journey
+        app.getMessageManager().conditionalSubscribeLeftJourney( leftJourney -> {
+            Platform.runLater(() -> {
+                User sender = leftJourney.getUser();
+                String message = sender.getName() + " a terminé son voyage !";
+                if (sender.equals(app.getUser().get())) {
+                    drawMessage(sender, message, AppConfig.CHAT_MESSAGE_ICON_SELF, AppConfig.COLOR_BLUE_10_OPACITY);
+                } else {
+                    drawMessage(sender, message, AppConfig.CHAT_MESSAGE_ICON, AppConfig.COLOR_BLUE_10_OPACITY);
+                }
+            });
+        }, 
+        leftJourney -> !(app.getUser().get().getIgnoredUserList().contains(leftJourney.getUser())) 
+        );
     }
 }
-- 
GitLab