diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-08-20 08:48:53 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-08-20 08:48:53 +0900 |
commit | e507ca582b1b243ee4422a4a3e0b11b28697cb16 (patch) | |
tree | 4954d791d4b51c656efac48de5d6a99a8362e637 /lib | |
parent | b3e90ac833424ef21a0f8947f74aa3ed445e16e1 (diff) | |
download | libquotient-e507ca582b1b243ee4422a4a3e0b11b28697cb16.tar.gz libquotient-e507ca582b1b243ee4422a4a3e0b11b28697cb16.zip |
Room::displaynameChanged() should pass the old name too
Also: general cleanup.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/room.cpp | 17 | ||||
-rw-r--r-- | lib/room.h | 2 |
2 files changed, 10 insertions, 9 deletions
diff --git a/lib/room.cpp b/lib/room.cpp index 2c30d2ba..07c39498 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -1705,7 +1705,8 @@ bool Room::processStateEvent(const RoomEvent& e) } , [this] (const RoomCanonicalAliasEvent& evt) { d->canonicalAlias = evt.alias(); - setObjectName(d->canonicalAlias); + if (!d->canonicalAlias.isEmpty()) + setObjectName(d->canonicalAlias); qCDebug(MAIN) << "Room canonical alias updated:" << d->canonicalAlias; return true; @@ -1935,6 +1936,10 @@ QString Room::Private::calculateDisplayname() const if (!canonicalAlias.isEmpty()) return canonicalAlias; + // Using m.room.aliases in naming is explicitly discouraged by the spec + //if (!aliases.empty() && !aliases.at(0).isEmpty()) + // return aliases.at(0); + // 3. Room members QString topMemberNames = roomNameFromMemberNames(membersMap.values()); if (!topMemberNames.isEmpty()) @@ -1947,18 +1952,14 @@ QString Room::Private::calculateDisplayname() const // 5. Fail miserably return tr("Empty room (%1)").arg(id); - - // Using m.room.aliases is explicitly discouraged by the spec - //if (!aliases.empty() && !aliases.at(0).isEmpty()) - // displayname = aliases.at(0); } void Room::Private::updateDisplayname() { - const QString old_name = displayname; + const QString oldName = displayname; displayname = calculateDisplayname(); - if (old_name != displayname) - emit q->displaynameChanged(q); + if (oldName != displayname) + emit q->displaynameChanged(q, oldName); } void appendStateEvent(QJsonArray& events, const QString& type, @@ -367,7 +367,7 @@ namespace QMatrixClient */ void namesChanged(Room* room); /** @brief The room displayname changed */ - void displaynameChanged(Room* room); + void displaynameChanged(Room* room, QString oldName); void topicChanged(); void avatarChanged(); void userAdded(User* user); |