Cleanup LocationsModel
Use libQuotient's event properties instead of accessing data from raw json
This commit is contained in:
committed by
Tobias Fella
parent
5d5295d06d
commit
9b65ae1e66
@@ -12,33 +12,27 @@ LocationsModel::LocationsModel(QObject *parent)
|
|||||||
{
|
{
|
||||||
connect(this, &LocationsModel::roomChanged, this, [this]() {
|
connect(this, &LocationsModel::roomChanged, this, [this]() {
|
||||||
for (const auto &event : m_room->messageEvents()) {
|
for (const auto &event : m_room->messageEvents()) {
|
||||||
if (!is<RoomMessageEvent>(*event)) {
|
if (const auto &roomMessageEvent = event.viewAs<RoomMessageEvent>()) {
|
||||||
continue;
|
if (roomMessageEvent->msgtype() == RoomMessageEvent::MsgType::Location) {
|
||||||
}
|
addLocation(roomMessageEvent);
|
||||||
if (event->contentJson()["msgtype"_L1] == "m.location"_L1) {
|
}
|
||||||
const auto &e = *event;
|
|
||||||
addLocation(eventCast<const RoomMessageEvent>(&e));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
connect(m_room, &NeoChatRoom::aboutToAddHistoricalMessages, this, [this](const auto &events) {
|
connect(m_room, &NeoChatRoom::aboutToAddHistoricalMessages, this, [this](const auto &events) {
|
||||||
for (const auto &event : events) {
|
for (const auto &event : events) {
|
||||||
if (!is<RoomMessageEvent>(*event)) {
|
if (const auto &roomMessageEvent = eventCast<const RoomMessageEvent>(event)) {
|
||||||
continue;
|
if (roomMessageEvent->msgtype() == RoomMessageEvent::MsgType::Location) {
|
||||||
}
|
addLocation(roomMessageEvent);
|
||||||
if (event->contentJson()["msgtype"_L1] == "m.location"_L1) {
|
}
|
||||||
const auto &e = *event;
|
|
||||||
addLocation(eventCast<const RoomMessageEvent>(&e));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(m_room, &NeoChatRoom::aboutToAddNewMessages, this, [this](const auto &events) {
|
connect(m_room, &NeoChatRoom::aboutToAddNewMessages, this, [this](const auto &events) {
|
||||||
for (const auto &event : events) {
|
for (const auto &event : events) {
|
||||||
if (!is<RoomMessageEvent>(*event)) {
|
if (const auto &roomMessageEvent = eventCast<const RoomMessageEvent>(event)) {
|
||||||
continue;
|
if (roomMessageEvent->msgtype() == RoomMessageEvent::MsgType::Location) {
|
||||||
}
|
addLocation(roomMessageEvent);
|
||||||
if (event->contentJson()["msgtype"_L1] == "m.location"_L1) {
|
}
|
||||||
const auto &e = *event;
|
|
||||||
addLocation(eventCast<const RoomMessageEvent>(&e));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user