mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
Removes notification row from the view when clicking on Dismiss.
Signed-off-by: Camila San <hello@camila.codes>
This commit is contained in:
parent
ef4a30fcb9
commit
49377976db
4 changed files with 24 additions and 9 deletions
|
@ -201,6 +201,16 @@ void ActivityListModel::addToActivityList(Activity activity) {
|
|||
combineActivityLists();
|
||||
}
|
||||
|
||||
void ActivityListModel::removeFromActivityList(int row) {
|
||||
if(removeRow(row))
|
||||
qDebug() << "Row removed!!" << row;
|
||||
else
|
||||
qDebug() << "Row not removed!!" << row;
|
||||
|
||||
_notificationLists.removeAt(row);
|
||||
combineActivityLists();
|
||||
}
|
||||
|
||||
void ActivityListModel::combineActivityLists()
|
||||
{
|
||||
ActivityList resultList;
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
|
||||
ActivityList activityList() { return _finalList; }
|
||||
void addToActivityList(Activity activity);
|
||||
void removeFromActivityList(int row);
|
||||
|
||||
public slots:
|
||||
void slotRefreshActivity();
|
||||
|
|
|
@ -123,9 +123,10 @@ void ActivityWidget::slotButtonClickedOnListView(const QModelIndex &index){
|
|||
|
||||
foreach (ActivityLink actionLink, actionLinks) {
|
||||
QAction *menuAction = new QAction(actionLink._label, &menu);
|
||||
menuAction->setProperty("activityRow", QVariant::fromValue(index.row()));
|
||||
connect(menuAction, &QAction::triggered, this, [this, index, actionLink] {
|
||||
qCInfo(lcActivity) << "Notification Link: " << actionLink._verb << actionLink._link;
|
||||
emit this->sendNotificationRequest(qvariant_cast<QString>(index.data(ActivityItemDelegate::AccountRole)), actionLink._link, actionLink._verb);
|
||||
emit this->sendNotificationRequest(qvariant_cast<QString>(index.data(ActivityItemDelegate::AccountRole)), actionLink._link, actionLink._verb, index.row());
|
||||
});
|
||||
menu.addAction(menuAction);
|
||||
}
|
||||
|
@ -145,6 +146,9 @@ void ActivityWidget::slotNotificationRequestFinished(int statusCode)
|
|||
if (statusCode != OCS_SUCCESS_STATUS_CODE && statusCode != OCS_SUCCESS_STATUS_CODE_V2) {
|
||||
qCWarning(lcActivity) << "Notification Request to Server failed, leave button visible.";
|
||||
} else {
|
||||
// to do use the model to rebuild the list or remove the item
|
||||
qDebug() << "activity to be removed from row" << sender()->property("activityRow").toInt();
|
||||
_model->removeFromActivityList(sender()->property("activityRow").toInt());
|
||||
qCWarning(lcActivity) << "Notification Request to Server successed, leave button visible.";
|
||||
}
|
||||
}
|
||||
|
@ -410,7 +414,7 @@ void ActivityWidget::slotBuildNotificationDisplay(const ActivityList &list)
|
|||
}
|
||||
}
|
||||
|
||||
void ActivityWidget::slotSendNotificationRequest(const QString &accountName, const QString &link, const QByteArray &verb)
|
||||
void ActivityWidget::slotSendNotificationRequest(const QString &accountName, const QString &link, const QByteArray &verb, int row)
|
||||
{
|
||||
qCInfo(lcActivity) << "Server Notification Request " << verb << link << "on account" << accountName;
|
||||
NotificationWidget *theSender = qobject_cast<NotificationWidget *>(sender());
|
||||
|
@ -426,7 +430,9 @@ void ActivityWidget::slotSendNotificationRequest(const QString &accountName, con
|
|||
NotificationConfirmJob *job = new NotificationConfirmJob(acc->account());
|
||||
QUrl l(link);
|
||||
job->setLinkAndVerb(l, verb);
|
||||
job->setWidget(theSender);
|
||||
job->setProperty("activityRow", QVariant::fromValue(row));
|
||||
// save the activity to be hidden or the QModelIndex
|
||||
//job->setProperty();
|
||||
connect(job, &AbstractNetworkJob::networkError,
|
||||
this, &ActivityWidget::slotNotifyNetworkError);
|
||||
connect(job, &NotificationConfirmJob::jobFinished,
|
||||
|
@ -445,9 +451,7 @@ void ActivityWidget::slotSendNotificationRequest(const QString &accountName, con
|
|||
void ActivityWidget::endNotificationRequest(NotificationWidget *widget, int replyCode)
|
||||
{
|
||||
_notificationRequestsRunning--;
|
||||
if (widget) {
|
||||
widget->slotNotificationRequestFinished(replyCode);
|
||||
}
|
||||
slotNotificationRequestFinished(replyCode);
|
||||
}
|
||||
|
||||
void ActivityWidget::slotNotifyNetworkError(QNetworkReply *reply)
|
||||
|
@ -478,7 +482,7 @@ void ActivityWidget::slotNotifyServerFinished(const QString &reply, int replyCod
|
|||
// Add 200 millisecs to the predefined value to make sure that the timer in
|
||||
// widget's method readyToClose() has elapsed.
|
||||
if (replyCode == OCS_SUCCESS_STATUS_CODE || replyCode == OCS_SUCCESS_STATUS_CODE_V2) {
|
||||
scheduleWidgetToRemove(job->widget());
|
||||
//scheduleWidgetToRemove(job->widget());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,11 +86,11 @@ signals:
|
|||
void rowsInserted();
|
||||
void hideActivityTab(bool);
|
||||
void newNotification();
|
||||
void sendNotificationRequest(const QString &, const QString &link, const QByteArray &verb);
|
||||
void sendNotificationRequest(const QString &, const QString &link, const QByteArray &verb, int row);
|
||||
|
||||
private slots:
|
||||
void slotBuildNotificationDisplay(const ActivityList &list);
|
||||
void slotSendNotificationRequest(const QString &accountName, const QString &link, const QByteArray &verb);
|
||||
void slotSendNotificationRequest(const QString &accountName, const QString &link, const QByteArray &verb, int row);
|
||||
void slotNotifyNetworkError(QNetworkReply *);
|
||||
void slotNotifyServerFinished(const QString &reply, int replyCode);
|
||||
void endNotificationRequest(NotificationWidget *widget, int replyCode);
|
||||
|
|
Loading…
Reference in a new issue