diff --git a/autotests/roommanagertest.cpp b/autotests/roommanagertest.cpp index f2962967a..3f1e1571c 100644 --- a/autotests/roommanagertest.cpp +++ b/autotests/roommanagertest.cpp @@ -28,6 +28,7 @@ private: private Q_SLOTS: void initTestCase(); void testMaximizeMedia(); + void testResolveMatrixLinks(); }; void RoomManagerTest::initTestCase() @@ -128,5 +129,13 @@ void RoomManagerTest::testMaximizeMedia() QVERIFY(spy[1][0] == 0); } +void RoomManagerTest::testResolveMatrixLinks() +{ + // Test if resolving a non-joined room will bring up the confirmation dialog. + const QSignalSpy askToJoinSpy(&RoomManager::instance(), &RoomManager::askJoinRoom); + RoomManager::instance().resolveResource(QStringLiteral("matrix:r/testbuild:matrix.org"), QStringLiteral("join")); + QTRY_COMPARE(askToJoinSpy.size(), 1); +} + QTEST_MAIN(RoomManagerTest) #include "roommanagertest.moc" diff --git a/src/app/qml/JoinRoomDialog.qml b/src/app/qml/JoinRoomDialog.qml index cce6de31f..7fc52313b 100644 --- a/src/app/qml/JoinRoomDialog.qml +++ b/src/app/qml/JoinRoomDialog.qml @@ -66,7 +66,7 @@ Kirigami.Dialog { text: i18nc("@action:button", "Join room") icon.name: "irc-join-channel" onClicked: { - RoomManager.resolveResource(root.room, "join"); + RoomManager.resolveResource(root.room, "join_confirmed"); root.close(); } } diff --git a/src/app/roommanager.cpp b/src/app/roommanager.cpp index 55cc58d91..f77fc1e79 100644 --- a/src/app/roommanager.cpp +++ b/src/app/roommanager.cpp @@ -214,19 +214,23 @@ void RoomManager::resolveResource(Uri uri, const QString &action) return; } + // For matrix URIs: if (uri.type() != Uri::NonMatrix) { if (!m_connection) { return; } - if (!action.isEmpty() && (uri.type() != Uri::UserId || action != "join"_L1)) { - uri.setAction(action); + // Once a join is confirmed, set the action to "join" so it skips the confirmation check. + if (action == "join_confirmed"_L1) { + uri.setAction(QStringLiteral("join")); } // TODO we should allow the user to select a connection. } const auto result = visitResource(m_connection, uri); + + // If we are not already in the room: if (result == Quotient::CouldNotResolve) { - if ((uri.type() == Uri::RoomAlias || uri.type() == Uri::RoomId) && action != "no_join"_L1) { + if ((uri.type() == Uri::RoomAlias || uri.type() == Uri::RoomId) && action == "join"_L1) { Q_EMIT askJoinRoom(uri.primaryId()); } }