fix autoplay after playlist click and select next playable
This commit is contained in:
parent
609f13991f
commit
4dfc4689c6
2 changed files with 37 additions and 17 deletions
21
dist/bundle.es.js
vendored
21
dist/bundle.es.js
vendored
|
@ -3694,22 +3694,27 @@ const makeSelectClaimIdsForCollectionId = id => reselect.createSelector(makeSele
|
||||||
return ids;
|
return ids;
|
||||||
});
|
});
|
||||||
|
|
||||||
const makeSelectIndexForUrlInCollection = (url, id) => reselect.createSelector(makeSelectUrlsForCollectionId(id), urls => {
|
const makeSelectIndexForUrlInCollection = (url, id) => reselect.createSelector(makeSelectUrlsForCollectionId(id), makeSelectClaimForUri(url), (urls, claim) => {
|
||||||
const index = urls && urls.findIndex(u => u === url);
|
const index = urls && urls.findIndex(u => u === url);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
return index;
|
return index;
|
||||||
|
} else if (claim) {
|
||||||
|
const index = urls && urls.findIndex(u => u === claim.permanent_url);
|
||||||
|
if (index > -1) return index;
|
||||||
|
return claim;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
const makeSelectNextUrlForCollectionAndUrl = (id, url) => reselect.createSelector(makeSelectIndexForUrlInCollection(url, id), makeSelectUrlsForCollectionId(id), (index, urls) => {
|
const makeSelectNextUrlForCollectionAndUrl = (id, url) => reselect.createSelector(makeSelectIndexForUrlInCollection(url, id), selectClaimsByUri, makeSelectUrlsForCollectionId(id), (index, claims, urls) => {
|
||||||
if (urls && index >= -1) {
|
if (index > -1) {
|
||||||
const url = urls[index + 1];
|
// We'll get the next playble url
|
||||||
if (url) {
|
const remainingUrls = urls.slice(index + 1);
|
||||||
return url;
|
const nextUrl = remainingUrls.find(u => claims[u].value.stream_type && (claims[u].value.stream_type === 'video' || claims[u].value.stream_type === 'audio'));
|
||||||
}
|
return nextUrl || null;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const makeSelectNameForCollectionId = id => reselect.createSelector(makeSelectCollectionForId(id), collection => {
|
const makeSelectNameForCollectionId = id => reselect.createSelector(makeSelectCollectionForId(id), collection => {
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import { selectMyCollectionIds } from 'redux/selectors/claims';
|
import {
|
||||||
|
selectMyCollectionIds,
|
||||||
|
makeSelectClaimForUri,
|
||||||
|
selectClaimsByUri,
|
||||||
|
} from 'redux/selectors/claims';
|
||||||
import { parseURI } from 'lbryURI';
|
import { parseURI } from 'lbryURI';
|
||||||
|
|
||||||
const selectState = (state: { collections: CollectionState }) => state.collections;
|
const selectState = (state: { collections: CollectionState }) => state.collections;
|
||||||
|
@ -187,10 +191,15 @@ export const makeSelectClaimIdsForCollectionId = (id: string) =>
|
||||||
export const makeSelectIndexForUrlInCollection = (url: string, id: string) =>
|
export const makeSelectIndexForUrlInCollection = (url: string, id: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
makeSelectUrlsForCollectionId(id),
|
makeSelectUrlsForCollectionId(id),
|
||||||
urls => {
|
makeSelectClaimForUri(url),
|
||||||
|
(urls, claim) => {
|
||||||
const index = urls && urls.findIndex(u => u === url);
|
const index = urls && urls.findIndex(u => u === url);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
return index;
|
return index;
|
||||||
|
} else if (claim) {
|
||||||
|
const index = urls && urls.findIndex(u => u === claim.permanent_url);
|
||||||
|
if (index > -1) return index;
|
||||||
|
return claim;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -199,15 +208,21 @@ export const makeSelectIndexForUrlInCollection = (url: string, id: string) =>
|
||||||
export const makeSelectNextUrlForCollectionAndUrl = (id: string, url: string) =>
|
export const makeSelectNextUrlForCollectionAndUrl = (id: string, url: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
makeSelectIndexForUrlInCollection(url, id),
|
makeSelectIndexForUrlInCollection(url, id),
|
||||||
|
selectClaimsByUri,
|
||||||
makeSelectUrlsForCollectionId(id),
|
makeSelectUrlsForCollectionId(id),
|
||||||
(index, urls) => {
|
(index, claims, urls) => {
|
||||||
if (urls && index >= -1) {
|
if (index > -1) {
|
||||||
const url = urls[index + 1];
|
// We'll get the next playble url
|
||||||
if (url) {
|
const remainingUrls = urls.slice(index + 1);
|
||||||
return url;
|
const nextUrl = remainingUrls.find(
|
||||||
}
|
u =>
|
||||||
|
claims[u].value.stream_type &&
|
||||||
|
(claims[u].value.stream_type === 'video' || claims[u].value.stream_type === 'audio')
|
||||||
|
);
|
||||||
|
return nextUrl || null;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue