Fix #1272 Notes created via Android's "Share Link" feature are not synced

Signed-off-by: Stefan Niedermann <info@niedermann.it>
This commit is contained in:
Stefan Niedermann 2021-10-11 11:24:37 +02:00
parent 220bc52cc4
commit 95afd472ce
3 changed files with 21 additions and 9 deletions

View file

@ -114,9 +114,9 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego
requireActivity().runOnUiThread(() -> onNoteLoaded(note));
requireActivity().invalidateOptionsMenu();
} else {
final var cloudNote = (Note) requireArguments().getSerializable(PARAM_NEWNOTE);
final var paramNote = (Note) requireArguments().getSerializable(PARAM_NEWNOTE);
final var content = requireArguments().getString(PARAM_CONTENT);
if (cloudNote == null) {
if (paramNote == null) {
if (content == null) {
throw new IllegalArgumentException(PARAM_NOTE_ID + " is not given, argument " + PARAM_NEWNOTE + " is missing and " + PARAM_CONTENT + " is missing.");
} else {
@ -125,7 +125,8 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego
requireActivity().invalidateOptionsMenu();
}
} else {
note = repo.addNote(localAccount.getId(), cloudNote);
paramNote.setStatus(DBStatus.LOCAL_EDITED);
note = repo.addNote(localAccount.getId(), paramNote);
originalNote = null;
requireActivity().runOnUiThread(() -> onNoteLoaded(note));
requireActivity().invalidateOptionsMenu();

View file

@ -423,7 +423,6 @@ public class NotesRepository {
@NonNull
@WorkerThread
public Note addNote(long accountId, @NonNull Note note) {
note.setStatus(note.getId() > 0 ? DBStatus.LOCAL_EDITED : DBStatus.VOID);
note.setAccountId(accountId);
note.setExcerpt(generateNoteExcerpt(note.getContent(), note.getTitle()));
return db.getNoteDao().getNoteById(db.getNoteDao().addNote(note));
@ -432,12 +431,9 @@ public class NotesRepository {
@MainThread
public LiveData<Note> moveNoteToAnotherAccount(Account account, @NonNull Note note) {
final var fullNote = new Note(null, note.getModified(), note.getTitle(), note.getContent(), note.getCategory(), note.getFavorite(), null);
fullNote.setStatus(DBStatus.LOCAL_EDITED);
deleteNoteAndSync(account, note.getId());
return map(addNoteAndSync(account, fullNote), (createdNote) -> {
db.getNoteDao().updateStatus(createdNote.getId(), DBStatus.LOCAL_EDITED);
createdNote.setStatus(DBStatus.LOCAL_EDITED);
return createdNote;
});
return addNoteAndSync(account, fullNote);
}
/**

View file

@ -0,0 +1,15 @@
3.4.14
- 🐞 Notes created via Android's "Share Link" feature are not synced (#1272)
3.4.13
- 🐞 Overflow-menu contains "search" when searchview is open (#522) by @vhouriet
- ✨ Enhance display of child/sub categories (#1154) by @ScottieKim
3.4.12
- 🐞 Fix potential crash when rendering a note with a checkbox (#1326) - by @pbek
- 🐞 Fix crash when long pressing a note and swiping to the edge of the screen (#1308)
- 🐞 Consistent timeouts when syncing (#761)
- 🐞 Categories created in web UI are not shown in Android app (#1358)