2019-07-17 22:49:06 +02:00
|
|
|
import { connect } from 'react-redux';
|
2022-03-31 16:19:19 +02:00
|
|
|
import * as SETTINGS from 'constants/settings';
|
2020-06-15 22:33:03 +02:00
|
|
|
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
2022-03-29 08:45:59 +02:00
|
|
|
import { selectHasNavigated, selectScrollStartingPosition } from 'redux/selectors/app';
|
2022-03-31 16:19:19 +02:00
|
|
|
import { selectClientSetting, selectHomepageData, selectWildWestDisabled } from 'redux/selectors/settings';
|
2018-04-18 06:03:01 +02:00
|
|
|
import Router from './view';
|
2021-10-17 10:36:14 +02:00
|
|
|
import { normalizeURI } from 'util/lbryURI';
|
2021-11-16 05:23:18 +01:00
|
|
|
import { selectTitleForUri } from 'redux/selectors/claims';
|
2022-05-04 15:59:10 +02:00
|
|
|
import { doSetHasNavigated, doSetActiveChannel } from 'redux/actions/app';
|
2020-10-07 02:59:38 +02:00
|
|
|
import { doUserSetReferrer } from 'redux/actions/user';
|
|
|
|
import { selectHasUnclaimedRefereeReward } from 'redux/selectors/rewards';
|
2022-03-22 19:03:39 +01:00
|
|
|
import { selectUnseenNotificationCount } from 'redux/selectors/notifications';
|
2020-10-07 02:59:38 +02:00
|
|
|
|
2021-10-17 10:36:14 +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,
|
2021-11-16 05:23:18 +01:00
|
|
|
title: selectTitleForUri(state, uri),
|
2020-01-25 21:37:02 +01:00
|
|
|
currentScroll: selectScrollStartingPosition(state),
|
|
|
|
isAuthenticated: selectUserVerifiedEmail(state),
|
2020-07-10 23:04:36 +02:00
|
|
|
hasNavigated: selectHasNavigated(state),
|
2020-10-07 02:59:38 +02:00
|
|
|
hasUnclaimedRefereeReward: selectHasUnclaimedRefereeReward(state),
|
2020-11-10 17:07:00 +01:00
|
|
|
homepageData: selectHomepageData(state),
|
2022-02-15 18:36:33 +01:00
|
|
|
wildWestDisabled: selectWildWestDisabled(state),
|
2022-03-22 19:03:39 +01:00
|
|
|
unseenCount: selectUnseenNotificationCount(state),
|
2022-03-31 16:19:19 +02:00
|
|
|
hideTitleNotificationCount: selectClientSetting(state, SETTINGS.HIDE_TITLE_NOTIFICATION_COUNT),
|
2022-05-04 15:59:10 +02:00
|
|
|
hasDefaultChannel: Boolean(selectClientSetting(state, SETTINGS.ACTIVE_CHANNEL_CLAIM)),
|
2020-01-25 21:37:02 +01:00
|
|
|
};
|
|
|
|
};
|
2019-07-17 22:49:06 +02:00
|
|
|
|
2022-05-04 15:59:10 +02:00
|
|
|
const perform = {
|
|
|
|
setHasNavigated: doSetHasNavigated,
|
|
|
|
setReferrer: doUserSetReferrer,
|
|
|
|
doSetActiveChannel,
|
|
|
|
};
|
2020-07-10 23:04:36 +02:00
|
|
|
|
|
|
|
export default connect(select, perform)(Router);
|