diff options
-rw-r--r-- | Swift/QtUI/UserSearch/QtUserSearchWindow.cpp | 10 | ||||
-rw-r--r-- | Swiften/JID/UnitTest/JIDTest.cpp | 6 |
2 files changed, 14 insertions, 2 deletions
diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp index ebf05b7..434da38 100644 --- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp +++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp @@ -164,15 +164,21 @@ void QtUserSearchWindow::handleContactSuggestionRequested(const QString& text) { } void QtUserSearchWindow::addContact() { - if (!!firstMultiJIDPage_->jid_->getContact()) { - contactVector_.push_back(firstMultiJIDPage_->jid_->getContact()); + auto contactToAdd = firstMultiJIDPage_->jid_->getContact(); + if (!!contactToAdd) { + contactVector_.push_back(contactToAdd); firstMultiJIDPage_->jid_->clear(); } + firstMultiJIDPage_->contactList_->setList(contactVector_); firstMultiJIDPage_->emitCompletenessCheck(); if (type_ == ChatToContact) { firstMultiJIDPage_->groupBox->setEnabled(supportsImpromptu_ ? 1 : (contactVector_.size() < 1)); } + + if (!!contactToAdd && contactToAdd->jid.isValid() && contactToAdd->statusType == StatusShow::None) { + onJIDUpdateRequested({contactToAdd->jid}); + } } void QtUserSearchWindow::setWarning(const boost::optional<std::string>& message) { diff --git a/Swiften/JID/UnitTest/JIDTest.cpp b/Swiften/JID/UnitTest/JIDTest.cpp index ffe28a1..432e7cb 100644 --- a/Swiften/JID/UnitTest/JIDTest.cpp +++ b/Swiften/JID/UnitTest/JIDTest.cpp @@ -15,6 +15,7 @@ class JIDTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(JIDTest); CPPUNIT_TEST(testConstructorWithString); + CPPUNIT_TEST(testConstructorWithString_Empty); CPPUNIT_TEST(testConstructorWithString_NoResource); CPPUNIT_TEST(testConstructorWithString_NoNode); CPPUNIT_TEST(testConstructorWithString_EmptyResource); @@ -76,6 +77,11 @@ class JIDTest : public CppUnit::TestFixture CPPUNIT_ASSERT(testling.isValid()); } + void testConstructorWithString_Empty() { + JID testling(""); + CPPUNIT_ASSERT_EQUAL(false, testling.isValid()); + } + void testConstructorWithString_NoResource() { JID testling("foo@bar"); |