Merge pull request #426 from saltrafael/playback-controls
Playback and List control changes
This commit is contained in:
commit
12a2ffc708
3 changed files with 94 additions and 19 deletions
49
dist/bundle.es.js
vendored
49
dist/bundle.es.js
vendored
|
@ -3730,23 +3730,51 @@ const makeSelectClaimIdsForCollectionId = id => reselect.createSelector(makeSele
|
|||
return ids;
|
||||
});
|
||||
|
||||
const makeSelectIndexForUrlInCollection = (url, id) => reselect.createSelector(makeSelectUrlsForCollectionId(id), makeSelectClaimForUri(url), (urls, claim) => {
|
||||
const index = urls && urls.findIndex(u => u === url);
|
||||
const makeSelectIndexForUrlInCollection = (url, id) => reselect.createSelector(state => state.content.shuffleList, makeSelectUrlsForCollectionId(id), makeSelectClaimForUri(url), (shuffleState, urls, claim) => {
|
||||
const shuffleUrls = shuffleState && shuffleState.collectionId === id && shuffleState.newUrls;
|
||||
const listUrls = shuffleUrls || urls;
|
||||
|
||||
const index = listUrls && listUrls.findIndex(u => u === url);
|
||||
if (index > -1) {
|
||||
return index;
|
||||
} else if (claim) {
|
||||
const index = urls && urls.findIndex(u => u === claim.permanent_url);
|
||||
const index = listUrls && listUrls.findIndex(u => u === claim.permanent_url);
|
||||
if (index > -1) return index;
|
||||
return claim;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
const makeSelectNextUrlForCollectionAndUrl = (id, url) => reselect.createSelector(makeSelectIndexForUrlInCollection(url, id), selectClaimsByUri, makeSelectUrlsForCollectionId(id), (index, claims, urls) => {
|
||||
const makeSelectPreviousUrlForCollectionAndUrl = (id, url) => reselect.createSelector(state => state.content.shuffleList, state => state.content.loopList, makeSelectIndexForUrlInCollection(url, id), makeSelectUrlsForCollectionId(id), (shuffleState, loopState, index, urls) => {
|
||||
const loopList = loopState && loopState.collectionId === id && loopState.loop;
|
||||
const shuffleUrls = shuffleState && shuffleState.collectionId === id && shuffleState.newUrls;
|
||||
|
||||
if (index > -1) {
|
||||
const listUrls = shuffleUrls || urls;
|
||||
let nextUrl;
|
||||
if (index === 0 && loopList) {
|
||||
nextUrl = listUrls[listUrls.length - 1];
|
||||
} else {
|
||||
nextUrl = listUrls[index - 1];
|
||||
}
|
||||
return nextUrl || null;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
const makeSelectNextUrlForCollectionAndUrl = (id, url) => reselect.createSelector(state => state.content.shuffleList, state => state.content.loopList, makeSelectIndexForUrlInCollection(url, id), makeSelectUrlsForCollectionId(id), (shuffleState, loopState, index, urls) => {
|
||||
const loopList = loopState && loopState.collectionId === id && loopState.loop;
|
||||
const shuffleUrls = shuffleState && shuffleState.collectionId === id && shuffleState.newUrls;
|
||||
|
||||
if (index > -1) {
|
||||
const listUrls = shuffleUrls || urls;
|
||||
// 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'));
|
||||
let remainingUrls = listUrls.slice(index + 1);
|
||||
if (!remainingUrls.length && loopList) {
|
||||
remainingUrls = listUrls.slice(0);
|
||||
}
|
||||
const nextUrl = remainingUrls && remainingUrls[0];
|
||||
return nextUrl || null;
|
||||
} else {
|
||||
return null;
|
||||
|
@ -3762,7 +3790,13 @@ const makeSelectCountForCollectionId = id => reselect.createSelector(makeSelectC
|
|||
if (collection.itemCount !== undefined) {
|
||||
return collection.itemCount;
|
||||
}
|
||||
return collection.items.length;
|
||||
let itemCount = 0;
|
||||
collection.items.map(item => {
|
||||
if (item) {
|
||||
itemCount += 1;
|
||||
}
|
||||
});
|
||||
return itemCount;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
@ -8064,6 +8098,7 @@ exports.makeSelectPendingAmountByUri = makeSelectPendingAmountByUri;
|
|||
exports.makeSelectPendingClaimForUri = makeSelectPendingClaimForUri;
|
||||
exports.makeSelectPendingCollectionForId = makeSelectPendingCollectionForId;
|
||||
exports.makeSelectPermanentUrlForUri = makeSelectPermanentUrlForUri;
|
||||
exports.makeSelectPreviousUrlForCollectionAndUrl = makeSelectPreviousUrlForCollectionAndUrl;
|
||||
exports.makeSelectPublishFormValue = makeSelectPublishFormValue;
|
||||
exports.makeSelectPublishedCollectionForId = makeSelectPublishedCollectionForId;
|
||||
exports.makeSelectReflectingClaimForUri = makeSelectReflectingClaimForUri;
|
||||
|
|
|
@ -183,6 +183,7 @@ export {
|
|||
makeSelectCountForCollectionId,
|
||||
makeSelectIsResolvingCollectionForId,
|
||||
makeSelectIndexForUrlInCollection,
|
||||
makeSelectPreviousUrlForCollectionAndUrl,
|
||||
makeSelectNextUrlForCollectionAndUrl,
|
||||
makeSelectCollectionForIdHasClaimUrl,
|
||||
} from 'redux/selectors/collections';
|
||||
|
|
|
@ -213,14 +213,18 @@ export const makeSelectClaimIdsForCollectionId = (id: string) =>
|
|||
|
||||
export const makeSelectIndexForUrlInCollection = (url: string, id: string) =>
|
||||
createSelector(
|
||||
state => state.content.shuffleList,
|
||||
makeSelectUrlsForCollectionId(id),
|
||||
makeSelectClaimForUri(url),
|
||||
(urls, claim) => {
|
||||
const index = urls && urls.findIndex(u => u === url);
|
||||
(shuffleState, urls, claim) => {
|
||||
const shuffleUrls = shuffleState && shuffleState.collectionId === id && shuffleState.newUrls;
|
||||
const listUrls = shuffleUrls || urls;
|
||||
|
||||
const index = listUrls && listUrls.findIndex(u => u === url);
|
||||
if (index > -1) {
|
||||
return index;
|
||||
} else if (claim) {
|
||||
const index = urls && urls.findIndex(u => u === claim.permanent_url);
|
||||
const index = listUrls && listUrls.findIndex(u => u === claim.permanent_url);
|
||||
if (index > -1) return index;
|
||||
return claim;
|
||||
}
|
||||
|
@ -228,20 +232,49 @@ export const makeSelectIndexForUrlInCollection = (url: string, id: string) =>
|
|||
}
|
||||
);
|
||||
|
||||
export const makeSelectPreviousUrlForCollectionAndUrl = (id: string, url: string) =>
|
||||
createSelector(
|
||||
state => state.content.shuffleList,
|
||||
state => state.content.loopList,
|
||||
makeSelectIndexForUrlInCollection(url, id),
|
||||
makeSelectUrlsForCollectionId(id),
|
||||
(shuffleState, loopState, index, urls) => {
|
||||
const loopList = loopState && loopState.collectionId === id && loopState.loop;
|
||||
const shuffleUrls = shuffleState && shuffleState.collectionId === id && shuffleState.newUrls;
|
||||
|
||||
if (index > -1) {
|
||||
const listUrls = shuffleUrls || urls;
|
||||
let nextUrl;
|
||||
if (index === 0 && loopList) {
|
||||
nextUrl = listUrls[listUrls.length - 1];
|
||||
} else {
|
||||
nextUrl = listUrls[index - 1];
|
||||
}
|
||||
return nextUrl || null;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
export const makeSelectNextUrlForCollectionAndUrl = (id: string, url: string) =>
|
||||
createSelector(
|
||||
state => state.content.shuffleList,
|
||||
state => state.content.loopList,
|
||||
makeSelectIndexForUrlInCollection(url, id),
|
||||
selectClaimsByUri,
|
||||
makeSelectUrlsForCollectionId(id),
|
||||
(index, claims, urls) => {
|
||||
(shuffleState, loopState, index, urls) => {
|
||||
const loopList = loopState && loopState.collectionId === id && loopState.loop;
|
||||
const shuffleUrls = shuffleState && shuffleState.collectionId === id && shuffleState.newUrls;
|
||||
|
||||
if (index > -1) {
|
||||
const listUrls = shuffleUrls || urls;
|
||||
// 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')
|
||||
);
|
||||
let remainingUrls = listUrls.slice(index + 1);
|
||||
if (!remainingUrls.length && loopList) {
|
||||
remainingUrls = listUrls.slice(0);
|
||||
}
|
||||
const nextUrl = remainingUrls && remainingUrls[0];
|
||||
return nextUrl || null;
|
||||
} else {
|
||||
return null;
|
||||
|
@ -265,7 +298,13 @@ export const makeSelectCountForCollectionId = (id: string) =>
|
|||
if (collection.itemCount !== undefined) {
|
||||
return collection.itemCount;
|
||||
}
|
||||
return collection.items.length;
|
||||
let itemCount = 0;
|
||||
collection.items.map(item => {
|
||||
if (item) {
|
||||
itemCount += 1;
|
||||
}
|
||||
});
|
||||
return itemCount;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue