Merge lp:~mzanetti/reminders-app/clear-on-logout into lp:reminders-app

Proposed by Michael Zanetti
Status: Merged
Approved by: Riccardo Padovani
Approved revision: 54
Merged at revision: 54
Proposed branch: lp:~mzanetti/reminders-app/clear-on-logout
Merge into: lp:reminders-app
Diff against target: 96 lines (+37/-6)
3 files modified
src/plugin/Evernote/notebooks.cpp (+8/-0)
src/plugin/Evernote/notebooks.h (+1/-0)
src/plugin/Evernote/notesstore.cpp (+28/-6)
To merge this branch: bzr merge lp:~mzanetti/reminders-app/clear-on-logout
Reviewer Review Type Date Requested Status
Riccardo Padovani Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+205043@code.launchpad.net

Commit message

properly react to clearing the token

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Riccardo Padovani (rpadovani) wrote :

Works as expected! Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/plugin/Evernote/notebooks.cpp'
--- src/plugin/Evernote/notebooks.cpp 2014-01-27 13:00:41 +0000
+++ src/plugin/Evernote/notebooks.cpp 2014-02-05 20:44:23 +0000
@@ -32,6 +32,7 @@
32 }32 }
3333
34 connect(NotesStore::instance(), SIGNAL(notebookAdded(const QString &)), SLOT(notebookAdded(const QString &)));34 connect(NotesStore::instance(), SIGNAL(notebookAdded(const QString &)), SLOT(notebookAdded(const QString &)));
35 connect(NotesStore::instance(), SIGNAL(notebookRemoved(const QString &)), SLOT(notebookRemoved(const QString &)));
35}36}
3637
37QVariant Notebooks::data(const QModelIndex &index, int role) const38QVariant Notebooks::data(const QModelIndex &index, int role) const
@@ -85,6 +86,13 @@
85 endInsertRows();86 endInsertRows();
86}87}
8788
89void Notebooks::notebookRemoved(const QString &guid)
90{
91 beginRemoveRows(QModelIndex(), m_list.indexOf(guid), m_list.indexOf(guid));
92 m_list.removeAll(guid);
93 endRemoveRows();
94}
95
88void Notebooks::noteCountChanged()96void Notebooks::noteCountChanged()
89{97{
90 Notebook *notebook = static_cast<Notebook*>(sender());98 Notebook *notebook = static_cast<Notebook*>(sender());
9199
=== modified file 'src/plugin/Evernote/notebooks.h'
--- src/plugin/Evernote/notebooks.h 2014-01-27 13:00:41 +0000
+++ src/plugin/Evernote/notebooks.h 2014-02-05 20:44:23 +0000
@@ -48,6 +48,7 @@
4848
49private slots:49private slots:
50 void notebookAdded(const QString &guid);50 void notebookAdded(const QString &guid);
51 void notebookRemoved(const QString &guid);
51 void noteCountChanged();52 void noteCountChanged();
5253
53private:54private:
5455
=== modified file 'src/plugin/Evernote/notesstore.cpp'
--- src/plugin/Evernote/notesstore.cpp 2014-02-05 17:26:54 +0000
+++ src/plugin/Evernote/notesstore.cpp 2014-02-05 20:44:23 +0000
@@ -157,9 +157,19 @@
157157
158void NotesStore::refreshNotes(const QString &filterNotebookGuid)158void NotesStore::refreshNotes(const QString &filterNotebookGuid)
159{159{
160 FetchNotesJob *job = new FetchNotesJob(filterNotebookGuid);160 if (EvernoteConnection::instance()->token().isEmpty()) {
161 connect(job, &FetchNotesJob::jobDone, this, &NotesStore::fetchNotesJobDone);161 beginResetModel();
162 EvernoteConnection::instance()->enqueue(job);162 foreach (Note *note, m_notes) {
163 emit noteRemoved(note->guid(), note->notebookGuid());
164 note->deleteLater();
165 }
166 m_notes.clear();
167 endResetModel();
168 } else {
169 FetchNotesJob *job = new FetchNotesJob(filterNotebookGuid);
170 connect(job, &FetchNotesJob::jobDone, this, &NotesStore::fetchNotesJobDone);
171 EvernoteConnection::instance()->enqueue(job);
172 }
163}173}
164174
165void NotesStore::fetchNotesJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const evernote::edam::NotesMetadataList &results)175void NotesStore::fetchNotesJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const evernote::edam::NotesMetadataList &results)
@@ -227,6 +237,10 @@
227 }237 }
228238
229 Note *note = m_notesHash.value(QString::fromStdString(result.guid));239 Note *note = m_notesHash.value(QString::fromStdString(result.guid));
240 if (note) {
241 qWarning() << "can't find note for this update... ignoring...";
242 return;
243 }
230 note->setNotebookGuid(QString::fromStdString(result.notebookGuid));244 note->setNotebookGuid(QString::fromStdString(result.notebookGuid));
231 note->setTitle(QString::fromStdString(result.title));245 note->setTitle(QString::fromStdString(result.title));
232246
@@ -263,9 +277,17 @@
263277
264void NotesStore::refreshNotebooks()278void NotesStore::refreshNotebooks()
265{279{
266 FetchNotebooksJob *job = new FetchNotebooksJob();280 if (EvernoteConnection::instance()->token().isEmpty()) {
267 connect(job, &FetchNotebooksJob::jobDone, this, &NotesStore::fetchNotebooksJobDone);281 foreach (Notebook *notebook, m_notebooks) {
268 EvernoteConnection::instance()->enqueue(job);282 emit notebookRemoved(notebook->guid());
283 notebook->deleteLater();
284 }
285 m_notebooks.clear();
286 } else {
287 FetchNotebooksJob *job = new FetchNotebooksJob();
288 connect(job, &FetchNotebooksJob::jobDone, this, &NotesStore::fetchNotebooksJobDone);
289 EvernoteConnection::instance()->enqueue(job);
290 }
269}291}
270292
271void NotesStore::fetchNotebooksJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const std::vector<evernote::edam::Notebook> &results)293void NotesStore::fetchNotebooksJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const std::vector<evernote::edam::Notebook> &results)

Subscribers

People subscribed via source and target branches