Fix typing notifications

This commit is contained in:
Nicolas Werner 2023-10-09 00:20:30 +02:00
parent c4d2ec875d
commit 2a687a202a
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
5 changed files with 16 additions and 15 deletions

View file

@ -541,7 +541,7 @@ RoomlistModel::sync(const mtx::responses::Sync &sync_)
if (auto t = if (auto t =
std::get_if<mtx::events::EphemeralEvent<mtx::events::ephemeral::Typing>>( std::get_if<mtx::events::EphemeralEvent<mtx::events::ephemeral::Typing>>(
&ev)) { &ev)) {
std::vector<QString> typing; QStringList typing;
typing.reserve(t->content.user_ids.size()); typing.reserve(t->content.user_ids.size());
for (const auto &user : t->content.user_ids) { for (const auto &user : t->content.user_ids) {
if (user != http::client()->user_id().to_string()) if (user != http::client()->user_id().to_string())

View file

@ -2288,8 +2288,9 @@ TimelineModel::markSpecialEffectsDone()
} }
QString QString
TimelineModel::formatTypingUsers(const std::vector<QString> &users, const QColor &bg) TimelineModel::formatTypingUsers(const QStringList &users, const QColor &bg)
{ {
nhlog::db()->critical("TYPING USERS!");
QString temp = QString temp =
tr("%1 and %2 are typing.", tr("%1 and %2 are typing.",
"Multiple users are typing. First argument is a comma separated list of potentially " "Multiple users are typing. First argument is a comma separated list of potentially "
@ -2335,7 +2336,7 @@ TimelineModel::formatTypingUsers(const std::vector<QString> &users, const QColor
}; };
uidWithoutLast.reserve(static_cast<int>(users.size())); uidWithoutLast.reserve(static_cast<int>(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])); uidWithoutLast.append(formatUser(users[i]));
} }

View file

@ -199,8 +199,8 @@ class TimelineModel final : public QAbstractListModel
QML_UNCREATABLE("") QML_UNCREATABLE("")
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
Q_PROPERTY(std::vector<QString> typingUsers READ typingUsers WRITE updateTypingUsers NOTIFY Q_PROPERTY(
typingUsersChanged) QStringList typingUsers READ typingUsers WRITE updateTypingUsers NOTIFY typingUsersChanged)
Q_PROPERTY(QString scrollTarget READ scrollTarget NOTIFY scrollTargetChanged) Q_PROPERTY(QString scrollTarget READ scrollTarget NOTIFY scrollTargetChanged)
Q_PROPERTY(QString reply READ reply WRITE setReply NOTIFY replyChanged RESET resetReply) Q_PROPERTY(QString reply READ reply WRITE setReply NOTIFY replyChanged RESET resetReply)
Q_PROPERTY(QString edit READ edit WRITE setEdit NOTIFY editChanged RESET resetEdit) 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 displayName(const QString &id) const;
Q_INVOKABLE QString avatarUrl(const QString &id) const; Q_INVOKABLE QString avatarUrl(const QString &id) const;
Q_INVOKABLE QString formatDateSeparator(QDate date) const; Q_INVOKABLE QString formatDateSeparator(QDate date) const;
Q_INVOKABLE QString formatTypingUsers(const std::vector<QString> &users, const QColor &bg); Q_INVOKABLE QString formatTypingUsers(const QStringList &users, const QColor &bg);
Q_INVOKABLE bool showAcceptKnockButton(const QString &id); Q_INVOKABLE bool showAcceptKnockButton(const QString &id);
Q_INVOKABLE void acceptKnock(const QString &id); Q_INVOKABLE void acceptKnock(const QString &id);
Q_INVOKABLE void joinReplacementRoom(const QString &id); Q_INVOKABLE void joinReplacementRoom(const QString &id);
@ -405,14 +405,14 @@ public slots:
void lastReadIdOnWindowFocus(); void lastReadIdOnWindowFocus();
void checkAfterFetch(); void checkAfterFetch();
QVariantMap getDump(const QString &eventId, const QString &relatedTo) const; QVariantMap getDump(const QString &eventId, const QString &relatedTo) const;
void updateTypingUsers(const std::vector<QString> &users) void updateTypingUsers(const QStringList &users)
{ {
if (this->typingUsers_ != users) { if (this->typingUsers_ != users) {
this->typingUsers_ = users; this->typingUsers_ = users;
emit typingUsersChanged(typingUsers_); emit typingUsersChanged(typingUsers_);
} }
} }
std::vector<QString> typingUsers() const { return typingUsers_; } QStringList typingUsers() const { return typingUsers_; }
bool paginationInProgress() const { return m_paginationInProgress; } bool paginationInProgress() const { return m_paginationInProgress; }
QString reply() const { return reply_; } QString reply() const { return reply_; }
void setReply(const QString &newReply); void setReply(const QString &newReply);
@ -470,7 +470,7 @@ signals:
void redactionFailed(QString id); void redactionFailed(QString id);
void mediaCached(QString mxcUrl, QString cacheUrl); void mediaCached(QString mxcUrl, QString cacheUrl);
void newEncryptedImage(mtx::crypto::EncryptedFile encryptionInfo); void newEncryptedImage(mtx::crypto::EncryptedFile encryptionInfo);
void typingUsersChanged(std::vector<QString> users); void typingUsersChanged(QStringList users);
void replyChanged(QString reply); void replyChanged(QString reply);
void editChanged(QString reply); void editChanged(QString reply);
void threadChanged(QString id); void threadChanged(QString id);
@ -528,7 +528,7 @@ private:
QString currentId, currentReadId; QString currentId, currentReadId;
QString reply_, edit_, thread_; QString reply_, edit_, thread_;
QString textBeforeEdit, replyBeforeEdit; QString textBeforeEdit, replyBeforeEdit;
std::vector<QString> typingUsers_; QStringList typingUsers_;
TimelineViewManager *manager_; TimelineViewManager *manager_;