diff options
Diffstat (limited to 'Swift/Controllers')
-rw-r--r-- | Swift/Controllers/Chat/ChatsManager.cpp | 12 | ||||
-rw-r--r-- | Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp | 14 |
2 files changed, 24 insertions, 2 deletions
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index 190ca8b..b7087fd 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -437,2 +437,11 @@ void ChatsManager::handleChatActivity(const JID& jid, const std::string& activit saveRecents(); + + // Look up potential MUC controller and update title accordingly as people + // join impromptu chats. + if (mucControllers_.find(jid) != mucControllers_.end()) { + auto chatListWindowIter = std::find_if(recentChats_.begin(), recentChats_.end(), [&](const ChatListWindow::Chat& chatListWindow) { return jid == (chatListWindow.jid); }); + if (chatListWindowIter != recentChats_.end() && (mucControllers_[jid]->isImpromptu() || !chatListWindowIter->impromptuJIDs.empty())) { + mucControllers_[jid]->setChatWindowTitle(chatListWindowIter->getTitle()); + } + } } @@ -877,4 +886,5 @@ MUC::ref ChatsManager::handleJoinMUCRequest(const JID &mucJID, const boost::opti } + auto chatListWindowIter = std::find_if(recentChats_.begin(), recentChats_.end(), [&](const ChatListWindow::Chat& chatListWindow) { return mucJID == (chatListWindow.jid); }); - if (chatListWindowIter != recentChats_.end()) { + if (chatListWindowIter != recentChats_.end() && (mucControllers_[mucJID]->isImpromptu() || !chatListWindowIter->impromptuJIDs.empty())) { mucControllers_[mucJID]->setChatWindowTitle(chatListWindowIter->getTitle()); diff --git a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp index 20c959c..8fc26b5 100644 --- a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp +++ b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp @@ -152,5 +152,6 @@ class ChatsManagerTest : public CppUnit::TestFixture { - //Imptomptu test + // Chat window title tests CPPUNIT_TEST(testImpromptuChatTitle); CPPUNIT_TEST(testImpromptuChatWindowTitle); + CPPUNIT_TEST(testStandardMUCChatWindowTitle); @@ -1588,2 +1589,13 @@ public: + void testStandardMUCChatWindowTitle() { + JID mucJID("mucroom@rooms.test.com"); + std::string nickname = "toodles"; + + MockChatWindow* window = new MockChatWindow(); + mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(mucJID, uiEventStream_).Return(window); + + uiEventStream_->send(std::make_shared<JoinMUCUIEvent>(mucJID, boost::optional<std::string>(), nickname)); + CPPUNIT_ASSERT_EQUAL(std::string("mucroom"), window->name_); + } + private: |