diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-03-07 14:58:30 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-03-07 14:58:30 +0100 |
commit | 96b5733f0c02b00679117bc95850ab8242e43eec (patch) | |
tree | 326d3429f8d340fe8bc3948540ff6ae715573676 /framework/domain/maillistmodel.cpp | |
parent | ab9cf3a17ddadbbb281e12d6ef72c97cf817cb30 (diff) | |
download | kube-96b5733f0c02b00679117bc95850ab8242e43eec.tar.gz kube-96b5733f0c02b00679117bc95850ab8242e43eec.zip |
Sink merges the sync requests now.
Diffstat (limited to 'framework/domain/maillistmodel.cpp')
-rw-r--r-- | framework/domain/maillistmodel.cpp | 21 |
1 files changed, 1 insertions, 20 deletions
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) | |||
27 | { | 27 | { |
28 | setDynamicSortFilter(true); | 28 | setDynamicSortFilter(true); |
29 | sort(0, Qt::DescendingOrder); | 29 | sort(0, Qt::DescendingOrder); |
30 | connect(&mFetchTimer, &QTimer::timeout, this, &MailListModel::fetch); | ||
31 | mFetchTimer.setSingleShot(true); | ||
32 | } | 30 | } |
33 | 31 | ||
34 | MailListModel::~MailListModel() | 32 | MailListModel::~MailListModel() |
@@ -78,24 +76,7 @@ void MailListModel::fetchMail(Sink::ApplicationDomain::Mail::Ptr mail) | |||
78 | if (mail && !mail->getFullPayloadAvailable() && !mFetchedMails.contains(mail->identifier())) { | 76 | if (mail && !mail->getFullPayloadAvailable() && !mFetchedMails.contains(mail->identifier())) { |
79 | qDebug() << "Fetching mail: " << mail->identifier() << mail->getSubject(); | 77 | qDebug() << "Fetching mail: " << mail->identifier() << mail->getSubject(); |
80 | mFetchedMails.insert(mail->identifier()); | 78 | mFetchedMails.insert(mail->identifier()); |
81 | mMailsToFetch << *mail; | 79 | Sink::Store::synchronize(Sink::SyncScope{*mail}).exec(); |
82 | //TODO it would be nicer if Sink could just transparently merge synchronization requeusts. | ||
83 | if (!mFetchTimer.isActive()) { | ||
84 | mFetchTimer.start(50); | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | |||
89 | void MailListModel::fetch() | ||
90 | { | ||
91 | if (!mMailsToFetch.isEmpty()) { | ||
92 | auto first = mMailsToFetch.first(); | ||
93 | auto scope = Sink::SyncScope{first}; | ||
94 | for (const auto &m : mMailsToFetch) { | ||
95 | scope.filter(m.identifier()); | ||
96 | } | ||
97 | Sink::Store::synchronize(scope).exec(); | ||
98 | mMailsToFetch.clear(); | ||
99 | } | 80 | } |
100 | } | 81 | } |
101 | 82 | ||