Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile: Resolves #4989: Implement sorting of notes #7981

Closed
wants to merge 15 commits into from

Conversation

jcgurango
Copy link
Contributor

The mobile apps do not currently have the ability to edit the custom sort of notes (even though these are displayed and function correctly if performed first on Desktop and then synchronized). This is pretty necessary for my personal usage of the app so I've implemented it myself and sharing my solution. I'm open to changing how it all works to conform more to the rest of the app if necessary.

Related issue: #4989

Note sorting is implemented by a long-press and drag gesture.

joplin-sorting-demo.webm

If the current sorting is not "Custom Sort", the user is prompted with a message similar to Desktop.

joplin-sorting-message-demo.webm

The original long-press to select is replaced with a swipe gesture. I'm open to making this a setting or something, or maybe we can add a right-swipe menu that includes many actions (delete, duplicate, move, select many).

joplin-sorting-selection-demo.webm

@jcgurango jcgurango changed the title Mobile: Resolves #4989: Implement sorting of notes and parenting of notebooks Mobile: Resolves #4989: Implement sorting of notes Mar 27, 2023
@tessus tessus added the mobile All mobile platforms label Mar 28, 2023
};
})(NoteListComponent);

export default NoteList;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I can't review this, since git shows this as a deleted file and a new file instead of a renamed file. You may have to use the git mv command or similar to make it work. If we can't review we can't merge

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git shows this as a deleted file and a new file instead of a renamed file. You may have to use the git mv command or similar to make it work

Hmm, unfortunately, that's not how git works. Rename detection is a client-side concern, driven by heuristics around the number of lines changed. git mv a b is really just a shortcut for mv a b && git add a && git add b, doing the physical move and adding the removed and added files to the index.

If it is important to you that this be treated as a move in your review, then you must ask that the file be "changed less" (in terms of touched-line-count, across all commits). However, looking at the changes, many of them appear related to the switch to tsx, I'm not sure at a glance which ones are optional.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I was hoping mv would be part of the heuristic they could use for this, but indeed if it's not recorded anywhere it's annoying. There isn't much that's changed in this file actually, so I'm surprised git cannot detect that it's the same file. Perhaps we should have two pull requests - one for the TS conversion, and one for the actual changes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation @TaoK, I guess perhaps because it's a different file type it's not detected as a rename? I can separate out the TS change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess perhaps because it's a different file type it's not detected as a rename?

No, the rename detection is based on file change % (by lines). The default change % to trigger a rename detection is 50% - I expect that's what github uses.

There isn't much that's changed in this file actually

I see most of it changed: I can see it as a rename, locally, by telling git to drop the similarity requirement to 10% rather than the 50% default, eg git diff ...jcgurango/feature/mobile-sorting --find-renames=10%, and I then see that almost all the imports are different, the interfaces are new, the declarations are different, much/most of the rendering logic is changed, and the export is different.

@laurent22
Copy link
Owner

The drag and drop of notes is nice, but unfortunately we then lose the existing long press. Isn't it possible to keep both? If you long press and move the note, you drag and drop it, but if you don't move you open the menu. I think that's how it's generally handled in mobile apps.

If the current sorting is not "Custom Sort", the user is prompted with a message similar to Desktop.

It displays a menu, but the "OK" button seems to be grayed out?

@jcgurango
Copy link
Contributor Author

Okay I've kind of combined the two gestures. Now the drag will just start if you've started dragging the item, and the long press is back but won't trigger if you're dragging an item. Not quite sure of the best way to do long-press-then-drag, so if anyone's got suggestions we can try them. Also not sure why your "OK" is greyed out, seems fine on my end:
image

Tested on my actual phone too.

@laurent22
Copy link
Owner

I've been trying to get this working on my laptop but there are so many issues I couldn't. Was it building for you, and did you commit all the changes? For example, I had to add packages to package.json, remove some variables that weren't in use, etc. But even after that, I'm still getting this error:

image

And I don't know how to fix this. If you're interested in getting this PR working I put my changes in this branch, including resolved conflicts:

https://github.com/laurent22/joplin/commits/jcgurango-feature/mobile-sorting

@jcgurango jcgurango force-pushed the feature/mobile-sorting branch from 844f868 to d8f721c Compare July 11, 2023 12:37
@jcgurango
Copy link
Contributor Author

jcgurango commented Jul 11, 2023

@laurent22 Rebased and it's building for me now. Turns out my initial implementation for combining the gestures fell apart when scrolling (i.e. when the list doesn't all fit on the screen). Tried several different ways involving a GestureDetector, composing gestures, etc. This was the best I could come up with, I don't think we're gonna be able to get it to be more responsive than this without some extensive reengineering.

@laurent22
Copy link
Owner

This was the best I could come up with, I don't think we're gonna be able to get it to be more responsive than this without some extensive reengineering.

So what is the issue with the current implementation?

@jcgurango
Copy link
Contributor Author

jcgurango commented Jul 14, 2023

@laurent22 it's usable, just that you have to long press and release instead of just long pressing.

@PaulS-26
Copy link

@laurent22 Would it be possible to merge this for release 2.12?

Manual sorting is a prerequisite for several note taking workflows not yet possible on mobile and certainly a long-awaited and appreciated feature.

Even if usability is not optimal yet, it would be great if this would be enabled at all. Thank you for the great work!

@laurent22
Copy link
Owner

@jcgurango, sorry for taking time to review this. I would like to test the change on simulator - would you mind fixing the conflict so that the branch can be built?

@laurent22
Copy link
Owner

@jcgurango, I'm going to close this pull request for now, but feel free to let me know if you'd like to get it working again

@laurent22 laurent22 closed this Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile All mobile platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants