mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Made only unjoined rooms joinable
This commit is contained in:
parent
f5ee1e84b5
commit
d3d7844106
2 changed files with 14 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "RoomDirectoryModel.h"
|
||||
#include "ChatPage.h"
|
||||
#include "Cache.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -68,6 +69,16 @@ RoomDirectoryModel::setSearchTerm(const QString &f)
|
|||
resetDisplayedData();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
RoomDirectoryModel::canJoinRoom(const QByteArray &room)
|
||||
{
|
||||
const auto &cache = cache::roomInfo();
|
||||
const QString room_id (room);
|
||||
const bool validRoom = !room_id.isNull() && !room_id.isEmpty();
|
||||
return validRoom && !cache.contains(room_id);
|
||||
}
|
||||
|
||||
std::vector<std::string>
|
||||
RoomDirectoryModel::getViasForRoom(const std::vector<std::string> &aliases)
|
||||
{
|
||||
|
@ -174,4 +185,4 @@ RoomDirectoryModel::displayRooms(std::vector<mtx::responses::PublicRoomsChunk> f
|
|||
}
|
||||
|
||||
prevBatch_ = std::exchange(nextBatch_, next_batch);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
}
|
||||
void fetchMore(const QModelIndex &) override;
|
||||
|
||||
Q_INVOKABLE bool canJoinRoom(const QByteArray &room);
|
||||
Q_INVOKABLE void joinRoom(const int &index = -1);
|
||||
|
||||
signals:
|
||||
|
@ -84,4 +85,4 @@ private:
|
|||
|
||||
std::vector<std::string> getViasForRoom(const std::vector<std::string> &room);
|
||||
void resetDisplayedData();
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue