ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #00159
[Merge] lp:~mzanetti/reminders-app/needsContentSync into lp:reminders-app
Michael Zanetti has proposed merging lp:~mzanetti/reminders-app/needsContentSync into lp:reminders-app with lp:~mzanetti/reminders-app/better-reset-connection as a prerequisite.
Commit message:
Don't send the note content to the server if it hasn't changed.
This avoids long saving times for notes with big content/attachment when only changing it's reminder or tags.
Requested reviews:
Ubuntu Reminders app developers (reminders-app-dev)
For more details, see:
https://code.launchpad.net/~mzanetti/reminders-app/needsContentSync/+merge/251333
--
Your team Ubuntu Reminders app developers is requested to review the proposed merge of lp:~mzanetti/reminders-app/needsContentSync into lp:reminders-app.
=== modified file 'src/libqtevernote/jobs/savenotejob.cpp'
--- src/libqtevernote/jobs/savenotejob.cpp 2014-12-16 21:01:28 +0000
+++ src/libqtevernote/jobs/savenotejob.cpp 2015-02-27 22:17:17 +0000
@@ -78,10 +78,6 @@
note.tagGuids = tags;
note.__isset.tagGuids = true;
- note.content = m_note->enmlContent().toStdString();
- note.__isset.content = true;
- note.contentLength = m_note->enmlContent().length();
-
note.__isset.attributes = true;
note.attributes.reminderOrder = m_note->reminderOrder();
note.attributes.__isset.reminderOrder = true;
@@ -90,32 +86,39 @@
note.attributes.reminderDoneTime = m_note->reminderDoneTime().toMSecsSinceEpoch();
note.attributes.__isset.reminderDoneTime = true;
- note.resources.clear();
- foreach (Resource *resource, m_note->resources()) {
- evernote::edam::Resource evResource;
- evResource.noteGuid = m_note->guid().toStdString();
- evResource.__isset.noteGuid = true;
- evResource.mime = resource->type().toStdString();
- evResource.__isset.mime = true;
-
- evResource.data.bodyHash = resource->hash().toStdString();
- evResource.data.__isset.bodyHash = true;
-
- QByteArray data = resource->data();
- evResource.data.body.assign(data.data(), data.length());
- evResource.data.__isset.body = true;
-
- evResource.data.size = data.length();
- evResource.data.__isset.size = true;
- evResource.__isset.data = true;
-
- evResource.attributes.fileName = resource->fileName().toStdString();
- evResource.attributes.__isset.fileName = true;
- evResource.__isset.attributes = true;
-
- note.resources.push_back(evResource);
+ qDebug() << "*** needs content sync" << m_note->needsContentSync();
+ if (m_note->needsContentSync()) {
+ note.content = m_note->enmlContent().toStdString();
+ note.__isset.content = true;
+ note.contentLength = m_note->enmlContent().length();
+
+ note.resources.clear();
+ foreach (Resource *resource, m_note->resources()) {
+ evernote::edam::Resource evResource;
+ evResource.noteGuid = m_note->guid().toStdString();
+ evResource.__isset.noteGuid = true;
+ evResource.mime = resource->type().toStdString();
+ evResource.__isset.mime = true;
+
+ evResource.data.bodyHash = resource->hash().toStdString();
+ evResource.data.__isset.bodyHash = true;
+
+ QByteArray data = resource->data();
+ evResource.data.body.assign(data.data(), data.length());
+ evResource.data.__isset.body = true;
+
+ evResource.data.size = data.length();
+ evResource.data.__isset.size = true;
+ evResource.__isset.data = true;
+
+ evResource.attributes.fileName = resource->fileName().toStdString();
+ evResource.attributes.__isset.fileName = true;
+ evResource.__isset.attributes = true;
+
+ note.resources.push_back(evResource);
+ }
+ note.__isset.resources = true;
}
- note.__isset.resources = true;
}
// In some error cases it may happen that the resultNote is not filled in. Make sure we have at least the guid
=== modified file 'src/libqtevernote/note.cpp'
--- src/libqtevernote/note.cpp 2015-02-27 11:46:17 +0000
+++ src/libqtevernote/note.cpp 2015-02-27 22:17:17 +0000
@@ -41,7 +41,8 @@
m_loadingHighPriority(false),
m_loaded(false),
m_syncError(false),
- m_conflicting(false)
+ m_conflicting(false),
+ m_needsContentSync(false)
{
setGuid(guid);
m_cacheFile.setFileName(NotesStore::instance()->storageLocation() + "note-" + guid + ".enml");
@@ -58,6 +59,7 @@
m_deleted = infoFile.value("deleted").toBool();
m_tagline = infoFile.value("tagline").toString();
m_lastSyncedSequenceNumber = infoFile.value("lastSyncedSequenceNumber", 0).toUInt();
+ m_needsContentSync = infoFile.value("needsContentSync", false).toBool();
m_synced = m_lastSyncedSequenceNumber == m_updateSequenceNumber;
infoFile.beginGroup("resources");
@@ -254,6 +256,10 @@
m_content.setEnml(enmlContent);
m_tagline = m_content.toPlaintext().left(100);
emit contentChanged();
+
+ if (m_loaded) {
+ m_needsContentSync = true;
+ }
}
m_loaded = true;
}
@@ -278,6 +284,8 @@
m_content.setRichText(richTextContent);
m_tagline = m_content.toPlaintext().left(100);
emit contentChanged();
+
+ m_needsContentSync = true;
}
}
@@ -454,6 +462,9 @@
m_updateSequenceNumber = updateSequenceNumber;
m_synced = m_updateSequenceNumber == m_lastSyncedSequenceNumber;
+ if (m_synced) {
+ m_needsContentSync = false;
+ }
emit syncedChanged();
}
}
@@ -469,6 +480,9 @@
m_lastSyncedSequenceNumber = lastSyncedSequenceNumber;
m_synced = m_updateSequenceNumber == m_lastSyncedSequenceNumber;
+ if (m_synced) {
+ m_needsContentSync = false;
+ }
emit syncedChanged();
}
}
@@ -544,6 +558,8 @@
// TODO: If the app should be extended to allow attaching other files, and we somehow
// can browse to unconfined files, this needs to be made conditional to not delete those files!
importedFile.remove();
+
+ m_needsContentSync = true;
}
void Note::format(int startPos, int endPos, TextFormat::Format format)
@@ -579,6 +595,7 @@
foreach (Resource *resource, m_resources) {
note->addResource(resource->data(), resource->hash(), resource->fileName(), resource->type());
}
+ note->m_needsContentSync = m_needsContentSync;
return note;
}
@@ -631,6 +648,7 @@
infoFile.setValue("created", m_created);
infoFile.setValue("title", m_title);
infoFile.setValue("updated", m_updated);
+ infoFile.setValue("needsContentSync", m_needsContentSync);
infoFile.setValue("notebookGuid", m_notebookGuid);
infoFile.setValue("tagGuids", m_tagGuids);
@@ -708,6 +726,11 @@
return m_conflicting;
}
+bool Note::needsContentSync() const
+{
+ return m_needsContentSync;
+}
+
void Note::setConflicting(bool conflicting)
{
if (m_conflicting != conflicting) {
=== modified file 'src/libqtevernote/note.h'
--- src/libqtevernote/note.h 2015-02-27 11:46:17 +0000
+++ src/libqtevernote/note.h 2015-02-27 22:17:17 +0000
@@ -147,6 +147,7 @@
bool synced() const;
bool syncError() const;
bool conflicting() const;
+ bool needsContentSync() const;
QStringList resourceUrls() const;
Q_INVOKABLE Resource* resource(const QString &hash);
@@ -229,6 +230,7 @@
bool m_loadingHighPriority;
mutable bool m_loaded;
bool m_synced;
+ bool m_needsContentSync;
bool m_syncError;
bool m_conflicting;
Follow ups