diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 77ae325..5214101 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -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 => { diff --git a/src/constants/collections.js b/src/constants/collections.js index 6c002e6..0f2d111 100644 --- a/src/constants/collections.js +++ b/src/constants/collections.js @@ -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'; diff --git a/src/redux/selectors/collections.js b/src/redux/selectors/collections.js index 92e2cf7..3218e2f 100644 --- a/src/redux/selectors/collections.js +++ b/src/redux/selectors/collections.js @@ -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; } );