From 2a687a202af605763ce49880cf11379ce4c95d44 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Mon, 9 Oct 2023 00:20:30 +0200 Subject: [PATCH] Fix typing notifications --- src/timeline/EventDelegateChooser.cpp | 4 ++-- src/timeline/EventDelegateChooser.h | 6 +++--- src/timeline/RoomlistModel.cpp | 2 +- src/timeline/TimelineModel.cpp | 5 +++-- src/timeline/TimelineModel.h | 14 +++++++------- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/timeline/EventDelegateChooser.cpp b/src/timeline/EventDelegateChooser.cpp index a8629b3e..e2319460 100644 --- a/src/timeline/EventDelegateChooser.cpp +++ b/src/timeline/EventDelegateChooser.cpp @@ -203,7 +203,7 @@ EventDelegateChooser::DelegateIncubator::setInitialState(QObject *obj) }; if (!forReply) { - auto row = chooser.room_->idToIndex(currentId); + auto row = chooser.room_->idToIndex(currentId); auto connection = connect( chooser.room_, &QAbstractItemModel::dataChanged, @@ -293,7 +293,7 @@ EventDelegateChooser::DelegateIncubator::statusChanged(QQmlIncubator::Status sta void EventDelegateChooser::updatePolish() { - auto mainChild = qobject_cast(eventIncubator.object()); + auto mainChild = qobject_cast(eventIncubator.object()); auto replyChild = qobject_cast(replyIncubator.object()); nhlog::ui()->critical("POLISHING {}", (void *)this); diff --git a/src/timeline/EventDelegateChooser.h b/src/timeline/EventDelegateChooser.h index ce79444a..df1953ab 100644 --- a/src/timeline/EventDelegateChooser.h +++ b/src/timeline/EventDelegateChooser.h @@ -84,8 +84,8 @@ signals: private: void polishChooser(); - double aspectRatio_ = 1.; - int maxWidth_ = -1; + double aspectRatio_ = 1.; + int maxWidth_ = -1; int maxHeight_ = -1; bool keepAspectRatio_ = false; bool isReply_ = false; @@ -252,7 +252,7 @@ private: QString currentId; QString instantiatedId; - int instantiatedRole = -1; + int instantiatedRole = -1; QAbstractItemModel *instantiatedModel = nullptr; int oldType = -1; }; diff --git a/src/timeline/RoomlistModel.cpp b/src/timeline/RoomlistModel.cpp index 8d8d2977..2bffc9be 100644 --- a/src/timeline/RoomlistModel.cpp +++ b/src/timeline/RoomlistModel.cpp @@ -541,7 +541,7 @@ RoomlistModel::sync(const mtx::responses::Sync &sync_) if (auto t = std::get_if>( &ev)) { - std::vector typing; + QStringList typing; typing.reserve(t->content.user_ids.size()); for (const auto &user : t->content.user_ids) { if (user != http::client()->user_id().to_string()) diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index f5b9e142..c2bcfeb5 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -2288,8 +2288,9 @@ TimelineModel::markSpecialEffectsDone() } QString -TimelineModel::formatTypingUsers(const std::vector &users, const QColor &bg) +TimelineModel::formatTypingUsers(const QStringList &users, const QColor &bg) { + nhlog::db()->critical("TYPING USERS!"); QString temp = tr("%1 and %2 are typing.", "Multiple users are typing. First argument is a comma separated list of potentially " @@ -2335,7 +2336,7 @@ TimelineModel::formatTypingUsers(const std::vector &users, const QColor }; uidWithoutLast.reserve(static_cast(users.size())); - for (size_t i = 0; i + 1 < users.size(); i++) { + for (qsizetype i = 0; i + 1 < users.size(); i++) { uidWithoutLast.append(formatUser(users[i])); } diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h index 8f787f21..23c3c802 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h @@ -199,8 +199,8 @@ class TimelineModel final : public QAbstractListModel QML_UNCREATABLE("") Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) - Q_PROPERTY(std::vector typingUsers READ typingUsers WRITE updateTypingUsers NOTIFY - typingUsersChanged) + Q_PROPERTY( + QStringList typingUsers READ typingUsers WRITE updateTypingUsers NOTIFY typingUsersChanged) Q_PROPERTY(QString scrollTarget READ scrollTarget NOTIFY scrollTargetChanged) Q_PROPERTY(QString reply READ reply WRITE setReply NOTIFY replyChanged RESET resetReply) Q_PROPERTY(QString edit READ edit WRITE setEdit NOTIFY editChanged RESET resetEdit) @@ -306,7 +306,7 @@ public: Q_INVOKABLE QString displayName(const QString &id) const; Q_INVOKABLE QString avatarUrl(const QString &id) const; Q_INVOKABLE QString formatDateSeparator(QDate date) const; - Q_INVOKABLE QString formatTypingUsers(const std::vector &users, const QColor &bg); + Q_INVOKABLE QString formatTypingUsers(const QStringList &users, const QColor &bg); Q_INVOKABLE bool showAcceptKnockButton(const QString &id); Q_INVOKABLE void acceptKnock(const QString &id); Q_INVOKABLE void joinReplacementRoom(const QString &id); @@ -405,14 +405,14 @@ public slots: void lastReadIdOnWindowFocus(); void checkAfterFetch(); QVariantMap getDump(const QString &eventId, const QString &relatedTo) const; - void updateTypingUsers(const std::vector &users) + void updateTypingUsers(const QStringList &users) { if (this->typingUsers_ != users) { this->typingUsers_ = users; emit typingUsersChanged(typingUsers_); } } - std::vector typingUsers() const { return typingUsers_; } + QStringList typingUsers() const { return typingUsers_; } bool paginationInProgress() const { return m_paginationInProgress; } QString reply() const { return reply_; } void setReply(const QString &newReply); @@ -470,7 +470,7 @@ signals: void redactionFailed(QString id); void mediaCached(QString mxcUrl, QString cacheUrl); void newEncryptedImage(mtx::crypto::EncryptedFile encryptionInfo); - void typingUsersChanged(std::vector users); + void typingUsersChanged(QStringList users); void replyChanged(QString reply); void editChanged(QString reply); void threadChanged(QString id); @@ -528,7 +528,7 @@ private: QString currentId, currentReadId; QString reply_, edit_, thread_; QString textBeforeEdit, replyBeforeEdit; - std::vector typingUsers_; + QStringList typingUsers_; TimelineViewManager *manager_;