From 42bca67768d6f174ecf125563ab28ef79b994e23 Mon Sep 17 00:00:00 2001 From: Ram Nad Date: Sun, 8 Mar 2020 02:43:23 +0530 Subject: fixing msc2432 --- lib/connection.cpp | 10 ++--- lib/connection.h | 2 +- lib/events/roomcanonicalaliasevent.h | 86 ++++++++++++++++++++++++++++++++++++ lib/events/simplestateevents.h | 2 - lib/room.cpp | 48 +++++++++++++++----- 5 files changed, 129 insertions(+), 19 deletions(-) create mode 100644 lib/events/roomcanonicalaliasevent.h (limited to 'lib') diff --git a/lib/connection.cpp b/lib/connection.cpp index 5bddbb83..f3d31d2d 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -87,7 +87,7 @@ public: QHash, Room*> roomMap; /// Mapping from serverparts to alias/room id mappings, /// as of the last sync - QHash> roomAliasMap; + QHash roomAliasMap; QVector roomIdsToForget; QVector firstTimeRooms; QVector pendingStateRoomIds; @@ -891,7 +891,7 @@ Room* Connection::room(const QString& roomId, JoinStates states) const Room* Connection::roomByAlias(const QString& roomAlias, JoinStates states) const { - const auto id = d->roomAliasMap.value(serverPart(roomAlias)).value(roomAlias); + const auto id = d->roomAliasMap.value(roomAlias); if (!id.isEmpty()) return room(id, states); @@ -901,17 +901,15 @@ Room* Connection::roomByAlias(const QString& roomAlias, JoinStates states) const } void Connection::updateRoomAliases(const QString& roomId, - const QString& aliasServer, const QStringList& previousRoomAliases, const QStringList& roomAliases) { - auto& aliasMap = d->roomAliasMap[aliasServer]; // Allocate if necessary for (const auto& a : previousRoomAliases) - if (aliasMap.remove(a) == 0) + if (d->roomAliasMap.remove(a) == 0) qCWarning(MAIN) << "Alias" << a << "is not found (already deleted?)"; for (const auto& a : roomAliases) { - auto& mappedId = aliasMap[a]; + auto& mappedId = d->roomAliasMap[a]; if (!mappedId.isEmpty()) { if (mappedId == roomId) qCDebug(MAIN) diff --git a/lib/connection.h b/lib/connection.h index e4109fd4..c7e18c12 100644 --- a/lib/connection.h +++ b/lib/connection.h @@ -294,7 +294,7 @@ public: /// This is used to maintain the internal index of room aliases. /// It does NOT change aliases on the server, /// \sa Room::setLocalAliases - void updateRoomAliases(const QString& roomId, const QString& aliasServer, + void updateRoomAliases(const QString& roomId, const QStringList& previousRoomAliases, const QStringList& roomAliases); Q_INVOKABLE Quotient::Room* invitation(const QString& roomId) const; diff --git a/lib/events/roomcanonicalaliasevent.h b/lib/events/roomcanonicalaliasevent.h new file mode 100644 index 00000000..3f89f639 --- /dev/null +++ b/lib/events/roomcanonicalaliasevent.h @@ -0,0 +1,86 @@ +// Contains code for RoomCanonicalAlias Event +#pragma once + +#include "stateevent.h" + +namespace Quotient { +namespace EventContent{ + template + class SimpleDualContent { + public: + using first_value_type = T1; + using second_value_type = T2; + + template + SimpleDualContent(QString Key1Name, TT1&& value1, QString Key2Name, + TT2&& value2) + : value1(std::forward(value1)) + , value2(std::forward(value2)) + , key1(std::move(Key1Name)) + , key2(std::move(Key2Name)) + { } + + SimpleDualContent(const QJsonObject& json, QString key1Name, + QString key2Name) + : value1(fromJson(json[key1Name])) + , value2(fromJson(json[key2Name])) + , key1(std::move(key1Name)) + , key2(std::move(key2Name)) + { } + + QJsonObject toJson() const + { + return { { key1, Quotient::toJson(value1) }, + { key2, Quotient::toJson(value2) } }; + } + + public: + T1 value1; + T2 value2; + + protected: + QString key1; + QString key2; + }; +} // namespace EventContent + +class RoomCanonicalAliasEvent + : public StateEvent> { +public: + DEFINE_EVENT_TYPEID("m.room.canonical_alias", RoomCanonicalAliasEvent) + + explicit RoomCanonicalAliasEvent(const QJsonObject& obj) + : StateEvent(typeId(), obj, QStringLiteral("alias"), + QStringLiteral("alt_aliases")) + { } + + RoomCanonicalAliasEvent(const QString& server, const QString& alias, + const QStringList& alt_aliases) + : StateEvent(typeId(), matrixTypeId(), server, QStringLiteral("alias"), + alias, QStringLiteral("alt_aliases"), alt_aliases) + { } + + // For compatibility used at Room::setCanonicalAlias + explicit RoomCanonicalAliasEvent(const QString& value1) + : RoomCanonicalAliasEvent(value1, QStringList()) + { } + + // Because, MSC2432 specifies, that alt_aliases may be present + // without aliases as well + explicit RoomCanonicalAliasEvent(const QStringList& value2) + : RoomCanonicalAliasEvent(QString(), value2) + { } + + template + RoomCanonicalAliasEvent(T1&& value1, T2&& value2) + : StateEvent(typeId(), matrixTypeId(), QString(), + QStringLiteral("alias"), std::forward(value1), + QStringLiteral("alt_aliases"), std::forward(value2)) + { } + + QString alias() const { return content().value1; } + + QStringList alt_aliases() const { return content().value2; } +}; +REGISTER_EVENT_TYPE(RoomCanonicalAliasEvent) +} // namespace Quotient \ No newline at end of file diff --git a/lib/events/simplestateevents.h b/lib/events/simplestateevents.h index eb1d2f7a..cde5b0fd 100644 --- a/lib/events/simplestateevents.h +++ b/lib/events/simplestateevents.h @@ -69,8 +69,6 @@ namespace EventContent { // End of macro DEFINE_SIMPLE_STATE_EVENT(RoomNameEvent, "m.room.name", QString, name) -DEFINE_SIMPLE_STATE_EVENT(RoomCanonicalAliasEvent, "m.room.canonical_alias", - QString, alias) DEFINE_SIMPLE_STATE_EVENT(RoomTopicEvent, "m.room.topic", QString, topic) class RoomAliasesEvent diff --git a/lib/room.cpp b/lib/room.cpp index b29f6f48..475c6570 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -56,6 +56,7 @@ #include "jobs/downloadfilejob.h" #include "jobs/mediathumbnailjob.h" #include "jobs/postreadmarkersjob.h" +#include "events/roomcanonicalaliasevent.h" #include #include @@ -107,6 +108,7 @@ public: QHash currentState; /// Servers with aliases for this room except the one of the local user /// \sa Room::remoteAliases + // This may not be required anymore QSet aliasServers; Timeline timeline; @@ -432,12 +434,13 @@ QString Room::name() const QStringList Room::localAliases() const { - return d - ->getCurrentState( - connection()->domain()) - ->aliases(); + QStringList result(d + ->getCurrentState()->alias()); + result += d->getCurrentState()->alt_aliases(); + return result; } +// Not sure about this function, maybe it is no more required QStringList Room::remoteAliases() const { QStringList result; @@ -1697,8 +1700,7 @@ void Room::setCanonicalAlias(const QString& newAlias) void Room::setLocalAliases(const QStringList& aliases) { - d->requestSetState(connection()->homeserver().authority(), - aliases); + d->requestSetState(aliases); } void Room::setTopic(const QString& newTopic) @@ -2368,14 +2370,40 @@ Room::Changes Room::processStateEvent(const RoomEvent& e) oldStateEvent ? static_cast(oldStateEvent)->aliases() : QStringList(); - connection()->updateRoomAliases(id(), ae.stateKey(), - previousAliases, ae.aliases()); + connection()->updateRoomAliases(id(), previousAliases, ae.aliases()); return OtherChange; // clang-format off } - , [this] (const RoomCanonicalAliasEvent& evt) { - setObjectName(evt.alias().isEmpty() ? d->id : evt.alias()); + , [this, oldStateEvent] (const RoomCanonicalAliasEvent& cae) { + // clang-format on + setObjectName(cae.alias().isEmpty() ? d->id : cae.alias()); + QString previousCanonicalAlias = + oldStateEvent + ? static_cast(oldStateEvent) + ->alias() + : QString(); + + auto previousAltAliases = + oldStateEvent + ? static_cast(oldStateEvent) + ->alt_aliases() + : QStringList(); + + if (!previousCanonicalAlias.isEmpty()) { + previousAltAliases.push_back(previousCanonicalAlias); + } + + const auto previousAliases = std::move(previousAltAliases); + + auto newAliases = cae.alt_aliases(); + + if (!cae.alias().isEmpty()) { + newAliases.push_front(cae.alias()); + } + + connection()->updateRoomAliases(id(), previousAliases, newAliases); return CanonicalAliasChange; + // clang-format off } , [] (const RoomTopicEvent&) { return TopicChange; -- cgit v1.2.3 From a682edf6e93f9ad4a087d5ba1374e42b06ec27e9 Mon Sep 17 00:00:00 2001 From: Ram Nad Date: Fri, 20 Mar 2020 01:11:34 +0530 Subject: Add warranty in lib/events/roomcanonicalaliasevent.h Co-Authored-By: Kitsune Ral --- lib/events/roomcanonicalaliasevent.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/events/roomcanonicalaliasevent.h b/lib/events/roomcanonicalaliasevent.h index 3f89f639..78d541bc 100644 --- a/lib/events/roomcanonicalaliasevent.h +++ b/lib/events/roomcanonicalaliasevent.h @@ -1,4 +1,21 @@ -// Contains code for RoomCanonicalAlias Event +/****************************************************************************** + * Copyright (C) 2020 QMatrixClient project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + #pragma once #include "stateevent.h" @@ -83,4 +100,4 @@ public: QStringList alt_aliases() const { return content().value2; } }; REGISTER_EVENT_TYPE(RoomCanonicalAliasEvent) -} // namespace Quotient \ No newline at end of file +} // namespace Quotient -- cgit v1.2.3 From 99c7e1c5e2a78c6babba50418789bd4c4f0e9db3 Mon Sep 17 00:00:00 2001 From: Ram Nad Date: Fri, 20 Mar 2020 02:29:45 +0530 Subject: made suggested changes --- lib/events/roomcanonicalaliasevent.h | 72 +++++++++++------------------------- lib/room.cpp | 46 ++++++++++------------- lib/room.h | 3 ++ 3 files changed, 44 insertions(+), 77 deletions(-) (limited to 'lib') diff --git a/lib/events/roomcanonicalaliasevent.h b/lib/events/roomcanonicalaliasevent.h index 78d541bc..012cac75 100644 --- a/lib/events/roomcanonicalaliasevent.h +++ b/lib/events/roomcanonicalaliasevent.h @@ -22,82 +22,54 @@ namespace Quotient { namespace EventContent{ - template - class SimpleDualContent { + class AliasesEventContent { + public: - using first_value_type = T1; - using second_value_type = T2; - template - SimpleDualContent(QString Key1Name, TT1&& value1, QString Key2Name, - TT2&& value2) - : value1(std::forward(value1)) - , value2(std::forward(value2)) - , key1(std::move(Key1Name)) - , key2(std::move(Key2Name)) + template + AliasesEventContent(T1&& canonicalAlias, T2&& altAliases) + : canonicalAlias(std::forward(canonicalAlias)) + , altAliases(std::forward(altAliases)) { } - SimpleDualContent(const QJsonObject& json, QString key1Name, - QString key2Name) - : value1(fromJson(json[key1Name])) - , value2(fromJson(json[key2Name])) - , key1(std::move(key1Name)) - , key2(std::move(key2Name)) + AliasesEventContent(const QJsonObject& json) + : canonicalAlias(fromJson(json["alias"])) + , altAliases(fromJson(json["alt_aliases"])) { } QJsonObject toJson() const { - return { { key1, Quotient::toJson(value1) }, - { key2, Quotient::toJson(value2) } }; + return { { "alias", Quotient::toJson(canonicalAlias) }, + { "alt_aliases", Quotient::toJson(altAliases) } }; } - public: - T1 value1; - T2 value2; - - protected: - QString key1; - QString key2; + QString canonicalAlias; + QStringList altAliases; }; } // namespace EventContent class RoomCanonicalAliasEvent - : public StateEvent> { + : public StateEvent { public: DEFINE_EVENT_TYPEID("m.room.canonical_alias", RoomCanonicalAliasEvent) explicit RoomCanonicalAliasEvent(const QJsonObject& obj) - : StateEvent(typeId(), obj, QStringLiteral("alias"), - QStringLiteral("alt_aliases")) - { } - - RoomCanonicalAliasEvent(const QString& server, const QString& alias, - const QStringList& alt_aliases) - : StateEvent(typeId(), matrixTypeId(), server, QStringLiteral("alias"), - alias, QStringLiteral("alt_aliases"), alt_aliases) - { } - - // For compatibility used at Room::setCanonicalAlias - explicit RoomCanonicalAliasEvent(const QString& value1) - : RoomCanonicalAliasEvent(value1, QStringList()) + : StateEvent(typeId(), obj) { } - // Because, MSC2432 specifies, that alt_aliases may be present - // without aliases as well - explicit RoomCanonicalAliasEvent(const QStringList& value2) - : RoomCanonicalAliasEvent(QString(), value2) + RoomCanonicalAliasEvent(const QString& canonicalAlias, const QStringList& altAliases = {}) + : StateEvent(typeId(), matrixTypeId(), QString(), + canonicalAlias, altAliases) { } - template - RoomCanonicalAliasEvent(T1&& value1, T2&& value2) + RoomCanonicalAliasEvent(QString&& canonicalAlias, QStringList&& altAliases = {}) : StateEvent(typeId(), matrixTypeId(), QString(), - QStringLiteral("alias"), std::forward(value1), - QStringLiteral("alt_aliases"), std::forward(value2)) + std::move(canonicalAlias), std::move(altAliases)) { } - QString alias() const { return content().value1; } + QString alias() const { return content().canonicalAlias; } - QStringList alt_aliases() const { return content().value2; } + QStringList altAliases() const { return content().altAliases; } }; REGISTER_EVENT_TYPE(RoomCanonicalAliasEvent) } // namespace Quotient diff --git a/lib/room.cpp b/lib/room.cpp index 475c6570..fa3f10a6 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -108,7 +108,7 @@ public: QHash currentState; /// Servers with aliases for this room except the one of the local user /// \sa Room::remoteAliases - // This may not be required anymore + QSet aliasServers; Timeline timeline; @@ -432,15 +432,20 @@ QString Room::name() const return d->getCurrentState()->name(); } -QStringList Room::localAliases() const +QStringList Room::aliases() const { - QStringList result(d - ->getCurrentState()->alias()); - result += d->getCurrentState()->alt_aliases(); + QStringList result(d->getCurrentState()->alias()); + result += d->getCurrentState()->altAliases(); return result; } -// Not sure about this function, maybe it is no more required +QStringList Room::localAliases() const +{ + return d->getCurrentState( + connection()->domain()) + ->aliases(); +} + QStringList Room::remoteAliases() const { QStringList result; @@ -1693,6 +1698,8 @@ void Room::setName(const QString& newName) d->requestSetState(newName); } +// Change might be required here as well. +// Not sure what will be best void Room::setCanonicalAlias(const QString& newAlias) { d->requestSetState(newAlias); @@ -1700,7 +1707,7 @@ void Room::setCanonicalAlias(const QString& newAlias) void Room::setLocalAliases(const QStringList& aliases) { - d->requestSetState(aliases); + d->requestSetState(this->canonicalAlias(), aliases); } void Room::setTopic(const QString& newTopic) @@ -2355,23 +2362,8 @@ Room::Changes Room::processStateEvent(const RoomEvent& e) } , [this,oldStateEvent] (const RoomAliasesEvent& ae) { // clang-format on - if (ae.aliases().isEmpty()) { - if (d->aliasServers.remove(ae.stateKey())) - qCDebug(STATE).noquote() - << ae.stateKey() << "no more has aliases for room" - << objectName(); - } else { - d->aliasServers.insert(ae.stateKey()); - qCDebug(STATE).nospace().noquote() - << "New server with aliases for room " << objectName() - << ": " << ae.stateKey(); - } - const auto previousAliases = - oldStateEvent - ? static_cast(oldStateEvent)->aliases() - : QStringList(); - connection()->updateRoomAliases(id(), previousAliases, ae.aliases()); - return OtherChange; + // This event has been removed by MSC-2432 + return NoChange; // clang-format off } , [this, oldStateEvent] (const RoomCanonicalAliasEvent& cae) { @@ -2386,7 +2378,7 @@ Room::Changes Room::processStateEvent(const RoomEvent& e) auto previousAltAliases = oldStateEvent ? static_cast(oldStateEvent) - ->alt_aliases() + ->altAliases() : QStringList(); if (!previousCanonicalAlias.isEmpty()) { @@ -2395,7 +2387,7 @@ Room::Changes Room::processStateEvent(const RoomEvent& e) const auto previousAliases = std::move(previousAltAliases); - auto newAliases = cae.alt_aliases(); + auto newAliases = cae.altAliases(); if (!cae.alias().isEmpty()) { newAliases.push_front(cae.alias()); @@ -2651,7 +2643,7 @@ QString Room::Private::calculateDisplayname() const return dispName; // 3. m.room.aliases - only local aliases, subject for further removal - const auto aliases = q->localAliases(); + const auto aliases = q->aliases(); if (!aliases.isEmpty()) return aliases.front(); diff --git a/lib/room.h b/lib/room.h index ad19792e..4d2527f7 100644 --- a/lib/room.h +++ b/lib/room.h @@ -188,11 +188,14 @@ public: QString name() const; /// Room aliases defined on the current user's server /// \sa remoteAliases, setLocalAliases + [[deprecated("Use aliases()")]] QStringList localAliases() const; /// Room aliases defined on other servers /// \sa localAliases + [[deprecated("Use aliases()")]] QStringList remoteAliases() const; QString canonicalAlias() const; + QStringList aliases() const; QString displayName() const; QString topic() const; QString avatarMediaId() const; -- cgit v1.2.3 From a2177b704c06bccc4840607803bca4fbe747830b Mon Sep 17 00:00:00 2001 From: Ram Nad Date: Fri, 20 Mar 2020 13:12:42 +0530 Subject: added altAliases() --- lib/room.cpp | 9 +++++++-- lib/room.h | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/room.cpp b/lib/room.cpp index fa3f10a6..60b36911 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -439,6 +439,11 @@ QStringList Room::aliases() const return result; } +QStringList Room::altAliases() const +{ + return d->getCurrentState()->altAliases(); +} + QStringList Room::localAliases() const { return d->getCurrentState( @@ -1702,7 +1707,7 @@ void Room::setName(const QString& newName) // Not sure what will be best void Room::setCanonicalAlias(const QString& newAlias) { - d->requestSetState(newAlias); + d->requestSetState(newAlias, this->altAliases()); } void Room::setLocalAliases(const QStringList& aliases) @@ -2394,7 +2399,7 @@ Room::Changes Room::processStateEvent(const RoomEvent& e) } connection()->updateRoomAliases(id(), previousAliases, newAliases); - return CanonicalAliasChange; + return AliasesChange; // clang-format off } , [] (const RoomTopicEvent&) { diff --git a/lib/room.h b/lib/room.h index 4d2527f7..d5fea94f 100644 --- a/lib/room.h +++ b/lib/room.h @@ -141,7 +141,8 @@ public: enum Change : uint { NoChange = 0x0, NameChange = 0x1, - CanonicalAliasChange = 0x2, + AliasesChange = 0x2, + CanonicalAliasChange = AliasesChange, TopicChange = 0x4, UnreadNotifsChange = 0x8, AvatarChange = 0x10, @@ -195,6 +196,7 @@ public: [[deprecated("Use aliases()")]] QStringList remoteAliases() const; QString canonicalAlias() const; + QStringList altAliases() const; QStringList aliases() const; QString displayName() const; QString topic() const; -- cgit v1.2.3 From 57ed7c21829347bd553a481becc6484164419c18 Mon Sep 17 00:00:00 2001 From: Ram Nad Date: Fri, 20 Mar 2020 13:28:05 +0530 Subject: dont use this --- lib/room.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/room.cpp b/lib/room.cpp index 60b36911..77b4a1e5 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -1707,12 +1707,12 @@ void Room::setName(const QString& newName) // Not sure what will be best void Room::setCanonicalAlias(const QString& newAlias) { - d->requestSetState(newAlias, this->altAliases()); + d->requestSetState(newAlias, altAliases()); } void Room::setLocalAliases(const QStringList& aliases) { - d->requestSetState(this->canonicalAlias(), aliases); + d->requestSetState(canonicalAlias(), aliases); } void Room::setTopic(const QString& newTopic) -- cgit v1.2.3 From ecdab8ba9d2f411e5cfb049866501f159725a3db Mon Sep 17 00:00:00 2001 From: Ram Nad Date: Fri, 20 Mar 2020 15:01:08 +0530 Subject: Make constructor explicit lib/events/roomcanonicalaliasevent.h Co-Authored-By: Kitsune Ral --- lib/events/roomcanonicalaliasevent.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/events/roomcanonicalaliasevent.h b/lib/events/roomcanonicalaliasevent.h index 012cac75..0c30db8b 100644 --- a/lib/events/roomcanonicalaliasevent.h +++ b/lib/events/roomcanonicalaliasevent.h @@ -57,7 +57,7 @@ public: : StateEvent(typeId(), obj) { } - RoomCanonicalAliasEvent(const QString& canonicalAlias, const QStringList& altAliases = {}) + explicit RoomCanonicalAliasEvent(const QString& canonicalAlias, const QStringList& altAliases = {}) : StateEvent(typeId(), matrixTypeId(), QString(), canonicalAlias, altAliases) { } -- cgit v1.2.3 From 153c1c66c7cc162920e5d4e4d902efcadf015d5b Mon Sep 17 00:00:00 2001 From: Ram Nad Date: Fri, 20 Mar 2020 15:01:55 +0530 Subject: Make rvalue constructor explicit Update lib/events/roomcanonicalaliasevent.h Co-Authored-By: Kitsune Ral --- lib/events/roomcanonicalaliasevent.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/events/roomcanonicalaliasevent.h b/lib/events/roomcanonicalaliasevent.h index 0c30db8b..311a5959 100644 --- a/lib/events/roomcanonicalaliasevent.h +++ b/lib/events/roomcanonicalaliasevent.h @@ -62,7 +62,7 @@ public: canonicalAlias, altAliases) { } - RoomCanonicalAliasEvent(QString&& canonicalAlias, QStringList&& altAliases = {}) + explicit RoomCanonicalAliasEvent(QString&& canonicalAlias, QStringList&& altAliases = {}) : StateEvent(typeId(), matrixTypeId(), QString(), std::move(canonicalAlias), std::move(altAliases)) { } -- cgit v1.2.3 From f9dee85c5f8eb35df14a29d011c3cb84915962a6 Mon Sep 17 00:00:00 2001 From: Ram Nad Date: Fri, 20 Mar 2020 15:06:21 +0530 Subject: emit nameChanged() on AliasesChange --- lib/room.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/room.cpp b/lib/room.cpp index 77b4a1e5..5f96a5f9 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -108,7 +108,6 @@ public: QHash currentState; /// Servers with aliases for this room except the one of the local user /// \sa Room::remoteAliases - QSet aliasServers; Timeline timeline; @@ -1423,7 +1422,7 @@ void Room::updateData(SyncRoomData&& data, bool fromCache) if (roomChanges & TopicChange) emit topicChanged(); - if (roomChanges & NameChange) + if (roomChanges & (NameChange | AliasesChange)) emit namesChanged(this); if (roomChanges & MembersChange) @@ -1703,8 +1702,6 @@ void Room::setName(const QString& newName) d->requestSetState(newName); } -// Change might be required here as well. -// Not sure what will be best void Room::setCanonicalAlias(const QString& newAlias) { d->requestSetState(newAlias, altAliases()); -- cgit v1.2.3 From ed62c822ca200613bde60e48547ba32a0bd21c13 Mon Sep 17 00:00:00 2001 From: Ram Nad Date: Sat, 21 Mar 2020 17:18:40 +0530 Subject: Update aliases code lib/room.cpp Co-Authored-By: Kitsune Ral --- lib/room.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/room.cpp b/lib/room.cpp index 5f96a5f9..403c024b 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -433,9 +433,8 @@ QString Room::name() const QStringList Room::aliases() const { - QStringList result(d->getCurrentState()->alias()); - result += d->getCurrentState()->altAliases(); - return result; + const auto* evt = d->getCurrentState(); + return QStringList(evt->altAliases()) << evt->alias(); } QStringList Room::altAliases() const -- cgit v1.2.3