mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 03:00:46 +03:00
check for empty alias and percent encoding for alias in url
This commit is contained in:
parent
0b6c82dfff
commit
3ea0e79a36
1 changed files with 8 additions and 3 deletions
|
@ -1,5 +1,7 @@
|
|||
#include "RoomsModel.h"
|
||||
|
||||
#include <QUrl>
|
||||
|
||||
#include "Cache_p.h"
|
||||
#include "CompletionModelRoles.h"
|
||||
|
||||
|
@ -14,7 +16,7 @@ RoomsModel::RoomsModel(bool showOnlyRoomWithAliases, QObject *parent)
|
|||
auto roomAliasesList = cache::client()->getRoomAliases(r);
|
||||
|
||||
if (showOnlyRoomWithAliases_) {
|
||||
if (roomAliasesList) {
|
||||
if (roomAliasesList && !roomAliasesList->alias.empty()) {
|
||||
roomids.push_back(QString::fromStdString(r));
|
||||
roomAliases.push_back(
|
||||
QString::fromStdString(roomAliasesList->alias));
|
||||
|
@ -44,8 +46,11 @@ RoomsModel::data(const QModelIndex &index, int role) const
|
|||
{
|
||||
if (hasIndex(index.row(), index.column(), index.parent())) {
|
||||
switch (role) {
|
||||
case CompletionModel::CompletionRole:
|
||||
return QString("[%1](https://matrix.to/%1)").arg(roomAliases[index.row()]);
|
||||
case CompletionModel::CompletionRole: {
|
||||
QString percentEncoding = QUrl::toPercentEncoding(roomAliases[index.row()]);
|
||||
return QString("[%1](https://matrix.to/#/%2)")
|
||||
.arg(roomAliases[index.row()], percentEncoding);
|
||||
}
|
||||
case CompletionModel::SearchRole:
|
||||
case Qt::DisplayRole:
|
||||
case Roles::RoomAlias:
|
||||
|
|
Loading…
Reference in a new issue