Commit 27664025 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix bug 453969 Only small amount of emails can be marked as read

BUG:453969
FIXED-IN: 5.21.0
parent 00483185
Pipeline #190336 passed with stage
in 6 minutes and 28 seconds
......@@ -10,6 +10,10 @@
#include <Akonadi/ItemModifyJob>
using namespace Akonadi;
namespace
{
static int sNumberMaxElement = 500;
}
MarkAsCommandHelper::MarkAsCommandHelper(QObject *parent)
: QObject{parent}
{
......@@ -19,17 +23,25 @@ MarkAsCommandHelper::~MarkAsCommandHelper() = default;
void MarkAsCommandHelper::start()
{
if (!mItemsToModify.isEmpty()) {
auto modifyJob = new Akonadi::ItemModifyJob(mItemsToModify, this);
modifyJob->setIgnorePayload(true);
modifyJob->disableRevisionCheck();
connect(modifyJob, &Akonadi::ItemModifyJob::result, this, &MarkAsCommandHelper::slotModifyItemDone);
} else {
if (mItemsToModify.isEmpty()) {
emitResult(Akonadi::CommandBase::OK);
deleteLater();
} else {
mIndex = 0;
modifyMessages();
}
}
void MarkAsCommandHelper::modifyMessages()
{
auto listElement = mItemsToModify.mid(mIndex, qMin(mIndex + sNumberMaxElement, mItemsToModify.count()));
mIndex += sNumberMaxElement;
auto modifyJob = new Akonadi::ItemModifyJob(listElement, this);
modifyJob->setIgnorePayload(true);
modifyJob->disableRevisionCheck();
connect(modifyJob, &Akonadi::ItemModifyJob::result, this, &MarkAsCommandHelper::slotModifyItemDone);
}
const Akonadi::Item::List &MarkAsCommandHelper::itemsToModify() const
{
return mItemsToModify;
......@@ -45,8 +57,15 @@ void MarkAsCommandHelper::slotModifyItemDone(KJob *job)
if (job && job->error()) {
qCDebug(AKONADIMIME_LOG) << " Error trying to set item status:" << job->errorText();
emitResult(Akonadi::CommandBase::Failed);
deleteLater();
} else {
emitResult(Akonadi::CommandBase::OK);
if (mIndex > mItemsToModify.count()) {
qCDebug(AKONADIMIME_LOG) << " finish";
emitResult(Akonadi::CommandBase::OK);
deleteLater();
} else {
// Modify more messages
modifyMessages();
}
}
deleteLater();
}
......@@ -23,11 +23,14 @@ public:
void setItemsToModify(const Akonadi::Item::List &newItemsToModify);
void start();
Q_SIGNALS:
void emitResult(Akonadi::CommandBase::Result result);
private:
void modifyMessages();
void slotModifyItemDone(KJob *job);
Akonadi::Item::List mItemsToModify;
int mIndex = 0;
};
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment