2019-07-17 22:49:06 +02:00
|
|
|
import { connect } from 'react-redux';
|
2020-07-10 23:04:36 +02:00
|
|
|
import { selectHasNavigated, selectScrollStartingPosition, selectWelcomeVersion } from 'redux/selectors/app';
|
2020-11-10 17:07:00 +01:00
|
|
|
import { selectHomepageData } from 'redux/selectors/settings';
|
2018-04-18 06:03:01 +02:00
|
|
|
import Router from './view';
|
2021-10-08 05:47:39 +02:00
|
|
|
import { normalizeURI } from 'util/lbryURI';
|
2022-01-20 02:46:01 +01:00
|
|
|
import { selectTitleForUri } from 'redux/selectors/claims';
|
2020-09-04 17:02:30 +02:00
|
|
|
import { doSetHasNavigated } from 'redux/actions/app';
|
2020-10-07 02:59:38 +02:00
|
|
|
|
2021-10-08 05:47:39 +02:00
|
|
|
const select = (state) => {
|
2020-01-25 21:37:02 +01:00
|
|
|
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,
|
2022-01-20 02:46:01 +01:00
|
|
|
title: selectTitleForUri(state, uri),
|
2020-01-25 21:37:02 +01:00
|
|
|
currentScroll: selectScrollStartingPosition(state),
|
2020-02-19 07:31:40 +01:00
|
|
|
welcomeVersion: selectWelcomeVersion(state),
|
2020-07-10 23:04:36 +02:00
|
|
|
hasNavigated: selectHasNavigated(state),
|
2020-11-10 17:07:00 +01:00
|
|
|
homepageData: selectHomepageData(state),
|
2020-01-25 21:37:02 +01:00
|
|
|
};
|
|
|
|
};
|
2019-07-17 22:49:06 +02:00
|
|
|
|
2021-10-08 05:47:39 +02:00
|
|
|
const perform = (dispatch) => ({
|
2020-07-10 23:04:36 +02:00
|
|
|
setHasNavigated: () => dispatch(doSetHasNavigated()),
|
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(select, perform)(Router);
|