Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Add Delete action #67

Merged
merged 3 commits into from
Jan 17, 2021
Merged

Add Delete action #67

merged 3 commits into from
Jan 17, 2021

Conversation

evowizz
Copy link
Contributor

@evowizz evowizz commented Jan 10, 2021

This change adds the ability for users to delete notes using a menu action within the toolbar (under "Split screen").

This is done by marking the note as pending for deletion.

isPendingDeletion was already available, I just used it for this action. The icon R.drawable.ic_twotone_delete_24 was also already within the app.

Screenshot (Click for bigger preview):
Screenshot

@evowizz evowizz changed the title Add Delete clicked action Add Delete action Jan 10, 2021
@saket
Copy link
Owner

saket commented Jan 13, 2021

Nice, thanks! I had so far avoided doing this because deleting a note is a dangerous action. If sync is not setup, there's no way to recover deleted notes. Let's give this option only if sync is setup? If you're familiar with reaktive/rxjava, you can inject Syncer to the presenter and use Syncer#status for showing delete only if the status is enabled.

@evowizz
Copy link
Contributor Author

evowizz commented Jan 13, 2021

I was able to add this behavior on my local branch. However, I wanted to make sure the current behavior was understood here.

Removing the Delete Menu action when the Syncer status is not Enabled means that the only way for users to fully delete a note is by removing the entire content of that note (making the note empty). And if the Menu action is enabled, clicking it will remove the note from both the user's repository and the local database.

I'm not sure I understand why it would be better only if the Syncer status is Enabled because in both cases there's no way to recover deleted notes?

@manueldidonna
Copy link

manueldidonna commented Jan 13, 2021

Nice, thanks! I had so far avoided doing this because deleting a note is a dangerous action. If sync is not setup, there's no way to recover deleted notes.

We could think of adding a bin to show the deleted notes. The bin would be automatically emptied at regular time intervals by a Worker. The bin would be a sort of 'special folder', graphically distinguished from the normal ones and without the permission to manually add new notes there.

@saket
Copy link
Owner

saket commented Jan 13, 2021

I'm not sure I understand why it would be better only if the Syncer status is Enabled because in both cases there's no way to recover deleted notes?

If sync is enabled then deleted notes will be part of user's version history. Recovering deleted notes is one git revert command away.

We could think of adding a bin to show the deleted notes

Right that's the eventual plan for the future, and also a reason why I hadn't added a delete action yet. But now I think it's okay to let users delete notes provided that they've sync enabled.

I also want to add a confirmation popup for deleting notes, similar to how Press shows a confirmation popup menu if you try disabling sync. But that's going to require some changes to how EditorPresenter handles menu events so I can do it later.

@saket saket merged commit b039c20 into saket:trunk Jan 17, 2021
@saket
Copy link
Owner

saket commented Jan 17, 2021

This looks good enough. I'd remove an extra distinctUntilChanged(), but I can do that myself. Thanks for contributing!

@saket saket mentioned this pull request Jan 17, 2021
@evowizz
Copy link
Contributor Author

evowizz commented Jan 17, 2021

Awesome, thanks!

@evowizz evowizz deleted the delete-note-action branch January 17, 2021 16:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants