Page MenuHomePhorge

matrix-room-list.cpp
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

matrix-room-list.cpp

/*
* This file is part of kazv.
* SPDX-FileCopyrightText: 2020 Tusooa Zhu <tusooa@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#include <libkazv-config.hpp>
#include <immer/config.hpp> // https://github.com/arximboldi/immer/issues/168
#include <lager/constant.hpp>
#include <lager/lenses/optional.hpp>
#include "matrix-room-list.hpp"
#include "matrix-room.hpp"
#include "helper.hpp"
MatrixRoomList::MatrixRoomList(Kazv::Client client, QObject *parent)
: QObject(parent)
, m_client(client)
, m_roomIds(m_client.roomIds())
, LAGER_QT(count)(m_roomIds.xform(containerSize))
, LAGER_QT(roomIds)(m_roomIds.xform(zug::map(
[](auto container) {
return zug::into(QStringList{}, strToQt, std::move(container));
})))
{
}
MatrixRoomList::~MatrixRoomList() = default;
MatrixRoom *MatrixRoomList::at(int index) const
{
qDebug() << "Room at index " << index << " requested";
return new MatrixRoom(
m_client.roomByCursor(
lager::with(m_roomIds, lager::make_constant(index))
.xform(zug::map([](auto ids, auto i) {
try {
return ids.at(i);
} catch (const std::out_of_range &) {
return std::string{};
}
}))));
}
QString MatrixRoomList::roomIdAt(int index) const
{
using namespace Kazv::CursorOp;
return +m_roomIds[index][lager::lenses::or_default].xform(strToQt);
}
MatrixRoom *MatrixRoomList::room(QString roomId) const
{
return new MatrixRoom(m_client.room(roomId.toStdString()));
}

File Metadata

Mime Type
text/x-c
Expires
Sun, Dec 1, 5:18 PM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41760
Default Alt Text
matrix-room-list.cpp (1 KB)

Event Timeline