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
hidden flows and custom toc removed from non-touch devices #11690
hidden flows and custom toc removed from non-touch devices #11690
Conversation
We care about not changing a lots of code just for indentation issues when not really needed (unlike with your other status bar or screensaver PRs where there is no alternative), to not mess git history and see who did change what when. This PR as-is would attribute all that code to you and now. if not Device:isTouchDevice() then
-- Remove them as not really usable
menu_items.handmade_toc = nil
menu_items.handmade_hidden_flows = nil
end (it would be stuff created for nothing and some CPU wasted, but we don't care that much about non touch devices). BUT:
People may have other kind of workflows, ie. when they want it do that on another device or their PC, and sync the docsettings to their devices, and get the feature, even if they don't/can't edit it on the NT device itself. |
Not entirely true, MenuSorter can be used internally even without taking everything global. (Granted, the conversion would still have to happen, but after that.)
Since it seems to apply it to everything, an early return would make more sense (and not just from a diff perspective).
|
who wrote this code?
I do.
trust me, no one is doing it. It is way, way, way too annoying (and easy to get wrong). It is not easy to navigate through a book on non-touch. It would be like threading a needle whilst tightrope walking, technically possible but no old ladies are doing it just to sew their grandchild's trousers. |
UIManager:show(InfoMessage:new{ | ||
text = _([[ | ||
If the book has no table of contents or you would like to substitute it with your own, you can create a custom TOC. The original TOC (if available) will not be altered. | ||
if Device:isTouchDevice() then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For an early return the code can be simplified like this:
if Device:isTouchDevice() then | |
if Device:isTouchDevice() then | |
return | |
end |
We (or at least I) prefer that legibility-wise. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if Device:isTouchDevice() then
EXISTING CODE
return
end
that what you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. ^_^ I mean exactly what I wrote. None of the changes, only an early return.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a random result that seems to offer a reasonable explanation as to why I often prefer it (if applicable): https://medium.com/swlh/return-early-pattern-3d18a41bba8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that it also solves the parallel diff/blame discussion is merely incidental to me but it happens to solve that as well. ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return means it returns a value to the caller. Nothing can happen after that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if Device:isTouchDevice() then
return
end
EXISTING CODE
but then the whole thing would run regardless, again pardon my inexperience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing under return will run. But I see where I caused confusion, I forgot to update the condition as appropriate.
if Device:isTouchDevice() then | |
if not Device:isTouchDevice() then | |
return | |
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, incidentally though you were suggesting to remove them from touch enabled devices 🤓. would have caused quite the stir.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally speak in pseudo-code, sorry for the confusion. It might accidentally be exactly right but it's not expected to be.
what if I do something naughty and not indent?
not pretty but would solve the attribution and wasted memory issues. Then the person who originally wrote it could go and make it pretty again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
is there going to be a stable release this month? |
It's not really about the attribution, rather the history and what you see when you hit "Blame": For this recent readerhandmade.lua, there was not much activity, but try it on other older modules: This is one of the most valuable feature of git - so when you don't understand something, you can get there to see when and why it was introduced and follow the related past changes and further fixes. |
If you're asking before the weekend then definitely no, for this month I don't know yet. |
self:updateHandmagePages() | ||
-- Don't have these send events their own events | ||
self:setupFlows(true) | ||
self:setupToc(true) | ||
if Device:isTouchDevice() then | ||
self:setupFlows(true) | ||
self:setupToc(true) | ||
end | ||
-- ReaderToc will process this event just after us, and will |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these 2 self:setupXyz() (but not self:updateHAndmagePages()?) really cause issues when called when nothing has been setup because there was no menu item to do so?
If none, I would just let that be as it was.
(And may be this won't break workflows such as the one I mentionned.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the setupFlows
definitely caused issues. I can be more specific if you want.
I take that back, in its original form it would complain about setupFlows
, with the early return it doesn't...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed now, just for you.
options to set 'custom hidden flows' and 'custom ToC' clutter the menus of non-touch devices. There is no available 'page browser' therefore these options cannot be used in them.
Technically you could set the ToC up, but it is SUCH a pain in the *rse you might as well just remove it altogether.
this PR looks scary but all it is really doing is
This change is