fix colon handling

This commit is contained in:
zeppi 2021-07-15 16:22:44 -04:00 committed by jessopb
parent 0e589c0401
commit b2b88b466e
13 changed files with 50 additions and 32 deletions

View file

@ -149,7 +149,7 @@
"imagesloaded": "^4.1.4",
"json-loader": "^0.5.4",
"lbry-format": "https://github.com/lbryio/lbry-format.git",
"lbry-redux": "lbryio/lbry-redux#7d25ceb939a7ea2b83cabbbfe62a946c9992e381",
"lbry-redux": "lbryio/lbry-redux#f00cad483b691374652d7d525b2875f749303acf",
"lbryinc": "lbryio/lbryinc#8f9a58bfc8312a65614fd7327661cdcc502c4e59",
"lint-staged": "^7.0.2",
"localforage": "^1.7.1",

View file

@ -5,7 +5,7 @@ import * as CS from 'constants/claim_search';
import React from 'react';
import usePersistedState from 'effects/use-persisted-state';
import { withRouter } from 'react-router';
import { createNormalizedClaimSearchKey, MATURE_TAGS } from 'lbry-redux';
import { createNormalizedClaimSearchKey, MATURE_TAGS, splitBySeparator } from 'lbry-redux';
import Button from 'component/button';
import moment from 'moment';
import ClaimList from 'component/claimList';
@ -147,7 +147,9 @@ function ClaimListDiscover(props: Props) {
(urlParams.get(CS.TAGS_KEY) !== null && urlParams.get(CS.TAGS_KEY)) ||
(defaultTags && getParamFromTags(defaultTags));
const freshnessParam = freshness || urlParams.get(CS.FRESH_KEY) || defaultFreshness;
const mutedAndBlockedChannelIds = Array.from(new Set(mutedUris.concat(blockedUris).map((uri) => uri.split('#')[1])));
const mutedAndBlockedChannelIds = Array.from(
new Set(mutedUris.concat(blockedUris).map((uri) => splitBySeparator(uri)[1]))
);
const langParam = urlParams.get(CS.LANGUAGE_KEY) || null;
const languageParams = searchInLanguage

View file

@ -4,7 +4,7 @@ import React, { useEffect, forwardRef } from 'react';
import { NavLink, withRouter } from 'react-router-dom';
import { lazyImport } from 'util/lazyImport';
import classnames from 'classnames';
import { parseURI, COLLECTIONS_CONSTS } from 'lbry-redux';
import { parseURI, COLLECTIONS_CONSTS, isURIEqual } from 'lbry-redux';
import { formatLbryUrlForWeb } from 'util/url';
import { isEmpty } from 'util/object';
import FileThumbnail from 'component/fileThumbnail';
@ -29,7 +29,9 @@ import { ENABLE_NO_SOURCE_CLAIMS } from 'config';
import Button from 'component/button';
import * as ICONS from 'constants/icons';
const AbandonedChannelPreview = lazyImport(() => import('component/abandonedChannelPreview' /* webpackChunkName: "abandonedChannelPreview" */));
const AbandonedChannelPreview = lazyImport(() =>
import('component/abandonedChannelPreview' /* webpackChunkName: "abandonedChannelPreview" */)
);
type Props = {
uri: string,
@ -207,10 +209,10 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
}
// block stream claims
if (claim && !shouldHide && !showUserBlocked && mutedUris.length && signingChannel) {
shouldHide = mutedUris.some((blockedUri) => blockedUri === signingChannel.permanent_url);
shouldHide = mutedUris.some((blockedUri) => isURIEqual(blockedUri, signingChannel.permanent_url));
}
if (claim && !shouldHide && !showUserBlocked && blockedUris.length && signingChannel) {
shouldHide = blockedUris.some((blockedUri) => blockedUri === signingChannel.permanent_url);
shouldHide = blockedUris.some((blockedUri) => isURIEqual(blockedUri, signingChannel.permanent_url));
}
if (!shouldHide && customShouldHide && claim) {

View file

@ -10,7 +10,7 @@ import ChannelThumbnail from 'component/channelThumbnail';
import SubscribeButton from 'component/subscribeButton';
import useGetThumbnail from 'effects/use-get-thumbnail';
import { formatLbryUrlForWeb } from 'util/url';
import { parseURI, COLLECTIONS_CONSTS } from 'lbry-redux';
import { parseURI, COLLECTIONS_CONSTS, isURIEqual } from 'lbry-redux';
import PreviewOverlayProperties from 'component/previewOverlayProperties';
import FileDownloadLink from 'component/fileDownloadLink';
import FileWatchLaterLink from 'component/fileWatchLaterLink';
@ -155,12 +155,12 @@ function ClaimPreviewTile(props: Props) {
// block stream claims
if (claim && !shouldHide && !showHiddenByUser && blockedChannelUris.length && signingChannel) {
shouldHide = blockedChannelUris.some((blockedUri) => blockedUri === signingChannel.permanent_url);
shouldHide = blockedChannelUris.some((blockedUri) => isURIEqual(blockedUri, signingChannel.permanent_url));
}
// block channel claims if we can't control for them in claim search
// e.g. fetchRecommendedSubscriptions
if (claim && isChannel && !shouldHide && !showHiddenByUser && blockedChannelUris.length) {
shouldHide = blockedChannelUris.some((blockedUri) => blockedUri === claim.permanent_url);
if (claim && isChannel && !shouldHide && !showHiddenByUser && blockedChannelUris.length && signingChannel) {
shouldHide = blockedChannelUris.some((blockedUri) => isURIEqual(blockedUri, signingChannel.permanent_url));
}
if (shouldHide || (isLivestream && !showNoSourceClaims)) {

View file

@ -3,7 +3,7 @@ import { ENABLE_NO_SOURCE_CLAIMS, SIMPLE_SITE } from 'config';
import * as CS from 'constants/claim_search';
import type { Node } from 'react';
import React from 'react';
import { createNormalizedClaimSearchKey, MATURE_TAGS } from 'lbry-redux';
import { createNormalizedClaimSearchKey, MATURE_TAGS, splitBySeparator } from 'lbry-redux';
import ClaimPreviewTile from 'component/claimPreviewTile';
import { useHistory } from 'react-router';
import { getLivestreamOnlyOptions } from 'util/search';
@ -155,7 +155,9 @@ function ClaimTilesDiscover(props: Props) {
const urlParams = new URLSearchParams(location.search);
const feeAmountInUrl = urlParams.get('fee_amount');
const feeAmountParam = feeAmountInUrl || feeAmount;
const mutedAndBlockedChannelIds = Array.from(new Set(mutedUris.concat(blockedUris).map((uri) => uri.split('#')[1])));
const mutedAndBlockedChannelIds = Array.from(
new Set(mutedUris.concat(blockedUris).map((uri) => splitBySeparator(uri)[1]))
);
const liveUris = [];
const [prevUris, setPrevUris] = React.useState([]);

View file

@ -14,6 +14,7 @@ import { onFullscreenChange } from 'util/full-screen';
import { useIsMobile } from 'effects/use-screensize';
import debounce from 'util/debounce';
import { useHistory } from 'react-router';
import { isURIEqual } from 'lbry-redux';
const IS_DESKTOP_MAC = typeof process === 'object' ? process.platform === 'darwin' : false;
const DEBOUNCE_WINDOW_RESIZE_HANDLER_MS = 60;
@ -55,7 +56,7 @@ export default function FileRenderFloating(props: Props) {
location: { pathname },
} = useHistory();
const isMobile = useIsMobile();
const mainFilePlaying = playingUri && playingUri.uri === primaryUri;
const mainFilePlaying = playingUri && isURIEqual(playingUri.uri, primaryUri);
const [fileViewerRect, setFileViewerRect] = useState();
const [desktopPlayStartTime, setDesktopPlayStartTime] = useState();
const [wasDragging, setWasDragging] = useState(false);

View file

@ -6,6 +6,7 @@ import { Modal } from 'modal/modal';
import Card from 'component/common/card';
import I18nMessage from 'component/i18nMessage';
import Button from 'component/button';
import { isURIEqual } from 'lbry-redux';
// This number is tied to transitions in scss/purchase.scss
const ANIMATION_LENGTH = 2500;
@ -16,7 +17,7 @@ type Props = {
uri: string,
cancelPurchase: () => void,
metadata: StreamMetadata,
analyticsPurchaseEvent: GetResponse => void,
analyticsPurchaseEvent: (GetResponse) => void,
playingUri: ?PlayingUri,
setPlayingUri: (?string) => void,
};
@ -37,7 +38,7 @@ function ModalAffirmPurchase(props: Props) {
function onAffirmPurchase() {
setPurchasing(true);
loadVideo(uri, fileInfo => {
loadVideo(uri, (fileInfo) => {
setPurchasing(false);
setSuccess(true);
analyticsPurchaseEvent(fileInfo);
@ -49,7 +50,7 @@ function ModalAffirmPurchase(props: Props) {
}
function cancelPurchase() {
if (playingUri && uri === playingUri.uri) {
if (playingUri && isURIEqual(uri, playingUri.uri)) {
setPlayingUri(null);
}

View file

@ -10,6 +10,7 @@ import Page from 'component/page';
import Button from 'component/button';
import Icon from 'component/common/icon';
import useGetLivestreams from 'effects/use-get-livestreams';
import { splitBySeparator } from 'lbry-redux';
type Props = {
subscribedChannels: Array<Subscription>,
@ -36,7 +37,7 @@ function ChannelsFollowingPage(props: Props) {
</span>
}
defaultOrderBy={CS.ORDER_BY_NEW}
channelIds={subscribedChannels.map((sub) => sub.uri.split('#')[1])}
channelIds={subscribedChannels.map((sub) => splitBySeparator(sub.uri)[1])}
meta={
<Button
icon={ICONS.SEARCH}

View file

@ -3,7 +3,15 @@ import * as ACTIONS from 'constants/action_types';
import * as REACTION_TYPES from 'constants/reactions';
import * as PAGES from 'constants/pages';
import { BLOCK_LEVEL } from 'constants/comment';
import { Lbry, parseURI, buildURI, selectClaimsById, selectClaimsByUri, selectMyChannelClaims } from 'lbry-redux';
import {
Lbry,
parseURI,
buildURI,
selectClaimsById,
selectClaimsByUri,
selectMyChannelClaims,
isURIEqual,
} from 'lbry-redux';
import { doToast, doSeeNotifications } from 'redux/actions/notifications';
import {
makeSelectCommentIdsForUri,
@ -849,7 +857,7 @@ export function doFetchModBlockedList() {
claimId: blockedChannel.blocked_channel_id,
});
if (!blockedList.find((blockedChannel) => blockedChannel.channelUri === channelUri)) {
if (!blockedList.find((blockedChannel) => isURIEqual(blockedChannel.channelUri, channelUri))) {
blockedList.push({ channelUri, blockedAt: blockedChannel.blocked_at });
}

View file

@ -2,7 +2,7 @@
import * as ACTIONS from 'constants/action_types';
import { handleActions } from 'util/redux-utils';
import { BLOCK_LEVEL } from 'constants/comment';
import { isURIEqual } from 'lbry-redux';
const defaultState: CommentsState = {
commentById: {}, // commentId -> Comment
byId: {}, // ClaimID -> list of comments
@ -548,7 +548,7 @@ export default handleActions(
for (const commentId in commentById) {
const comment = commentById[commentId];
if (blockedUri === comment.channel_url) {
if (isURIEqual(blockedUri, comment.channel_url)) {
delete commentById[comment.comment_id];
}
}

View file

@ -1,6 +1,6 @@
// @flow
import * as ACTIONS from 'constants/action_types';
import { parseURI, ACTIONS as LBRY_REDUX_ACTIONS } from 'lbry-redux';
import { parseURI, normalizeURI, isURIEqual, ACTIONS as LBRY_REDUX_ACTIONS } from 'lbry-redux';
import { handleActions } from 'util/redux-utils';
const defaultState: SubscriptionState = {
@ -17,21 +17,21 @@ export default handleActions(
const newSubscriptions: Array<Subscription> = state.subscriptions.slice();
let newFollowing: Array<Following> = state.following.slice();
// prevent duplicates in the sidebar
if (!newSubscriptions.some((sub) => sub.uri === newSubscription.uri)) {
if (!newSubscriptions.some((sub) => isURIEqual(sub.uri, newSubscription.uri))) {
// $FlowFixMe
newSubscriptions.unshift(newSubscription);
}
if (!newFollowing.some((sub) => sub.uri === newSubscription.uri)) {
if (!newFollowing.some((sub) => isURIEqual(sub.uri, newSubscription.uri))) {
newFollowing.unshift({
uri: newSubscription.uri,
notificationsDisabled: newSubscription.notificationsDisabled,
});
} else {
newFollowing = newFollowing.map((following) => {
if (following.uri === newSubscription.uri) {
if (isURIEqual(following.uri, newSubscription.uri)) {
return {
uri: newSubscription.uri,
uri: normalizeURI(newSubscription.uri),
notificationsDisabled: newSubscription.notificationsDisabled,
};
} else {

View file

@ -5,6 +5,7 @@ import {
makeSelectChannelForClaimUri,
parseURI,
makeSelectClaimForUri,
isURIEqual,
} from 'lbry-redux';
import { swapKeyAndValue } from 'util/swap-json';
@ -112,7 +113,7 @@ export const makeSelectIsSubscribed = (uri) =>
makeSelectClaimForUri(uri),
(subscriptions, channelUri, claim) => {
if (channelUri) {
return subscriptions.some((sub) => sub.uri === channelUri);
return subscriptions.some((sub) => isURIEqual(sub.uri, channelUri));
}
// If we couldn't get a channel uri from the claim uri, the uri passed in might be a channel already
@ -123,11 +124,11 @@ export const makeSelectIsSubscribed = (uri) =>
if (isChannel && claim) {
const uri = claim.permanent_url;
return subscriptions.some((sub) => sub.uri === uri);
return subscriptions.some((sub) => isURIEqual(sub.uri, uri));
}
if (isChannel && !claim) {
return subscriptions.some((sub) => sub.uri === uri);
return subscriptions.some((sub) => isURIEqual(sub.uri, uri));
}
return false;

View file

@ -7283,9 +7283,9 @@ lazy-val@^1.0.4:
yargs "^13.2.2"
zstd-codec "^0.1.1"
lbry-redux@lbryio/lbry-redux#7d25ceb939a7ea2b83cabbbfe62a946c9992e381:
lbry-redux@lbryio/lbry-redux#f00cad483b691374652d7d525b2875f749303acf:
version "0.0.1"
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/7d25ceb939a7ea2b83cabbbfe62a946c9992e381"
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/f00cad483b691374652d7d525b2875f749303acf"
dependencies:
proxy-polyfill "0.1.6"
reselect "^3.0.0"