diff options
| author | Joanna Hulboj <joanna.hulboj@isode.com> | 2017-03-13 21:51:04 (GMT) |
|---|---|---|
| committer | Kevin Smith <kevin.smith@isode.com> | 2017-05-04 10:34:00 (GMT) |
| commit | cfea60eda7f3ce5fa10ed92c50c19fc1ee264eb1 (patch) | |
| tree | fb2564927189eb1cc8e28ac82fd96f6161b54d31 /Swift/Controllers/UIInterfaces | |
| parent | dc70dbb6af039fba8f7a1cece8db4bb119deaabd (diff) | |
| download | swift-cfea60eda7f3ce5fa10ed92c50c19fc1ee264eb1.zip swift-cfea60eda7f3ce5fa10ed92c50c19fc1ee264eb1.tar.bz2 | |
Fix recent chat entries being incorrectly displayed
Recent chat entries were displayed as a randomly generated numbers instead of
impromptus (if invitees were offline).
Title displayed in the Recent Chat List for MUC is now based on both the
occupants and invitees. To do that a collection with all the invitees is
being stored (new) along the occupants (existing).
Test-Information:
From Swift menu choose Actions, Start Chat... Add some offline contacts
to the List of Participants and press Finish. Recent chat entry will
have correct name (combined of contact names).
Change-Id: Ie076165e8dbb493aa261cc49ca3ab1e0c1c542a8
Diffstat (limited to 'Swift/Controllers/UIInterfaces')
| -rw-r--r-- | Swift/Controllers/UIInterfaces/ChatListWindow.h | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/Swift/Controllers/UIInterfaces/ChatListWindow.h b/Swift/Controllers/UIInterfaces/ChatListWindow.h index dde596e..29097e9 100644 --- a/Swift/Controllers/UIInterfaces/ChatListWindow.h +++ b/Swift/Controllers/UIInterfaces/ChatListWindow.h @@ -1,99 +1,119 @@ /* * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once #include <list> #include <map> #include <memory> #include <set> + +#include <boost/algorithm/string/join.hpp> #include <boost/filesystem/path.hpp> #include <boost/signals2.hpp> +#include <Swiften/Base/Algorithm.h> #include <Swiften/Elements/StatusShow.h> #include <Swiften/MUC/MUCBookmark.h> namespace Swift { class ChatListWindow { public: class Chat { public: Chat() : statusType(StatusShow::None), isMUC(false), unreadCount(0), isPrivateMessage(false) {} Chat(const JID& jid, const std::string& chatName, const std::string& activity, int unreadCount, StatusShow::Type statusType, const boost::filesystem::path& avatarPath, bool isMUC, bool isPrivateMessage = false, const std::string& nick = "", const boost::optional<std::string> password = boost::optional<std::string>()) : jid(jid), chatName(chatName), activity(activity), statusType(statusType), isMUC(isMUC), nick(nick), password(password), unreadCount(unreadCount), avatarPath(avatarPath), isPrivateMessage(isPrivateMessage) {} /** Assume that nicks and other transient features aren't important for equality */ bool operator==(const Chat& other) const { if (impromptuJIDs.empty()) { return jid.toBare() == other.jid.toBare() && isMUC == other.isMUC; } + if (chatName == other.chatName) { + return true; + } else { /* compare the chat occupant lists */ for (const auto& jid : impromptuJIDs) { bool found = false; for (const auto& otherJID : other.impromptuJIDs) { if (jid.second.toBare() == otherJID.second.toBare()) { found = true; break; } } if (!found) { return false; } } - return true; + return key_compare(inviteesNames, other.inviteesNames); } } void setUnreadCount(int unread) { unreadCount = unread; } void setStatusType(StatusShow::Type type) { statusType = type; } void setAvatarPath(const boost::filesystem::path& path) { avatarPath = path; } std::string getImpromptuTitle() const { - std::string title; - for (auto& pair : impromptuJIDs) { - if (title.empty()) { - title += pair.first; - } else { - title += ", " + pair.first; + std::set<std::string> participants; + std::map<JID, std::string> participantsMap; + + for (auto& pair : inviteesNames) { + if (!pair.second.empty()) { + participantsMap[pair.first] = pair.second; } + else { + participantsMap[pair.first] = pair.first.toString(); + } + } + for (auto& pair : impromptuJIDs) { + participantsMap[pair.second] = pair.first; } - return title; + for (auto& participant : participantsMap) { + participants.insert(participant.second); + } + return boost::algorithm::join(participants, ", "); + } + std::string getTitle() const { + std::string title = getImpromptuTitle(); + return title.empty() ? chatName : title; } JID jid; std::string chatName; std::string activity; StatusShow::Type statusType; bool isMUC; std::string nick; boost::optional<std::string> password; int unreadCount; boost::filesystem::path avatarPath; std::map<std::string, JID> impromptuJIDs; + std::map<JID, std::string> inviteesNames; bool isPrivateMessage; }; virtual ~ChatListWindow(); virtual void setBookmarksEnabled(bool enabled) = 0; virtual void addMUCBookmark(const MUCBookmark& bookmark) = 0; virtual void addWhiteboardSession(const ChatListWindow::Chat& chat) = 0; virtual void removeWhiteboardSession(const JID& jid) = 0; virtual void removeMUCBookmark(const MUCBookmark& bookmark) = 0; virtual void setRecents(const std::list<Chat>& recents) = 0; virtual void setUnreadCount(int unread) = 0; virtual void clearBookmarks() = 0; virtual void setOnline(bool isOnline) = 0; boost::signals2::signal<void (const MUCBookmark&)> onMUCBookmarkActivated; boost::signals2::signal<void (const Chat&)> onRecentActivated; boost::signals2::signal<void (const JID&)> onWhiteboardActivated; boost::signals2::signal<void ()> onClearRecentsRequested; }; } |
Swift