fixes: canonical url + sub downloads

Sub downloads is just missing the last step - need to check why it's not being resolved/saved.
This commit is contained in:
Thomas Zarebczan 2019-08-29 19:18:06 -04:00 committed by Sean Yesmunt
parent 4e3bd44f4e
commit 3d4e35e32f
11 changed files with 37 additions and 42 deletions

View file

@ -129,7 +129,7 @@
"jsmediatags": "^3.8.1",
"json-loader": "^0.5.4",
"lbry-format": "https://github.com/lbryio/lbry-format.git",
"lbry-redux": "lbryio/lbry-redux#a9e2cc91838af340d4566b384b20d7b0af8e68df",
"lbry-redux": "lbryio/lbry-redux#48dd46a9a837d81cff8700b7a571baa8081bf3aa",
"lbryinc": "lbryio/lbryinc#1ce266b3c52654190b955e9c869b8e302aa5c585",
"lint-staged": "^7.0.2",
"localforage": "^1.7.1",

View file

@ -82,7 +82,7 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
let isValid = false;
if (uri) {
try {
({ claimName: name } = parseURI(uri));
({ streamName: name } = parseURI(uri));
isValid = true;
} catch (e) {
isValid = false;

View file

@ -102,13 +102,13 @@ function PublishForm(props: Props) {
// We are only going to store the full uri, but we need to resolve the uri with and without the channel name
let uri;
try {
uri = buildURI({ contentName: name, channelName });
uri = buildURI({ streamName: name, channelName });
} catch (e) {}
if (channelName) {
// resolve without the channel name so we know the winning bid for it
try {
const uriLessChannel = buildURI({ contentName: name });
const uriLessChannel = buildURI({ streamName: name });
resolveUri(uriLessChannel);
} catch (e) {}
}

View file

@ -19,8 +19,8 @@ function NameHelpText(props: Props) {
nameHelpText = __('You are currently editing this claim. If you change the URL, you will need to reselect a file.');
} else if (uri && myClaimForUri) {
const editUri = buildURI({
contentName: myClaimForUri.name,
claimId: myClaimForUri.claim_id,
streamName: myClaimForUri.name,
streamClaimId: myClaimForUri.claim_id,
});
nameHelpText = (

View file

@ -68,7 +68,7 @@ function AppRouter(props: Props) {
<Route path={`/$/${PAGES.BLOCKED}`} exact component={ListBlocked} />
{/* Below need to go at the end to make sure we don't match any of our pages first */}
<Route path="/:claimName" exact component={ShowPage} />
<Route path="/:claimName/:contentName" exact component={ShowPage} />
<Route path="/:claimName/:streamName" exact component={ShowPage} />
{/* Route not found. Mostly for people typing crazy urls into the url */}
<Route render={() => <Redirect to="/" />} />

View file

@ -35,7 +35,8 @@ export default function SubscribeButton(props: Props) {
} = props;
const buttonRef = useRef();
const isHovering = useHover(buttonRef);
const { claimName } = parseURI(uri);
const { channelName } = parseURI(uri);
const claimName = '@' + channelName;
const subscriptionHandler = isSubscribed ? doChannelUnsubscribe : doChannelSubscribe;
const subscriptionLabel = isSubscribed ? __('Following') : __('Follow');
const unfollowOverride = isSubscribed && isHovering && __('Unfollow');

View file

@ -45,10 +45,10 @@ class TransactionListItem extends React.PureComponent<Props> {
// Ensure the claim name exists and is valid
let uri;
let claimName = name;
let streamName = name;
try {
({ claimName } = parseURI(name));
uri = buildURI({ claimName: claimName, claimId });
({ streamName } = parseURI(name));
uri = buildURI({ streamName, streamClaimId: claimId });
} catch (e) {}
const dateFormat = {
@ -74,7 +74,7 @@ class TransactionListItem extends React.PureComponent<Props> {
</td>
<td>
{reward && <span>{reward.reward_title}</span>}
{name && claimId && <Button button="link" navigate={uri} label={claimName} />}
{name && claimId && <Button button="link" navigate={uri} label={streamName} />}
</td>
<td>

View file

@ -111,7 +111,7 @@ function ChannelPage(props: Props) {
/>
)}
<h1 className="channel__title">
{title || channelName}
{title || '@' + channelName}
{channelIsMine && !editing && (
<Button title={__('Edit')} onClick={() => setEditing(!editing)} icon={ICONS.EDIT} iconSize={49} />
)}

View file

@ -14,7 +14,6 @@ import {
SETTINGS,
Lbry,
Lbryapi,
buildURI,
makeSelectFileInfoForUri,
selectFileInfosByOutpoint,
makeSelectChannelForClaimUri,
@ -67,14 +66,15 @@ export function doUpdateLoadStatus(uri: string, outpoint: string) {
});
const channelUri = makeSelectChannelForClaimUri(uri, true)(state);
const { claimName: channelName } = parseURI(channelUri);
const { channelName } = parseURI(channelUri);
const claimName = '@' + channelName;
const unreadForChannel = makeSelectUnreadByChannel(channelUri)(state);
if (unreadForChannel && unreadForChannel.type === NOTIFICATION_TYPES.DOWNLOADING) {
const count = unreadForChannel.uris.length;
if (selectosNotificationsEnabled(state)) {
const notif = new window.Notification(channelName, {
const notif = new window.Notification(claimName, {
body: `Posted ${fileInfo.metadata.title}${
count > 1 && count < 10 ? ` and ${count - 1} other new items` : ''
}${count > 9 ? ' and 9+ other new items' : ''}`,
@ -154,10 +154,10 @@ export function doFetchClaimsByChannel(uri: string, page: number = 1, pageSize:
dispatch(
setSubscriptionLatest(
{
channelName: latest.channel_name,
uri: latest.signing_channel.canonical_url,
channelName: latest.signing_channel.name,
uri: latest.signing_channel.permanent_url,
},
buildURI({ streamName: latest.name, streamClaimId: latest.claim_id }, false)
latest.permanent_url
)
);
}
@ -201,7 +201,7 @@ export function doPlayUri(uri: string, skipCostCheck: boolean = false, saveFileO
const daemonSettings = selectDaemonSettings(state);
const costInfo = makeSelectCostInfoForUri(uri)(state);
const cost = Number(costInfo.cost);
const cost = (costInfo && Number(costInfo.cost)) || 0;
const saveFile = !uriIsStreamable ? true : daemonSettings.save_files || saveFileOverride || cost > 0;
const instantPurchaseEnabled = makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_ENABLED)(state);
const instantPurchaseMax = makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_MAX)(state);

View file

@ -6,7 +6,8 @@ import * as NOTIFICATION_TYPES from 'constants/subscriptions';
import { Lbryio, rewards, doClaimRewardType } from 'lbryinc';
import { selectSubscriptions, selectUnreadByChannel } from 'redux/selectors/subscriptions';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { Lbry, buildURI, parseURI, doResolveUris, doPurchaseUri } from 'lbry-redux';
import { Lbry, parseURI, doResolveUris } from 'lbry-redux';
import { doPlayUri } from 'redux/actions/content';
const CHECK_SUBSCRIPTIONS_INTERVAL = 15 * 60 * 1000;
const SUBSCRIPTION_DOWNLOAD_LIMIT = 1;
@ -47,8 +48,8 @@ export const doFetchMySubscriptions = () => (dispatch: Dispatch, getState: GetSt
const subscriptionsToReturn = reduxSubscriptions.slice();
reduxSubscriptions.forEach(sub => {
const { claimId } = parseURI(sub.uri);
reduxSubMap[claimId] = 1;
const { channelClaimId } = parseURI(sub.uri);
reduxSubMap[channelClaimId] = 1;
});
storedSubscriptions.forEach(sub => {
@ -218,9 +219,7 @@ export const doCheckSubscription = (subscriptionUri: string, shouldNotify?: bool
}
// Determine if the latest subscription currently saved is actually the latest subscription
const latestIndex = claimsInChannel.findIndex(
claim => `${claim.name}#${claim.claim_id}` === savedSubscription.latest
);
const latestIndex = claimsInChannel.findIndex(claim => claim.permanent_url === savedSubscription.latest);
// If latest is -1, it is a newly subscribed channel or there have been 10+ claims published since last viewed
const latestIndexToNotify = latestIndex === -1 ? 10 : latestIndex;
@ -232,7 +231,7 @@ export const doCheckSubscription = (subscriptionUri: string, shouldNotify?: bool
const newUnread = [];
claimsInChannel.slice(0, latestIndexToNotify).forEach(claim => {
const uri = buildURI({ contentName: claim.name, claimId: claim.claim_id }, true);
const uri = claim.permanent_url;
const shouldDownload =
shouldAutoDownload && Boolean(downloadCount < SUBSCRIPTION_DOWNLOAD_LIMIT && !claim.value.fee);
@ -243,7 +242,8 @@ export const doCheckSubscription = (subscriptionUri: string, shouldNotify?: bool
if (shouldDownload) {
downloadCount += 1;
dispatch(doPurchaseUri(uri, { cost: 0 }, true));
// this fails since something is not resolved/saved somewhere...
dispatch(doPlayUri(uri, true, true));
}
});
@ -262,10 +262,10 @@ export const doCheckSubscription = (subscriptionUri: string, shouldNotify?: bool
dispatch(
setSubscriptionLatest(
{
channelName: latest.channel_name,
uri: latest.signing_channel.canonical_url,
channelName: latest.signing_channel.name,
uri: latest.signing_channel.permanent_url,
},
buildURI({ streamName: latest.name, streamClaimId: latest.claim_id }, false)
latest.permanent_url
)
);
@ -300,11 +300,11 @@ export const doChannelSubscribe = (subscription: Subscription) => (dispatch: Dis
// if the user isn't sharing data, keep the subscriptions entirely in the app
if (isSharingData) {
const { claimId } = parseURI(subscription.uri);
const { channelClaimId } = parseURI(subscription.uri);
// They are sharing data, we can store their subscriptions in our internal database
Lbryio.call('subscription', 'new', {
channel_name: subscription.channelName,
claim_id: claimId,
claim_id: channelClaimId,
});
dispatch(doClaimRewardType(rewards.TYPE_SUBSCRIPTION, { failSilently: true }));
@ -325,9 +325,9 @@ export const doChannelUnsubscribe = (subscription: Subscription) => (dispatch: D
});
if (isSharingData) {
const { claimId } = parseURI(subscription.uri);
const { channelClaimId } = parseURI(subscription.uri);
Lbryio.call('subscription', 'delete', {
claim_id: claimId,
claim_id: channelClaimId,
});
}
};

View file

@ -1,10 +1,4 @@
import {
selectClaimsByUri,
selectIsFetchingClaimListMine,
selectMyClaims,
selectClaimsById,
buildURI,
} from 'lbry-redux';
import { selectClaimsByUri, selectIsFetchingClaimListMine, selectMyClaims, selectClaimsById } from 'lbry-redux';
import { createSelector } from 'reselect';
export const selectState = state => state.fileInfo || {};