RoomManager: Unify the resolveResource overloads

Every time I look at how resource resolving works, I always trip over
this unused overload. This behaves *different* than the other overload,
which has special cases for handling invalid Uris.

Now whether you pass in a Uri or a QString, it should behave the same.

(cherry picked from commit 55362c5573)
This commit is contained in:
Joshua Goins
2024-11-15 22:42:29 -05:00
parent 0c08c2ab89
commit d6ecaaa344
2 changed files with 16 additions and 17 deletions

View File

@@ -134,16 +134,15 @@ void RoomManager::activateUserModel()
m_userListModel->activate();
}
UriResolveResult RoomManager::resolveResource(const Uri &uri)
{
return UriResolverBase::visitResource(m_connection, uri);
}
void RoomManager::resolveResource(const QString &idOrUri, const QString &action)
{
Uri uri{idOrUri};
resolveResource(Uri{idOrUri}, action);
}
void RoomManager::resolveResource(Uri uri, const QString &action)
{
if (!uri.isValid()) {
Q_EMIT showMessage(MessageType::Warning, i18n("Malformed or empty Matrix id<br />%1 is not a correct Matrix identifier", idOrUri));
Q_EMIT showMessage(MessageType::Warning, i18n("Malformed or empty Matrix id<br />%1 is not a correct Matrix identifier", uri.toDisplayString()));
return;
}

View File

@@ -168,16 +168,6 @@ public:
UserListModel *userListModel() const;
Q_INVOKABLE void activateUserModel();
/**
* @brief Resolve the given URI resource.
*
* @note It's actually Quotient::UriResolverBase::visitResource() but with Q_INVOKABLE
* and the connection grabbed from RoomManager.
*
* @sa Quotient::UriResolverBase::visitResource()
*/
Q_INVOKABLE UriResolveResult resolveResource(const Uri &uri);
/**
* @brief Resolve the given resource.
*
@@ -188,6 +178,16 @@ public:
*/
Q_INVOKABLE void resolveResource(const QString &idOrUri, const QString &action = {});
/**
* @brief Resolve the given resource URI.
*
* @note It's actually Quotient::UriResolverBase::visitResource() but with Q_INVOKABLE
* and the connection grabbed from RoomManager.
*
* @sa Quotient::UriResolverBase::visitResource()
*/
Q_INVOKABLE void resolveResource(Uri uri, const QString &action = {});
bool hasOpenRoom() const;
/**