Use null for not-existing remoteId

This commit is contained in:
Stefan Niedermann 2020-10-20 23:38:45 +02:00
parent 8e878de184
commit 4a4d4f81fd
2 changed files with 3 additions and 5 deletions

View file

@ -371,7 +371,7 @@ public class NoteServerSyncHelper {
switch (note.getStatus()) {
case LOCAL_EDITED:
Log.v(TAG, " ...create/edit");
if (note.getRemoteId() != null && note.getRemoteId() > 0) {
if (note.getRemoteId() != null) {
Log.v(TAG, " ...Note has remoteId → try to edit");
try {
remoteNote = notesClient.editNote(ssoAccount, note).getNote();

View file

@ -191,9 +191,7 @@ public abstract class NotesDatabase extends RoomDatabase {
entity.setAccountId(accountId);
entity.setExcerpt(generateNoteExcerpt(note.getContent(), note.getTitle()));
}
if (note.getRemoteId() != null && note.getRemoteId() > 0) {
entity.setRemoteId(note.getRemoteId());
}
entity.setRemoteId(note.getRemoteId());
entity.setTitle(note.getTitle());
entity.setModified(note.getModified());
entity.setContent(note.getContent());
@ -267,7 +265,7 @@ public abstract class NotesDatabase extends RoomDatabase {
if (newTitle != null) {
title = newTitle;
} else {
if (oldNote.getRemoteId() == null || oldNote.getRemoteId() == 0 || localAccount.getPreferredApiVersion() == null || localAccount.getPreferredApiVersion().compareTo(new ApiVersion("1.0", 0, 0)) < 0) {
if (oldNote.getRemoteId() == null || localAccount.getPreferredApiVersion() == null || localAccount.getPreferredApiVersion().compareTo(new ApiVersion("1.0", 0, 0)) < 0) {
title = NoteUtil.generateNonEmptyNoteTitle(newContent, context);
} else {
title = oldNote.getTitle();