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

@ -203,7 +203,7 @@ EventDelegateChooser::DelegateIncubator::setInitialState(QObject *obj)
}; };
if (!forReply) { if (!forReply) {
auto row = chooser.room_->idToIndex(currentId); auto row = chooser.room_->idToIndex(currentId);
auto connection = connect( auto connection = connect(
chooser.room_, chooser.room_,
&QAbstractItemModel::dataChanged, &QAbstractItemModel::dataChanged,
@ -293,7 +293,7 @@ EventDelegateChooser::DelegateIncubator::statusChanged(QQmlIncubator::Status sta
void void
EventDelegateChooser::updatePolish() EventDelegateChooser::updatePolish()
{ {
auto mainChild = qobject_cast<QQuickItem *>(eventIncubator.object()); auto mainChild = qobject_cast<QQuickItem *>(eventIncubator.object());
auto replyChild = qobject_cast<QQuickItem *>(replyIncubator.object()); auto replyChild = qobject_cast<QQuickItem *>(replyIncubator.object());
nhlog::ui()->critical("POLISHING {}", (void *)this); nhlog::ui()->critical("POLISHING {}", (void *)this);

View file

@ -84,8 +84,8 @@ signals:
private: private:
void polishChooser(); void polishChooser();
double aspectRatio_ = 1.; double aspectRatio_ = 1.;
int maxWidth_ = -1; int maxWidth_ = -1;
int maxHeight_ = -1; int maxHeight_ = -1;
bool keepAspectRatio_ = false; bool keepAspectRatio_ = false;
bool isReply_ = false; bool isReply_ = false;
@ -252,7 +252,7 @@ private:
QString currentId; QString currentId;
QString instantiatedId; QString instantiatedId;
int instantiatedRole = -1; int instantiatedRole = -1;
QAbstractItemModel *instantiatedModel = nullptr; QAbstractItemModel *instantiatedModel = nullptr;
int oldType = -1; int oldType = -1;
}; };

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_;