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

Right Click to Navigate History #3547

Merged
merged 11 commits into from
Feb 3, 2020
Merged

Conversation

dalhill
Copy link
Contributor

@dalhill dalhill commented Jan 25, 2020

PR Checklist

  • I have checked that this PR is not a duplicate of an existing PR (open, closed or merged)
  • I have checked that this PR does not introduce a breaking change

PR Type

  • Feature

Fixes

Issue Number: #3474

What is the current behavior?

In order to navigate history, the user must do so one step at a time.

What is the new behavior?

User is able to right click the navigation buttons to move forward or backward multiple steps.

backward

forward

Other information

Possible improvements

  • Limit the size of the history. Showing only 12 historical entries on either side. This is consistent with chrome.
  • Configure the list to dropdown the same height as the other header buttons.
  • If there is no "forward" or "backward" action to be taken, disable the button.

useEffect(() => {
if (typeof title !== 'undefined' && title !== '') {
document.title = title;
} else if (typeof streamName !== 'undefined' && streamName !== 'undefined' && streamName !== '') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

BTW - streamName was coming as a string of value 'undefined'. I didn't look too far into this bug.

Copy link

Choose a reason for hiding this comment

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

I think it's when you call parseURI with an undefined uri. Only calling parseURI if uri exists should fix it.

Copy link

@neb-b neb-b left a comment

Choose a reason for hiding this comment

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

A few questions

@@ -96,7 +96,7 @@ const persistOptions = {

let history;
// @if TARGET='app'
history = createHashHistory();
history = createMemoryHistory();
Copy link

Choose a reason for hiding this comment

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

What is the difference between these two?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

createMemoryHistory gives us an array of entries so that we can reference the history stack.

Excerpt from history/docs/GettingStarted

Additionally, createMemoryHistory provides history.index and history.entries properties that let you inspect the history stack.

const { entries } = history;
const entryIndex = history.index;

useEffect(() => {
Copy link

Choose a reason for hiding this comment

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

Why did you move this effect out of the show component?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I want this to fire on every page and not just the pages that render using the ShowPage component.

const slicedEntries = sliceEntries(currentIndex, entries, historyLength, isBackward);
return (
<div>
<Button
Copy link

Choose a reason for hiding this comment

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

Are you able to determine if we can go back here or not? If so, it would be great to disable the back button and give it some disabled style so it's easier to tell that you can't

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PR has been updated to disable button if no historical entries.

Copy link

Choose a reason for hiding this comment

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

Awesome!

@lbry-bot lbry-bot assigned neb-b and unassigned neb-b Jan 27, 2020
@tzarebczan
Copy link
Contributor

Thanks for the PR! Once this is fully reviewed/corrected/merged, please send us an email so we can show you some appreciation

@lbry-bot lbry-bot assigned neb-b and unassigned neb-b Jan 28, 2020
@neb-b
Copy link

neb-b commented Jan 28, 2020

Nice work @dalhill. This is really close.

I'll spend some time testing your branch this week just to make sure there aren't any issues on electron moving to memoryHistory, but I don't think there will be. I'll also push up a commit and do another pass at the styling.

@dalhill
Copy link
Contributor Author

dalhill commented Jan 29, 2020

Pushed to resolve conflicts

Copy link

@neb-b neb-b left a comment

Choose a reason for hiding this comment

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

I pushed up a commit that cleaned up the styling. I'll get this merged today!

useEffect(() => {
if (typeof title !== 'undefined' && title !== '') {
document.title = title;
} else if (typeof streamName !== 'undefined' && streamName !== 'undefined' && streamName !== '') {
Copy link

Choose a reason for hiding this comment

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

I think it's when you call parseURI with an undefined uri. Only calling parseURI if uri exists should fix it.

@lbry-bot lbry-bot assigned neb-b and unassigned neb-b Feb 3, 2020
@neb-b neb-b merged commit 6d88d87 into lbryio:master Feb 3, 2020
neb-b pushed a commit that referenced this pull request Feb 3, 2020
neb-b pushed a commit that referenced this pull request Feb 3, 2020
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.

3 participants