diff --git a/src/states_screens/dialogs/user_info_dialog.cpp b/src/states_screens/dialogs/user_info_dialog.cpp index bd06dcde1..b89aee79d 100644 --- a/src/states_screens/dialogs/user_info_dialog.cpp +++ b/src/states_screens/dialogs/user_info_dialog.cpp @@ -278,6 +278,24 @@ void UserInfoDialog::declineFriendRequest() } // declineFriendRequest +// ----------------------------------------------------------------------------- +/** Removes an existing friend. + */ +void UserInfoDialog::removeExistingFriend() +{ + CurrentUser::get()->requestRemoveFriend(m_profile->getID()); + +} // removeExistingFriend + +// ----------------------------------------------------------------------------- +/** Removes a pending friend request. + */ +void UserInfoDialog::removePendingFriend() +{ + CurrentUser::get()->requestCancelFriend(m_profile->getID()); + +} // removePendingFriend + // ----------------------------------------------------------------------------- GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& eventSource) { @@ -304,10 +322,12 @@ GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& even } else if(selection == m_remove_widget->m_properties[PROP_ID]) { - if(m_profile->getRelationInfo()->isPending()) - CurrentUser::get()->requestCancelFriend(m_profile->getID()); + if (m_profile->getRelationInfo() && + m_profile->getRelationInfo()->isPending() ) + removePendingFriend(); else - CurrentUser::get()->requestRemoveFriend(m_profile->getID()); + removeExistingFriend(); + m_processing = true; m_options_widget->setDeactivated(); return GUIEngine::EVENT_BLOCK; diff --git a/src/states_screens/dialogs/user_info_dialog.hpp b/src/states_screens/dialogs/user_info_dialog.hpp index ca6c23c78..ed5c01bd8 100644 --- a/src/states_screens/dialogs/user_info_dialog.hpp +++ b/src/states_screens/dialogs/user_info_dialog.hpp @@ -63,6 +63,8 @@ private: void sendFriendRequest(); void acceptFriendRequest(); void declineFriendRequest(); + void removeExistingFriend(); + void removePendingFriend(); public: UserInfoDialog(uint32_t showing_id, const core::stringw info = "", bool error = false, bool from_queue = false);