diff options
author | Camila <hello@camila.codes> | 2022-03-28 17:03:38 +0300 |
---|---|---|
committer | Camila <hello@camila.codes> | 2022-03-28 17:04:54 +0300 |
commit | 7cc2486d79711ebd47ff1c2f35ed659619462abe (patch) | |
tree | 71a022354e438071b4cbb75f2925ab19afee834b /src | |
parent | 9b00e5268e8abbdcbca0da03b308fb2b6f70a849 (diff) |
Address PR comments.
Signed-off-by: Camila <hello@camila.codes>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/tray/ActivityItem.qml | 12 | ||||
-rw-r--r-- | src/gui/tray/ActivityItemContent.qml | 4 | ||||
-rw-r--r-- | src/gui/tray/TalkReplyTextField.qml | 11 | ||||
-rw-r--r-- | src/gui/tray/activitydata.h | 1 | ||||
-rw-r--r-- | src/gui/tray/activitylistmodel.cpp | 27 | ||||
-rw-r--r-- | src/gui/tray/activitylistmodel.h | 9 |
6 files changed, 29 insertions, 35 deletions
diff --git a/src/gui/tray/ActivityItem.qml b/src/gui/tray/ActivityItem.qml index e7bff5fe3..46c353f94 100644 --- a/src/gui/tray/ActivityItem.qml +++ b/src/gui/tray/ActivityItem.qml @@ -15,16 +15,6 @@ MouseArea { property bool isChatActivity: model.objectType === "chat" || model.objectType === "room" || model.objectType === "call" property bool isTalkReplyPossible: model.conversationToken !== "" - property bool displayTalkReplyOptions: false - Connections { - target: activityModel - function onDisplayTalkReplyOptions(activityIndex) { - if (model.index === activityIndex) { - displayTalkReplyOptions = true; - } - } - } - signal fileActivityButtonClicked(string absolutePath) enabled: (model.path !== "" || model.link !== "" || model.isCurrentUserFileActivity === true) @@ -83,7 +73,7 @@ MouseArea { ActivityItemActions { id: activityActions - visible: !root.isFileActivityList && model.linksForActionButtons.length > 0 && !displayTalkReplyOptions + visible: !root.isFileActivityList && model.linksForActionButtons.length > 0 && !model.displayReplyOption Layout.preferredHeight: Style.trayWindowHeaderHeight * 0.85 Layout.fillWidth: true diff --git a/src/gui/tray/ActivityItemContent.qml b/src/gui/tray/ActivityItemContent.qml index 8c091c324..f18244e56 100644 --- a/src/gui/tray/ActivityItemContent.qml +++ b/src/gui/tray/ActivityItemContent.qml @@ -133,8 +133,8 @@ RowLayout { Loader { id: talkReplyTextFieldLoader - active: isChatActivity && isTalkReplyPossible && displayTalkReplyOptions - visible: displayTalkReplyOptions + active: isChatActivity && isTalkReplyPossible && model.displayReplyOption + visible: model.displayReplyOption anchors.top: activityTextDateTime.bottom anchors.topMargin: 10 diff --git a/src/gui/tray/TalkReplyTextField.qml b/src/gui/tray/TalkReplyTextField.qml index 93a073f5f..610e28af1 100644 --- a/src/gui/tray/TalkReplyTextField.qml +++ b/src/gui/tray/TalkReplyTextField.qml @@ -7,14 +7,6 @@ import com.nextcloud.desktopclient 1.0 Item { id: root - Connections { - target: activityModel - function onMessageSent() { - replyMessageTextField.clear(); - replyMessageSent.text = activityModel.replyMessageSent(model.index); - } - } - function sendReplyMessage() { if (replyMessageTextField.text === "") { return; @@ -25,9 +17,10 @@ Item { Text { id: replyMessageSent + text: model.messageSent font.pixelSize: Style.topLinePixelSize color: Style.menuBorder - visible: replyMessageSent.text !== "" + visible: model.messageSent !== "" } TextField { diff --git a/src/gui/tray/activitydata.h b/src/gui/tray/activitydata.h index 9c035e2a3..166832f4f 100644 --- a/src/gui/tray/activitydata.h +++ b/src/gui/tray/activitydata.h @@ -113,6 +113,7 @@ public: QString conversationToken; QString messageId; QString messageSent; + bool displayReplyOption = false; }; Type _type; diff --git a/src/gui/tray/activitylistmodel.cpp b/src/gui/tray/activitylistmodel.cpp index 47b56726c..a34c2464b 100644 --- a/src/gui/tray/activitylistmodel.cpp +++ b/src/gui/tray/activitylistmodel.cpp @@ -80,6 +80,7 @@ QHash<int, QByteArray> ActivityListModel::roleNames() const roles[TalkNotificationConversationTokenRole] = "conversationToken"; roles[TalkNotificationMessageIdRole] = "messageId"; roles[TalkNotificationMessageSentRole] = "messageSent"; + roles[TalkNotificationDisplayReplyOptionRole] = "displayReplyOption"; return roles; } @@ -331,7 +332,9 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const case TalkNotificationMessageIdRole: return a._talkNotificationData.messageId; case TalkNotificationMessageSentRole: - return a._talkNotificationData.messageSent; + return replyMessageSent(a); + case TalkNotificationDisplayReplyOptionRole: + return displayReplyOption(a); default: return QVariant(); } @@ -613,7 +616,7 @@ void ActivityListModel::slotTriggerAction(const int activityIndex, const int act // TODO this will change with https://github.com/nextcloud/desktop/issues/4159 if (action._verb == "WEB" && action._label == tr("View chat")) { - emit displayTalkReplyOptions(activityIndex); + setDisplayReplyOption(activityIndex); return; } @@ -826,16 +829,22 @@ void ActivityListModel::setReplyMessageSent(const int activityIndex, const QStri _finalList[activityIndex]._talkNotificationData.messageSent = message; - emit messageSent(); + emit dataChanged(index(activityIndex, 0), index(activityIndex, 0), {ActivityListModel::TalkNotificationMessageSentRole}); } -QString ActivityListModel::replyMessageSent(const int activityIndex) const +QString ActivityListModel::replyMessageSent(const Activity &activity) const { - if (activityIndex < 0 || activityIndex >= _finalList.size()) { - qCWarning(lcActivity) << "Couldn't trigger action on activity at index" << activityIndex << "/ final list size:" << _finalList.size(); - return {}; - } + return activity._talkNotificationData.messageSent; +} - return _finalList[activityIndex]._talkNotificationData.messageSent; +void ActivityListModel::setDisplayReplyOption(const int activityIndex) +{ + _finalList[activityIndex]._talkNotificationData.displayReplyOption = true; + emit dataChanged(index(activityIndex, 0), index(activityIndex, 0), {ActivityListModel::TalkNotificationDisplayReplyOptionRole}); +} + +bool ActivityListModel::displayReplyOption(const Activity &activity) const +{ + return activity._talkNotificationData.displayReplyOption; } } diff --git a/src/gui/tray/activitylistmodel.h b/src/gui/tray/activitylistmodel.h index fbe1f63aa..c0698a9e6 100644 --- a/src/gui/tray/activitylistmodel.h +++ b/src/gui/tray/activitylistmodel.h @@ -43,7 +43,6 @@ class ActivityListModel : public QAbstractListModel Q_PROPERTY(quint32 maxActionButtons READ maxActionButtons CONSTANT) Q_PROPERTY(AccountState *accountState READ accountState CONSTANT) - public: enum DataRole { DarkIconRole = Qt::UserRole + 1, @@ -72,6 +71,7 @@ public: TalkNotificationConversationTokenRole, TalkNotificationMessageIdRole, TalkNotificationMessageSentRole, + TalkNotificationDisplayReplyOptionRole, }; Q_ENUM(DataRole) @@ -107,7 +107,8 @@ public: void setCurrentItem(const int currentItem); void setReplyMessageSent(const int activityIndex, const QString &message); - Q_INVOKABLE QString replyMessageSent(const int activityIndex) const; + QString replyMessageSent(const Activity &activity) const; + bool displayReplyOption(const Activity &activity) const; public slots: void slotRefreshActivity(); @@ -119,8 +120,6 @@ public slots: signals: void activityJobStatusCode(int statusCode); void sendNotificationRequest(const QString &accountName, const QString &link, const QByteArray &verb, int row); - void messageSent(); - void displayTalkReplyOptions(const int activityIndex); protected: void setup(); @@ -150,6 +149,8 @@ private: void ingestActivities(const QJsonArray &activities); + void setDisplayReplyOption(const int activityIndex); + ActivityList _activityLists; ActivityList _syncFileItemLists; ActivityList _notificationLists; |