mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Address PR comments.
Signed-off-by: Camila <hello@camila.codes>
This commit is contained in:
parent
9b00e5268e
commit
7cc2486d79
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -113,6 +113,7 @@ public:
|
||||
QString conversationToken;
|
||||
QString messageId;
|
||||
QString messageSent;
|
||||
bool displayReplyOption = false;
|
||||
};
|
||||
|
||||
Type _type;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user