lbry-desktop/ui/component/router/index.js
Dalton Hill 6d88d87ff2
Right Click to Navigate History (#3547)
* merge && backwards functionality working (kind of) WIP

* wip - need to fix forward and backwards buttons

* history works well but only for channel related pages - need to add title update hook for other pages

* moved useEffect to router

* renamed buttonNavigation -> navigationButton

* removed unused history

* fixed issue with lbry.tv

* disable button if no entries

* added max size for history

* set correct margin-top for nav button dropdown

* cleanup

Co-authored-by: Sean Yesmunt <sean@lbry.io>
2020-02-03 10:19:15 -05:00

33 lines
919 B
JavaScript

import { connect } from 'react-redux';
import { selectUserVerifiedEmail } from 'lbryinc';
import { selectScrollStartingPosition } from 'redux/selectors/app';
import Router from './view';
import { normalizeURI, makeSelectTitleForUri } from 'lbry-redux';
const select = state => {
const { pathname, hash } = state.router.location;
const urlPath = pathname + hash;
// Remove the leading "/" added by the browser
const path = urlPath.slice(1).replace(/:/g, '#');
let uri;
try {
uri = normalizeURI(path);
} catch (e) {
const match = path.match(/[#/:]/);
if (!path.startsWith('$/') && match && match.index) {
uri = `lbry://${path.slice(0, match.index)}`;
}
}
return {
uri,
title: makeSelectTitleForUri(uri)(state),
currentScroll: selectScrollStartingPosition(state),
isAuthenticated: selectUserVerifiedEmail(state),
};
};
export default connect(select)(Router);