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

feat(frontend): add toggle to remove line and page numbers from transliterations and translations #578

Merged
merged 17 commits into from
Jun 28, 2020

Conversation

saihaj
Copy link
Member

@saihaj saihaj commented Jun 4, 2020

Summary of PR

Using stripEndings() adds toggle that allows user to hide the line endings for translations and transliterations in the following settings tabs:

  • Display
  • Overlay
  • Search

Tests for unexpected behavior

  • Tested on browser and electron and works!
  • Passing null vals doesn't make it crash
  • Don't stripEndings for Sirlekh

Unhide Line Endings
image

image

image

Hide Line Endings:
image

image

image

Time spent on PR

6.5 hours

Linked issues

Fix #508

Reviewers

@Harjot1Singh @bhajneet

Note: Don't forget npm install since gurmukhi-util packages was updated.

@Harjot1Singh
Copy link
Member

Note: feat(frontend/controller, overlay, presenter) is not correct, you'd need to use the full scope for each.

On a side note, I don't think it's actually correct to use the comma notation, even though I have, but instead use frontend solely as the scope

@saihaj
Copy link
Member Author

saihaj commented Jun 6, 2020

Note: feat(frontend/controller, overlay, presenter) is not correct, you'd need to use the full scope for each.

On a side note, I don't think it's actually correct to use the comma notation, even though I have, but instead use frontend solely as the scope

So I can either do feat(frontend) or 3 different commits feat(frontend/controller) and etc...?

Copy link
Member

@Harjot1Singh Harjot1Singh left a comment

Choose a reason for hiding this comment

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

Generally, not sure I'm a fan of the parameter-passing, it's very similar to prop-drilling. Perhaps a utility function and/or usage of stripEndings directly would be a better approach? What if we wanted to add another option in the future? Would we keep extending the parameter list?

The approach otherwise is good.

@saihaj
Copy link
Member Author

saihaj commented Jun 6, 2020

Generally, not sure I'm a fan of the parameter-passing, it's very similar to prop-drilling. Perhaps a utility function and/or usage of stripEndings directly would be a better approach? What if we wanted to add another option in the future? Would we keep extending the parameter list?

The approach otherwise is good.

It is possible to do use stripEndings before rendering but that is much more work and complicates things up. +1 for extending the list but we know the downside (the mess that we need to take care of). So we need a different way that will allow us to keep these functions higher up such that we don't have to deal with long parameter lists.

@Harjot1Singh
Copy link
Member

Generally, not sure I'm a fan of the parameter-passing, it's very similar to prop-drilling. Perhaps a utility function and/or usage of stripEndings directly would be a better approach? What if we wanted to add another option in the future? Would we keep extending the parameter list?
The approach otherwise is good.

It is possible to do use stripEndings before rendering but that is much more work and complicates things up. +1 for extending the list but we know the downside (the mess that we need to take care of). So we need a different way that will allow us to keep these functions higher up such that we don't have to deal with long parameter lists.

Are you proposing a different solution, or did you mean you prefer extending the list? My suggestion is to use or write something like lodash's mapValues, so the code would look like mapValues( transliterations, stripEndings ), which is readable and clean.

@saihaj
Copy link
Member Author

saihaj commented Jun 14, 2020

Generally, not sure I'm a fan of the parameter-passing, it's very similar to prop-drilling. Perhaps a utility function and/or usage of stripEndings directly would be a better approach? What if we wanted to add another option in the future? Would we keep extending the parameter list?

The approach otherwise is good.

It is possible to do use stripEndings before rendering but that is much more work and complicates things up. +1 for extending the list but we know the downside (the mess that we need to take care of). So we need a different way that will allow us to keep these functions higher up such that we don't have to deal with long parameter lists.

Are you proposing a different solution, or did you mean you prefer extending the list? My suggestion is to use or write something like lodash's mapValues, so the code would look like mapValues( transliterations, stripEndings ), which is readable and clean.

I preferred extending list, but something else that can make it readable will be amazing and I think I can change it to use the mapValues

@saihaj
Copy link
Member Author

saihaj commented Jun 15, 2020

@Harjot1Singh I think we can add mapValues in future when it is extended. Right now there are only 2 things in the hooks so should be fine

