From 96b5733f0c02b00679117bc95850ab8242e43eec Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 7 Mar 2017 14:58:30 +0100 Subject: Sink merges the sync requests now. --- framework/domain/maillistmodel.cpp | 21 +-------------------- framework/domain/maillistmodel.h | 6 ------ 2 files changed, 1 insertion(+), 26 deletions(-) (limited to 'framework') diff --git a/framework/domain/maillistmodel.cpp b/framework/domain/maillistmodel.cpp index a995451e..c96f6dd1 100644 --- a/framework/domain/maillistmodel.cpp +++ b/framework/domain/maillistmodel.cpp @@ -27,8 +27,6 @@ MailListModel::MailListModel(QObject *parent) { setDynamicSortFilter(true); sort(0, Qt::DescendingOrder); - connect(&mFetchTimer, &QTimer::timeout, this, &MailListModel::fetch); - mFetchTimer.setSingleShot(true); } MailListModel::~MailListModel() @@ -78,24 +76,7 @@ void MailListModel::fetchMail(Sink::ApplicationDomain::Mail::Ptr mail) if (mail && !mail->getFullPayloadAvailable() && !mFetchedMails.contains(mail->identifier())) { qDebug() << "Fetching mail: " << mail->identifier() << mail->getSubject(); mFetchedMails.insert(mail->identifier()); - mMailsToFetch << *mail; - //TODO it would be nicer if Sink could just transparently merge synchronization requeusts. - if (!mFetchTimer.isActive()) { - mFetchTimer.start(50); - } - } -} - -void MailListModel::fetch() -{ - if (!mMailsToFetch.isEmpty()) { - auto first = mMailsToFetch.first(); - auto scope = Sink::SyncScope{first}; - for (const auto &m : mMailsToFetch) { - scope.filter(m.identifier()); - } - Sink::Store::synchronize(scope).exec(); - mMailsToFetch.clear(); + Sink::Store::synchronize(Sink::SyncScope{*mail}).exec(); } } diff --git a/framework/domain/maillistmodel.h b/framework/domain/maillistmodel.h index 1fd0ef5e..96cf98f2 100644 --- a/framework/domain/maillistmodel.h +++ b/framework/domain/maillistmodel.h @@ -25,7 +25,6 @@ #include #include #include -#include class MailListModel : public QSortFilterProxyModel { @@ -70,16 +69,11 @@ public: void setMail(const QVariant &mail); QVariant mail() const; -private slots: - void fetch(); - private: void fetchMail(Sink::ApplicationDomain::Mail::Ptr mail); QSharedPointer m_model; bool mFetchMails = false; QSet mFetchedMails; - QList mMailsToFetch; QByteArray mCurrentQueryItem; - QTimer mFetchTimer; }; -- cgit v1.2.3