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
1=== modified file 'src/plugin/Evernote/notebooks.cpp'
2--- src/plugin/Evernote/notebooks.cpp 2014-01-27 13:00:41 +0000
3+++ src/plugin/Evernote/notebooks.cpp 2014-02-05 20:44:23 +0000
4@@ -32,6 +32,7 @@
5 }
6
7 connect(NotesStore::instance(), SIGNAL(notebookAdded(const QString &)), SLOT(notebookAdded(const QString &)));
8+ connect(NotesStore::instance(), SIGNAL(notebookRemoved(const QString &)), SLOT(notebookRemoved(const QString &)));
9 }
10
11 QVariant Notebooks::data(const QModelIndex &index, int role) const
12@@ -85,6 +86,13 @@
13 endInsertRows();
14 }
15
16+void Notebooks::notebookRemoved(const QString &guid)
17+{
18+ beginRemoveRows(QModelIndex(), m_list.indexOf(guid), m_list.indexOf(guid));
19+ m_list.removeAll(guid);
20+ endRemoveRows();
21+}
22+
23 void Notebooks::noteCountChanged()
24 {
25 Notebook *notebook = static_cast<Notebook*>(sender());
26
27=== modified file 'src/plugin/Evernote/notebooks.h'
28--- src/plugin/Evernote/notebooks.h 2014-01-27 13:00:41 +0000
29+++ src/plugin/Evernote/notebooks.h 2014-02-05 20:44:23 +0000
30@@ -48,6 +48,7 @@
31
32 private slots:
33 void notebookAdded(const QString &guid);
34+ void notebookRemoved(const QString &guid);
35 void noteCountChanged();
36
37 private:
38
39=== modified file 'src/plugin/Evernote/notesstore.cpp'
40--- src/plugin/Evernote/notesstore.cpp 2014-02-05 17:26:54 +0000
41+++ src/plugin/Evernote/notesstore.cpp 2014-02-05 20:44:23 +0000
42@@ -157,9 +157,19 @@
43
44 void NotesStore::refreshNotes(const QString &filterNotebookGuid)
45 {
46- FetchNotesJob *job = new FetchNotesJob(filterNotebookGuid);
47- connect(job, &FetchNotesJob::jobDone, this, &NotesStore::fetchNotesJobDone);
48- EvernoteConnection::instance()->enqueue(job);
49+ if (EvernoteConnection::instance()->token().isEmpty()) {
50+ beginResetModel();
51+ foreach (Note *note, m_notes) {
52+ emit noteRemoved(note->guid(), note->notebookGuid());
53+ note->deleteLater();
54+ }
55+ m_notes.clear();
56+ endResetModel();
57+ } else {
58+ FetchNotesJob *job = new FetchNotesJob(filterNotebookGuid);
59+ connect(job, &FetchNotesJob::jobDone, this, &NotesStore::fetchNotesJobDone);
60+ EvernoteConnection::instance()->enqueue(job);
61+ }
62 }
63
64 void NotesStore::fetchNotesJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const evernote::edam::NotesMetadataList &results)
65@@ -227,6 +237,10 @@
66 }
67
68 Note *note = m_notesHash.value(QString::fromStdString(result.guid));
69+ if (note) {
70+ qWarning() << "can't find note for this update... ignoring...";
71+ return;
72+ }
73 note->setNotebookGuid(QString::fromStdString(result.notebookGuid));
74 note->setTitle(QString::fromStdString(result.title));
75
76@@ -263,9 +277,17 @@
77
78 void NotesStore::refreshNotebooks()
79 {
80- FetchNotebooksJob *job = new FetchNotebooksJob();
81- connect(job, &FetchNotebooksJob::jobDone, this, &NotesStore::fetchNotebooksJobDone);
82- EvernoteConnection::instance()->enqueue(job);
83+ if (EvernoteConnection::instance()->token().isEmpty()) {
84+ foreach (Notebook *notebook, m_notebooks) {
85+ emit notebookRemoved(notebook->guid());
86+ notebook->deleteLater();
87+ }
88+ m_notebooks.clear();
89+ } else {
90+ FetchNotebooksJob *job = new FetchNotebooksJob();
91+ connect(job, &FetchNotebooksJob::jobDone, this, &NotesStore::fetchNotebooksJobDone);
92+ EvernoteConnection::instance()->enqueue(job);
93+ }
94 }
95
96 void NotesStore::fetchNotebooksJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const std::vector<evernote::edam::Notebook> &results)

Subscribers

People subscribed via source and target branches