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;
|
||||
});
|
||||
|
||||
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);
|
||||
if (index > -1) {
|
||||
return index;
|
||||
} else if (claim) {
|
||||
const index = urls && urls.findIndex(u => u === claim.permanent_url);
|
||||
if (index > -1) return index;
|
||||
return claim;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
const makeSelectNextUrlForCollectionAndUrl = (id, url) => reselect.createSelector(makeSelectIndexForUrlInCollection(url, id), makeSelectUrlsForCollectionId(id), (index, urls) => {
|
||||
if (urls && index >= -1) {
|
||||
const url = urls[index + 1];
|
||||
if (url) {
|
||||
return url;
|
||||
}
|
||||
const makeSelectNextUrlForCollectionAndUrl = (id, url) => reselect.createSelector(makeSelectIndexForUrlInCollection(url, id), selectClaimsByUri, makeSelectUrlsForCollectionId(id), (index, claims, urls) => {
|
||||
if (index > -1) {
|
||||
// We'll get the next playble url
|
||||
const remainingUrls = urls.slice(index + 1);
|
||||
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 => {
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
// @flow
|
||||
import { createSelector } from 'reselect';
|
||||
import { selectMyCollectionIds } from 'redux/selectors/claims';
|
||||
import {
|
||||
selectMyCollectionIds,
|
||||
makeSelectClaimForUri,
|
||||
selectClaimsByUri,
|
||||
} from 'redux/selectors/claims';
|
||||
import { parseURI } from 'lbryURI';
|
||||
|
||||
const selectState = (state: { collections: CollectionState }) => state.collections;
|
||||
|
@ -187,10 +191,15 @@ export const makeSelectClaimIdsForCollectionId = (id: string) =>
|
|||
export const makeSelectIndexForUrlInCollection = (url: string, id: string) =>
|
||||
createSelector(
|
||||
makeSelectUrlsForCollectionId(id),
|
||||
urls => {
|
||||
makeSelectClaimForUri(url),
|
||||
(urls, claim) => {
|
||||
const index = urls && urls.findIndex(u => u === url);
|
||||
if (index > -1) {
|
||||
return index;
|
||||
} else if (claim) {
|
||||
const index = urls && urls.findIndex(u => u === claim.permanent_url);
|
||||
if (index > -1) return index;
|
||||
return claim;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -199,15 +208,21 @@ export const makeSelectIndexForUrlInCollection = (url: string, id: string) =>
|
|||
export const makeSelectNextUrlForCollectionAndUrl = (id: string, url: string) =>
|
||||
createSelector(
|
||||
makeSelectIndexForUrlInCollection(url, id),
|
||||
selectClaimsByUri,
|
||||
makeSelectUrlsForCollectionId(id),
|
||||
(index, urls) => {
|
||||
if (urls && index >= -1) {
|
||||
const url = urls[index + 1];
|
||||
if (url) {
|
||||
return url;
|
||||
}
|
||||
(index, claims, urls) => {
|
||||
if (index > -1) {
|
||||
// We'll get the next playble url
|
||||
const remainingUrls = urls.slice(index + 1);
|
||||
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