fix autoplay after playlist click and select next playable #415

Merged
jessopb merged 2 commits from fix-autoplay into master 2021-06-10 23:20:09 +02:00
3 changed files with 52 additions and 18 deletions

32
dist/bundle.es.js vendored
View file

@ -1051,6 +1051,11 @@ const FAVORITES_ID = 'favorites';
const FAVORITE_CHANNELS_ID = 'favoriteChannels';
const BUILTIN_LISTS = [WATCH_LATER_ID, FAVORITES_ID, FAVORITE_CHANNELS_ID];
const COL_KEY_EDITED = 'edited';
const COL_KEY_UNPUBLISHED = 'unpublished';
const COL_KEY_PENDING = 'pending';
const COL_KEY_SAVED = 'saved';
var collections = /*#__PURE__*/Object.freeze({
COLLECTION_ID: COLLECTION_ID,
COLLECTION_INDEX: COLLECTION_INDEX,
@ -1059,7 +1064,11 @@ var collections = /*#__PURE__*/Object.freeze({
WATCH_LATER_ID: WATCH_LATER_ID,
FAVORITES_ID: FAVORITES_ID,
FAVORITE_CHANNELS_ID: FAVORITE_CHANNELS_ID,
BUILTIN_LISTS: BUILTIN_LISTS
BUILTIN_LISTS: BUILTIN_LISTS,
COL_KEY_EDITED: COL_KEY_EDITED,
COL_KEY_UNPUBLISHED: COL_KEY_UNPUBLISHED,
COL_KEY_PENDING: COL_KEY_PENDING,
COL_KEY_SAVED: COL_KEY_SAVED
});
const DEFAULT_FOLLOWED_TAGS = ['art', 'automotive', 'blockchain', 'comedy', 'economics', 'education', 'gaming', 'music', 'news', 'science', 'sports', 'technology'];
@ -3694,22 +3703,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 => {

View file

@ -8,3 +8,8 @@ export const WATCH_LATER_ID = 'watchlater';
export const FAVORITES_ID = 'favorites';
export const FAVORITE_CHANNELS_ID = 'favoriteChannels';
export const BUILTIN_LISTS = [WATCH_LATER_ID, FAVORITES_ID, FAVORITE_CHANNELS_ID];
export const COL_KEY_EDITED = 'edited';
export const COL_KEY_UNPUBLISHED = 'unpublished';
export const COL_KEY_PENDING = 'pending';
export const COL_KEY_SAVED = 'saved';

View file

@ -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;
}
);