|
|
|
@ -144,14 +144,26 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj |
|
|
|
|
, room_id_(room_id) |
|
|
|
|
, manager_(manager) |
|
|
|
|
{ |
|
|
|
|
connect(this, |
|
|
|
|
&TimelineModel::oldMessagesRetrieved, |
|
|
|
|
this, |
|
|
|
|
&TimelineModel::addBackwardsEvents, |
|
|
|
|
Qt::QueuedConnection); |
|
|
|
|
connect( |
|
|
|
|
this, &TimelineModel::oldMessagesRetrieved, this, &TimelineModel::addBackwardsEvents); |
|
|
|
|
connect(this, &TimelineModel::messageFailed, this, [this](QString txn_id) { |
|
|
|
|
this, |
|
|
|
|
&TimelineModel::messageFailed, |
|
|
|
|
this, |
|
|
|
|
[this](QString txn_id) { |
|
|
|
|
nhlog::ui()->error("Failed to send {}, retrying", txn_id.toStdString()); |
|
|
|
|
|
|
|
|
|
QTimer::singleShot(5000, this, [this]() { emit nextPendingMessage(); }); |
|
|
|
|
}); |
|
|
|
|
connect(this, &TimelineModel::messageSent, this, [this](QString txn_id, QString event_id) { |
|
|
|
|
}, |
|
|
|
|
Qt::QueuedConnection); |
|
|
|
|
connect( |
|
|
|
|
this, |
|
|
|
|
&TimelineModel::messageSent, |
|
|
|
|
this, |
|
|
|
|
[this](QString txn_id, QString event_id) { |
|
|
|
|
pending.removeOne(txn_id); |
|
|
|
|
|
|
|
|
|
auto ev = events.value(txn_id); |
|
|
|
@ -191,25 +203,37 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj |
|
|
|
|
|
|
|
|
|
if (pending.size() > 0) |
|
|
|
|
emit nextPendingMessage(); |
|
|
|
|
}); |
|
|
|
|
connect(this, &TimelineModel::redactionFailed, this, [](const QString &msg) { |
|
|
|
|
emit ChatPage::instance()->showNotification(msg); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
Qt::QueuedConnection); |
|
|
|
|
connect( |
|
|
|
|
this, &TimelineModel::nextPendingMessage, this, &TimelineModel::processOnePendingMessage); |
|
|
|
|
connect(this, &TimelineModel::newMessageToSend, this, &TimelineModel::addPendingMessage); |
|
|
|
|
this, |
|
|
|
|
&TimelineModel::redactionFailed, |
|
|
|
|
this, |
|
|
|
|
[](const QString &msg) { emit ChatPage::instance()->showNotification(msg); }, |
|
|
|
|
Qt::QueuedConnection); |
|
|
|
|
|
|
|
|
|
connect(this, |
|
|
|
|
&TimelineModel::nextPendingMessage, |
|
|
|
|
this, |
|
|
|
|
&TimelineModel::processOnePendingMessage, |
|
|
|
|
Qt::QueuedConnection); |
|
|
|
|
connect(this, |
|
|
|
|
&TimelineModel::newMessageToSend, |
|
|
|
|
this, |
|
|
|
|
&TimelineModel::addPendingMessage, |
|
|
|
|
Qt::QueuedConnection); |
|
|
|
|
|
|
|
|
|
connect( |
|
|
|
|
this, |
|
|
|
|
&TimelineModel::eventFetched, |
|
|
|
|
this, |
|
|
|
|
[this](QString requestingEvent, mtx::events::collections::TimelineEvents event) { |
|
|
|
|
events.insert(QString::fromStdString(mtx::accessors::event_id(event)), |
|
|
|
|
event); |
|
|
|
|
events.insert(QString::fromStdString(mtx::accessors::event_id(event)), event); |
|
|
|
|
auto idx = idToIndex(requestingEvent); |
|
|
|
|
if (idx >= 0) |
|
|
|
|
emit dataChanged(index(idx, 0), index(idx, 0)); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
Qt::QueuedConnection); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QHash<int, QByteArray> |
|
|
|
|