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;
|
return ids;
|
||||||
});
|
});
|
||||||
|
|
||||||
const makeSelectIndexForUrlInCollection = (url, id) => reselect.createSelector(makeSelectUrlsForCollectionId(id), makeSelectClaimForUri(url), (urls, claim) => {
|
const makeSelectIndexForUrlInCollection = (url, id) => reselect.createSelector(state => state.content.shuffleList, makeSelectUrlsForCollectionId(id), makeSelectClaimForUri(url), (shuffleState, urls, claim) => {
|
||||||
const index = urls && urls.findIndex(u => u === url);
|
const shuffleUrls = shuffleState && shuffleState.collectionId === id && shuffleState.newUrls;
|
||||||
|
const listUrls = shuffleUrls || urls;
|
||||||
|
|
||||||
|
const index = listUrls && listUrls.findIndex(u => u === url);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
return index;
|
return index;
|
||||||
} else if (claim) {
|
} 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;
|
if (index > -1) return index;
|
||||||
return claim;
|
return claim;
|
||||||
}
|
}
|
||||||
return null;
|
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) {
|
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
|
// We'll get the next playble url
|
||||||
const remainingUrls = urls.slice(index + 1);
|
let remainingUrls = listUrls.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'));
|
if (!remainingUrls.length && loopList) {
|
||||||
|
remainingUrls = listUrls.slice(0);
|
||||||
|
}
|
||||||
|
const nextUrl = remainingUrls && remainingUrls[0];
|
||||||
return nextUrl || null;
|
return nextUrl || null;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
@ -3762,7 +3790,13 @@ const makeSelectCountForCollectionId = id => reselect.createSelector(makeSelectC
|
||||||
if (collection.itemCount !== undefined) {
|
if (collection.itemCount !== undefined) {
|
||||||
return collection.itemCount;
|
return collection.itemCount;
|
||||||
}
|
}
|
||||||
return collection.items.length;
|
let itemCount = 0;
|
||||||
|
collection.items.map(item => {
|
||||||
|
if (item) {
|
||||||
|
itemCount += 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return itemCount;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
@ -8064,6 +8098,7 @@ exports.makeSelectPendingAmountByUri = makeSelectPendingAmountByUri;
|
||||||
exports.makeSelectPendingClaimForUri = makeSelectPendingClaimForUri;
|
exports.makeSelectPendingClaimForUri = makeSelectPendingClaimForUri;
|
||||||
exports.makeSelectPendingCollectionForId = makeSelectPendingCollectionForId;
|
exports.makeSelectPendingCollectionForId = makeSelectPendingCollectionForId;
|
||||||
exports.makeSelectPermanentUrlForUri = makeSelectPermanentUrlForUri;
|
exports.makeSelectPermanentUrlForUri = makeSelectPermanentUrlForUri;
|
||||||
|
exports.makeSelectPreviousUrlForCollectionAndUrl = makeSelectPreviousUrlForCollectionAndUrl;
|
||||||
exports.makeSelectPublishFormValue = makeSelectPublishFormValue;
|
exports.makeSelectPublishFormValue = makeSelectPublishFormValue;
|
||||||
exports.makeSelectPublishedCollectionForId = makeSelectPublishedCollectionForId;
|
exports.makeSelectPublishedCollectionForId = makeSelectPublishedCollectionForId;
|
||||||
exports.makeSelectReflectingClaimForUri = makeSelectReflectingClaimForUri;
|
exports.makeSelectReflectingClaimForUri = makeSelectReflectingClaimForUri;
|
||||||
|
|
|
@ -183,6 +183,7 @@ export {
|
||||||
makeSelectCountForCollectionId,
|
makeSelectCountForCollectionId,
|
||||||
makeSelectIsResolvingCollectionForId,
|
makeSelectIsResolvingCollectionForId,
|
||||||
makeSelectIndexForUrlInCollection,
|
makeSelectIndexForUrlInCollection,
|
||||||
|
makeSelectPreviousUrlForCollectionAndUrl,
|
||||||
makeSelectNextUrlForCollectionAndUrl,
|
makeSelectNextUrlForCollectionAndUrl,
|
||||||
makeSelectCollectionForIdHasClaimUrl,
|
makeSelectCollectionForIdHasClaimUrl,
|
||||||
} from 'redux/selectors/collections';
|
} from 'redux/selectors/collections';
|
||||||
|
|
|
@ -213,14 +213,18 @@ export const makeSelectClaimIdsForCollectionId = (id: string) =>
|
||||||
|
|
||||||
export const makeSelectIndexForUrlInCollection = (url: string, id: string) =>
|
export const makeSelectIndexForUrlInCollection = (url: string, id: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
|
state => state.content.shuffleList,
|
||||||
makeSelectUrlsForCollectionId(id),
|
makeSelectUrlsForCollectionId(id),
|
||||||
makeSelectClaimForUri(url),
|
makeSelectClaimForUri(url),
|
||||||
(urls, claim) => {
|
(shuffleState, urls, claim) => {
|
||||||
const index = urls && urls.findIndex(u => u === url);
|
const shuffleUrls = shuffleState && shuffleState.collectionId === id && shuffleState.newUrls;
|
||||||
|
const listUrls = shuffleUrls || urls;
|
||||||
|
|
||||||
|
const index = listUrls && listUrls.findIndex(u => u === url);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
return index;
|
return index;
|
||||||
} else if (claim) {
|
} 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;
|
if (index > -1) return index;
|
||||||
return claim;
|
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) =>
|
export const makeSelectNextUrlForCollectionAndUrl = (id: string, url: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
|
state => state.content.shuffleList,
|
||||||
|
state => state.content.loopList,
|
||||||
makeSelectIndexForUrlInCollection(url, id),
|
makeSelectIndexForUrlInCollection(url, id),
|
||||||
selectClaimsByUri,
|
|
||||||
makeSelectUrlsForCollectionId(id),
|
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) {
|
if (index > -1) {
|
||||||
|
const listUrls = shuffleUrls || urls;
|
||||||
// We'll get the next playble url
|
// We'll get the next playble url
|
||||||
const remainingUrls = urls.slice(index + 1);
|
let remainingUrls = listUrls.slice(index + 1);
|
||||||
const nextUrl = remainingUrls.find(
|
if (!remainingUrls.length && loopList) {
|
||||||
u =>
|
remainingUrls = listUrls.slice(0);
|
||||||
claims[u].value.stream_type &&
|
}
|
||||||
(claims[u].value.stream_type === 'video' || claims[u].value.stream_type === 'audio')
|
const nextUrl = remainingUrls && remainingUrls[0];
|
||||||
);
|
|
||||||
return nextUrl || null;
|
return nextUrl || null;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
@ -265,7 +298,13 @@ export const makeSelectCountForCollectionId = (id: string) =>
|
||||||
if (collection.itemCount !== undefined) {
|
if (collection.itemCount !== undefined) {
|
||||||
return collection.itemCount;
|
return collection.itemCount;
|
||||||
}
|
}
|
||||||
return collection.items.length;
|
let itemCount = 0;
|
||||||
|
collection.items.map(item => {
|
||||||
|
if (item) {
|
||||||
|
itemCount += 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return itemCount;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue