From f2fdec8ab1796475d58ad6d0bbaf949512213a37 Mon Sep 17 00:00:00 2001
From: Nicolas Jager <nicolas.jager@savoirfairelinux.com>
Date: Thu, 22 Sep 2016 11:06:51 -0400
Subject: [PATCH] fix : show the right frame when a call ends.

- returns to the welcome page if no contact is selected during the
end of the call. Returns to the text message page otherwise.

Change-Id: I817a8466b1c5f6725f02c94e2e0d4a678f2878e8
Tuleap: #1056
---
 MainPage.xaml.cpp | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/MainPage.xaml.cpp b/MainPage.xaml.cpp
index d804a8f..67ec540 100644
--- a/MainPage.xaml.cpp
+++ b/MainPage.xaml.cpp
@@ -63,8 +63,8 @@ MainPage::MainPage()
     ContactsViewModel::instance->newContactSelected += ref new NewContactSelected([&]() {
         Contact^ selectedContact = ContactsViewModel::instance->selectedContact;
         auto call = selectedContact?
-            SmartPanelItemsViewModel::instance->findItem(selectedContact)->_call:
-            nullptr;
+                    SmartPanelItemsViewModel::instance->findItem(selectedContact)->_call:
+                    nullptr;
         if (call != nullptr) {
             if (call->state == "CURRENT")
                 showFrame(_videoFrame_);
@@ -77,12 +77,18 @@ MainPage::MainPage()
     });
     ContactsViewModel::instance->noContactSelected += ref new NoContactSelected([&]() {
         showFrame(_welcomeFrame_);
-        });
+    });
     CallsViewModel::instance->callStarted += ref new CallStarted([&]() {
         showFrame(_videoFrame_);
     });
     CallsViewModel::instance->callEnded += ref new CallEnded([&]() {
-        showFrame(_messageTextFrame_);
+        auto contact = ContactsViewModel::instance->selectedContact;
+
+        if(contact)
+            showFrame(_messageTextFrame_);
+        else
+            showFrame(_welcomeFrame_);
+
     });
 
     DisplayInformation^ displayInformation = DisplayInformation::GetForCurrentView();
-- 
GitLab