Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 546f95a9 authored by Stefan Niedermann's avatar Stefan Niedermann
Browse files

#831 Also update modified date (next to etag) before pulling remote changes

parent 94315a1e
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -163,8 +163,13 @@ abstract class NotesServerSyncTask extends Thread {
        Log.d(TAG, "pullRemoteChanges() for account " + localAccount.getAccountName());
        try {
            final Map<Long, Long> idMap = db.getIdMap(localAccount.getId());

            // FIXME re-reading the localAccount is only a workaround for a not-up-to-date eTag in localAccount.
            final ServerResponse.NotesResponse response = notesClient.getNotes(ssoAccount, localAccount.getModified(), db.getAccountDao().getAccountById(localAccount.getId()).getETag());
            final Account accountFromDatabase = db.getAccountDao().getAccountById(localAccount.getId());
            localAccount.setModified(accountFromDatabase.getModified());
            localAccount.setETag(accountFromDatabase.getETag());

            final ServerResponse.NotesResponse response = notesClient.getNotes(ssoAccount, localAccount.getModified(), localAccount.getETag());
            final List<Note> remoteNotes = response.getNotes();
            final Set<Long> remoteIDs = new HashSet<>();
            // pull remote changes: update or create each remote note