fix 7188 window.location.pathname (#7401)
This commit is contained in:
parent
ca799ae4ec
commit
34283f7be6
6 changed files with 35 additions and 77 deletions
|
@ -29,13 +29,11 @@ const SHARE_THIRD_PARTY = 'shareThirdParty';
|
|||
const WATCHMAN_BACKEND_ENDPOINT = 'https://watchman.na-backend.odysee.com/reports/playback';
|
||||
const SEND_DATA_TO_WATCHMAN_INTERVAL = 10; // in seconds
|
||||
|
||||
// @if TARGET='app'
|
||||
if (isProduction) {
|
||||
ElectronCookies.enable({
|
||||
origin: 'https://lbry.tv',
|
||||
});
|
||||
}
|
||||
// @endif
|
||||
|
||||
type Analytics = {
|
||||
error: (string) => Promise<any>,
|
||||
|
@ -83,11 +81,7 @@ type LogPublishParams = {
|
|||
};
|
||||
|
||||
let internalAnalyticsEnabled: boolean = IS_WEB || false;
|
||||
// let thirdPartyAnalyticsEnabled: boolean = IS_WEB || false;
|
||||
// @if TARGET='app'
|
||||
if (window.localStorage.getItem(SHARE_INTERNAL) === 'true') internalAnalyticsEnabled = true;
|
||||
// if (window.localStorage.getItem(SHARE_THIRD_PARTY) === 'true') thirdPartyAnalyticsEnabled = true;
|
||||
// @endif
|
||||
|
||||
/**
|
||||
* Determine the mobile device type viewing the data
|
||||
|
@ -96,26 +90,7 @@ if (window.localStorage.getItem(SHARE_INTERNAL) === 'true') internalAnalyticsEna
|
|||
* @returns {String}
|
||||
*/
|
||||
function getDeviceType() {
|
||||
// We may not care what the device is if it's in a web browser. Commenting out for now.
|
||||
// if (!IS_WEB) {
|
||||
// return 'elt';
|
||||
// }
|
||||
// const userAgent = navigator.userAgent || navigator.vendor || window.opera;
|
||||
//
|
||||
// if (/android/i.test(userAgent)) {
|
||||
// return 'adr';
|
||||
// }
|
||||
//
|
||||
// // iOS detection from: http://stackoverflow.com/a/9039885/177710
|
||||
// if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
|
||||
// return 'ios';
|
||||
// }
|
||||
|
||||
// default as web, this can be optimized
|
||||
if (!IS_WEB) {
|
||||
return 'dsk';
|
||||
}
|
||||
return 'web';
|
||||
return 'dsk';
|
||||
}
|
||||
// variables initialized for watchman
|
||||
let amountOfBufferEvents = 0;
|
||||
|
@ -449,17 +424,7 @@ const MatomoInstance = new MatomoTracker({
|
|||
// linkTracking: false // optional, default value: true
|
||||
});
|
||||
|
||||
// Manually call the first page view
|
||||
// React Router doesn't include this on `history.listen`
|
||||
// @if TARGET='web'
|
||||
analytics.pageView(window.location.pathname + window.location.search, window.location.search);
|
||||
// @endif
|
||||
|
||||
// @if TARGET='app'
|
||||
analytics.pageView(
|
||||
window.location.pathname.split('.html')[1] + window.location.search || generateInitialUrl(window.location.hash)
|
||||
);
|
||||
// @endif;
|
||||
analytics.pageView(generateInitialUrl(window.location.hash));
|
||||
|
||||
// Listen for url changes and report
|
||||
// This will include search queries
|
||||
|
|
|
@ -384,22 +384,6 @@ function ClaimListDiscover(props: Props) {
|
|||
const claimSearchResult = claimSearchByQuery[searchKey];
|
||||
const claimSearchResultLastPageReached = claimSearchByQueryLastPageReached[searchKey];
|
||||
|
||||
// uncomment to fix an item on a page
|
||||
// const fixUri = 'lbry://@corbettreport#0/lbryodysee#5';
|
||||
// if (
|
||||
// orderParam === CS.ORDER_BY_NEW &&
|
||||
// claimSearchResult &&
|
||||
// claimSearchResult.length > 2 &&
|
||||
// window.location.pathname === '/$/rabbithole'
|
||||
// ) {
|
||||
// if (claimSearchResult.indexOf(fixUri) !== -1) {
|
||||
// claimSearchResult.splice(claimSearchResult.indexOf(fixUri), 1);
|
||||
// } else {
|
||||
// claimSearchResult.pop();
|
||||
// }
|
||||
// claimSearchResult.splice(2, 0, fixUri);
|
||||
// }
|
||||
|
||||
const [prevOptions, setPrevOptions] = React.useState(null);
|
||||
|
||||
if (!isJustScrollingToNewPage(prevOptions, options)) {
|
||||
|
|
|
@ -29,7 +29,7 @@ type Props = {
|
|||
mediaDuration?: string,
|
||||
resolveUri: (string) => void,
|
||||
isResolvingUri: boolean,
|
||||
history: { push: (string) => void },
|
||||
history: { push: (string) => void, location: { pathname: string } },
|
||||
thumbnail: string,
|
||||
title: string,
|
||||
placeholder: boolean,
|
||||
|
@ -91,6 +91,7 @@ function ClaimPreviewTile(props: Props) {
|
|||
to: navigateUrl,
|
||||
onClick: (e) => e.stopPropagation(),
|
||||
};
|
||||
const { location } = history;
|
||||
|
||||
let isValid = false;
|
||||
if (uri) {
|
||||
|
@ -138,7 +139,7 @@ function ClaimPreviewTile(props: Props) {
|
|||
return null;
|
||||
}
|
||||
|
||||
const isChannelPage = window.location.pathname.startsWith('/@');
|
||||
const isChannelPage = location.pathname.startsWith('/@');
|
||||
|
||||
const shouldShowViewCount = !(!viewCount || (claim && claim.repost_url) || !isChannelPage);
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ function ClaimTilesDiscover(props: Props) {
|
|||
fetchingClaimSearchByQuery,
|
||||
hasNoSource,
|
||||
renderProperties,
|
||||
pinUrls,
|
||||
// pinUrls,
|
||||
prefixUris,
|
||||
showNoSourceClaims,
|
||||
doFetchViewCount,
|
||||
|
@ -106,17 +106,17 @@ function ClaimTilesDiscover(props: Props) {
|
|||
const shouldPerformSearch = !fetchingClaimSearch && claimSearchUris.length === 0;
|
||||
|
||||
const uris = (prefixUris || []).concat(claimSearchUris);
|
||||
|
||||
if (pinUrls && uris && uris.length > 2 && window.location.pathname === '/') {
|
||||
pinUrls.forEach((pin) => {
|
||||
if (uris.indexOf(pin) !== -1) {
|
||||
uris.splice(uris.indexOf(pin), 1);
|
||||
} else {
|
||||
uris.pop();
|
||||
}
|
||||
});
|
||||
uris.splice(2, 0, ...pinUrls);
|
||||
}
|
||||
// Not sure what to do with pinUrls
|
||||
// if (pinUrls && uris && uris.length > 2 && window.location.pathname === '/') {
|
||||
// pinUrls.forEach((pin) => {
|
||||
// if (uris.indexOf(pin) !== -1) {
|
||||
// uris.splice(uris.indexOf(pin), 1);
|
||||
// } else {
|
||||
// uris.pop();
|
||||
// }
|
||||
// });
|
||||
// uris.splice(2, 0, ...pinUrls);
|
||||
// }
|
||||
|
||||
if (uris.length > 0 && uris.length < pageSize && shouldPerformSearch) {
|
||||
// prefixUri and pinUrls might already be present while waiting for the
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// @flow
|
||||
import React from 'react';
|
||||
import 'scss/component/_view_count.scss';
|
||||
import { useHistory } from 'react-router';
|
||||
|
||||
type Props = {
|
||||
uri: string,
|
||||
|
@ -12,6 +13,9 @@ type Props = {
|
|||
|
||||
export default function FileViewCountInline(props: Props) {
|
||||
const { claim, viewCount, lang } = props;
|
||||
const {
|
||||
location: { pathname },
|
||||
} = useHistory();
|
||||
let formattedViewCount;
|
||||
|
||||
try {
|
||||
|
@ -27,7 +31,7 @@ export default function FileViewCountInline(props: Props) {
|
|||
// Limit the view-count visibility to Channel Pages for now. I believe we'll
|
||||
// eventually show it everywhere, so this band-aid would be the easiest to
|
||||
// clean up (only one place edit/remove).
|
||||
const isChannelPage = window.location.pathname.startsWith('/@');
|
||||
const isChannelPage = pathname.startsWith('/@');
|
||||
|
||||
// dont show if no view count, if it's a repost or isn't a channel page
|
||||
if (!viewCount || (claim && claim.repost_url) || !isChannelPage) {
|
||||
|
|
|
@ -12,15 +12,7 @@ import I18nMessage from 'component/i18nMessage';
|
|||
import ChannelThumbnail from 'component/channelThumbnail';
|
||||
import { DOMAIN, ENABLE_UI_NOTIFICATIONS } from 'config';
|
||||
import { IS_MAC } from 'component/app/view';
|
||||
|
||||
const HOME = {
|
||||
title: 'Home',
|
||||
link: `/`,
|
||||
icon: ICONS.HOME,
|
||||
onClick: () => {
|
||||
if (window.location.pathname === '/') window.location.reload();
|
||||
},
|
||||
};
|
||||
import { useHistory } from 'react-router';
|
||||
|
||||
const RECENT_FROM_FOLLOWING = {
|
||||
title: 'Following --[sidebar button]--',
|
||||
|
@ -71,6 +63,18 @@ function SideNavigation(props: Props) {
|
|||
followedTags,
|
||||
} = props;
|
||||
|
||||
const {
|
||||
location: { pathname },
|
||||
} = useHistory();
|
||||
|
||||
const HOME = {
|
||||
title: 'Home',
|
||||
link: `/`,
|
||||
icon: ICONS.HOME,
|
||||
onClick: () => {
|
||||
if (pathname === '/') window.location.reload();
|
||||
},
|
||||
};
|
||||
const FULL_LINKS: Array<SideNavLink> = [
|
||||
{
|
||||
title: 'Your Tags',
|
||||
|
|
Loading…
Reference in a new issue