diff --git a/include/MatrixClient.h b/include/MatrixClient.h index b2765c0..422e4cf 100644 --- a/include/MatrixClient.h +++ b/include/MatrixClient.h @@ -62,7 +62,7 @@ public: QUrl getHomeServer() { return server_; }; int transactionId() { return txn_id_; }; - int incrementTransactionId() { return ++txn_id_; }; // It is incredibly important that it's incremented first. + int incrementTransactionId() { return ++txn_id_; }; void reset() noexcept; diff --git a/include/TimelineView.h b/include/TimelineView.h index af0e938..bc7c41e 100644 --- a/include/TimelineView.h +++ b/include/TimelineView.h @@ -50,7 +50,12 @@ struct PendingMessage QString event_id; TimelineItem *widget; - PendingMessage(matrix::events::MessageEventType ty, int txn_id, QString body, QString filename, QString event_id, TimelineItem *widget) + PendingMessage(matrix::events::MessageEventType ty, + int txn_id, + QString body, + QString filename, + QString event_id, + TimelineItem *widget) : ty(ty) , txn_id(txn_id) , body(body) @@ -125,9 +130,7 @@ private: // sender's name. bool isSenderRendered(const QString &user_id, TimelineDirection direction); - bool isPendingMessage(const QString &txnid, - const QString &sender, - const QString &userid); + bool isPendingMessage(const QString &txnid, const QString &sender, const QString &userid); void removePendingMessage(const QString &txnid); bool isDuplicate(const QString &event_id) { return eventIds_.contains(event_id); }; diff --git a/src/TimelineView.cc b/src/TimelineView.cc index 0e45bf6..b1fb2ad 100644 --- a/src/TimelineView.cc +++ b/src/TimelineView.cc @@ -247,7 +247,8 @@ TimelineView::parseMessageEvent(const QJsonObject &event, TimelineDirection dire eventIds_[text.eventId()] = true; QString txnid = text.unsignedData().transactionId(); - if (!txnid.isEmpty() && isPendingMessage(txnid, text.sender(), local_user_)) { + if (!txnid.isEmpty() && + isPendingMessage(txnid, text.sender(), local_user_)) { removePendingMessage(txnid); return nullptr; } @@ -293,7 +294,8 @@ TimelineView::parseMessageEvent(const QJsonObject &event, TimelineDirection dire eventIds_[img.eventId()] = true; QString txnid = img.unsignedData().transactionId(); - if (!txnid.isEmpty() && isPendingMessage(txnid, img.sender(), local_user_)) { + if (!txnid.isEmpty() && + isPendingMessage(txnid, img.sender(), local_user_)) { removePendingMessage(txnid); return nullptr; } @@ -319,7 +321,8 @@ TimelineView::parseMessageEvent(const QJsonObject &event, TimelineDirection dire eventIds_[emote.eventId()] = true; QString txnid = emote.unsignedData().transactionId(); - if (!txnid.isEmpty() && isPendingMessage(txnid, emote.sender(), local_user_)) { + if (!txnid.isEmpty() && + isPendingMessage(txnid, emote.sender(), local_user_)) { removePendingMessage(txnid); return nullptr; } @@ -499,7 +502,7 @@ void TimelineView::updatePendingMessage(int txn_id, QString event_id) { if (pending_msgs_.head().txn_id == txn_id) { // We haven't received it yet - auto msg = pending_msgs_.dequeue(); + auto msg = pending_msgs_.dequeue(); msg.event_id = event_id; pending_sent_msgs_.append(msg); } @@ -546,7 +549,8 @@ TimelineView::addUserMessage(const QString &url, const QString &filename) lastSender_ = user_id; int txn_id = client_->incrementTransactionId(); - PendingMessage message(matrix::events::MessageEventType::Image, txn_id, url, filename, "", view_item); + PendingMessage message( + matrix::events::MessageEventType::Image, txn_id, url, filename, "", view_item); handleNewUserMessage(message); } @@ -567,7 +571,8 @@ TimelineView::sendNextPendingMessage() PendingMessage &m = pending_msgs_.head(); switch (m.ty) { case matrix::events::MessageEventType::Image: - client_->sendRoomMessage(m.ty, m.txn_id, room_id_, QFileInfo(m.filename).fileName(), m.body); + client_->sendRoomMessage( + m.ty, m.txn_id, room_id_, QFileInfo(m.filename).fileName(), m.body); break; default: client_->sendRoomMessage(m.ty, m.txn_id, room_id_, m.body); diff --git a/src/TimelineViewManager.cc b/src/TimelineViewManager.cc index 35c2a56..ec7b844 100644 --- a/src/TimelineViewManager.cc +++ b/src/TimelineViewManager.cc @@ -36,9 +36,10 @@ TimelineViewManager::TimelineViewManager(QSharedPointer client, QW connect( client_.data(), &MatrixClient::messageSent, this, &TimelineViewManager::messageSent); - connect( - client_.data(), &MatrixClient::messageSendFailed, - this, &TimelineViewManager::messageSendFailed); + connect(client_.data(), + &MatrixClient::messageSendFailed, + this, + &TimelineViewManager::messageSendFailed); } TimelineViewManager::~TimelineViewManager() {} @@ -81,8 +82,8 @@ TimelineViewManager::queueEmoteMessage(const QString &msg) void TimelineViewManager::queueImageMessage(const QString &roomid, - const QString &filename, - const QString &url) + const QString &filename, + const QString &url) { if (!views_.contains(roomid)) { qDebug() << "Cannot send m.image message to a non-managed view";