All the customizaions will run through a function which can be expanded in future to include more transformations.
app/frontend/src/lib/utils.js Outdated Show resolved Hide resolved
app/frontend/src/lib/utils.js Outdated Show resolved Hide resolved
app/frontend/src/lib/utils.js Outdated Show resolved Hide resolved
app/frontend/src/Controller/Search.js Outdated Show resolved Hide resolved
app/frontend/src/Overlay/index.js Outdated Show resolved Hide resolved
app/frontend/src/lib/utils.js Show resolved Hide resolved
app/settings.default.json Outdated Show resolved Hide resolved
@saihaj saihaj requested a review from Harjot1Singh June 16, 2020 23:40
app/frontend/src/lib/utils.js Outdated Show resolved Hide resolved
app/frontend/src/lib/utils.js Outdated Show resolved Hide resolved
app/frontend/src/Presenter/Display.js Outdated Show resolved Hide resolved
@saihaj saihaj requested a review from Harjot1Singh June 17, 2020 16:24
@saihaj
Copy link
Member Author

saihaj commented Jun 17, 2020

Should be good to merge now!

@bhajneet
Copy link
Member

Option name: Line Ending
Value: False
Result: Shows line endings

???

@saihaj
Copy link
Member Author

saihaj commented Jun 17, 2020

Can you give screenshot

@bhajneet
Copy link
Member

Just going off the screenshots provided in PR -- was this updated/changed?

@saihaj
Copy link
Member Author

saihaj commented Jun 17, 2020

nope

@saihaj
Copy link
Member Author

saihaj commented Jun 17, 2020

Just going off the screenshots provided in PR

Which one ?

@saihaj
Copy link
Member Author

saihaj commented Jun 17, 2020

Updated screenshots

@saihaj saihaj marked this pull request as draft June 17, 2020 17:23
@saihaj saihaj marked this pull request as ready for review June 17, 2020 18:52
@@ -23,18 +25,26 @@ const Overlay = () => {
} } = globalSettings || {}

const [ line ] = useCurrentLine()
const { typeId } = line || ''
Copy link
Member

Choose a reason for hiding this comment

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

Why the || '

Copy link
Member Author

Choose a reason for hiding this comment

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

because I was getting undefined errors so added it as a safety check

Copy link
Member

Choose a reason for hiding this comment

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

Deal with this inside customiseLine, since you presumably are doing this in multiple places

app/frontend/src/lib/consts.js Outdated Show resolved Hide resolved
app/frontend/src/lib/utils.js Outdated Show resolved Hide resolved
@saihaj saihaj requested a review from Harjot1Singh June 18, 2020 17:30
@@ -23,18 +25,26 @@ const Overlay = () => {
} } = globalSettings || {}

const [ line ] = useCurrentLine()
const { typeId } = line || ''
Copy link
Member

Choose a reason for hiding this comment

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

Deal with this inside customiseLine, since you presumably are doing this in multiple places

@saihaj
Copy link
Member Author

saihaj commented Jun 23, 2020

the problem I can't handle there is this ->
image

@Harjot1Singh
Copy link
Member

the problem I can't handle there is this ->
image

If you move the typeId || '' inside customiseLine, does this not solve that?

@saihaj
Copy link
Member Author

saihaj commented Jun 24, 2020

the problem I can't handle there is this ->
image

If you move the typeId || '' inside customiseLine, does this not solve that?

I have to destructure typeId from line and when line is undefined I get the TypeError

@saihaj saihaj requested a review from Harjot1Singh June 27, 2020 02:51
@Harjot1Singh
Copy link
Member

the problem I can't handle there is this ->
image

If you move the typeId || '' inside customiseLine, does this not solve that?

I have to destructure typeId from line and when line is undefined I get the TypeError

In this situation, it's ok to do the equivalent of line || {}, and then in customiseLine, typeId || ''. That should handle the TypeError

@saihaj
Copy link
Member Author

saihaj commented Jun 28, 2020

Doing line || {} is sufficient

@Harjot1Singh Harjot1Singh changed the title feat(frontend): ability to remove line and page numbers (translit and translations) feat(frontend): add toggle to remove line and page numbers from transliterations and translations Jun 28, 2020
@Harjot1Singh Harjot1Singh merged commit ec21bbb into shabados:dev Jun 28, 2020
@saihaj saihaj deleted the saihaj/issue508 branch June 28, 2020 18:26
@saihaj saihaj restored the saihaj/issue508 branch June 28, 2020 18:31
@saihaj saihaj deleted the saihaj/issue508 branch June 28, 2020 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to remove lines and page numbers from translits
3 participants