Recsys: determine the clicked index based on raw results instead of rendered order
## Ticket 1606 ## Issue The displayed order of the recs are often re-adjusted -- viewed content are pushed to the bottom to avoid auto-play-next from picking it up again. This was causing recsys to be confused, because the click order does not correspond the results. ## Change Refactored the selector we can grab the raw results and use that as the index reference.
This commit is contained in:
parent
2edf1ca564
commit
e4214b1c1b
3 changed files with 10 additions and 6 deletions
|
@ -1,7 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { RECSYS_ENDPOINT } from 'config';
|
import { RECSYS_ENDPOINT } from 'config';
|
||||||
import { selectUser } from 'redux/selectors/user';
|
import { selectUser } from 'redux/selectors/user';
|
||||||
import { makeSelectRecommendedRecsysIdForClaimId } from 'redux/selectors/search';
|
import { makeSelectRecommendedRecsysIdForClaimId, selectRecommendedContentRawForUri } from 'redux/selectors/search';
|
||||||
import { v4 as Uuidv4 } from 'uuid';
|
import { v4 as Uuidv4 } from 'uuid';
|
||||||
import { parseURI } from 'util/lbryURI';
|
import { parseURI } from 'util/lbryURI';
|
||||||
import { getAuthToken } from 'util/saved-passwords';
|
import { getAuthToken } from 'util/saved-passwords';
|
||||||
|
@ -82,13 +82,17 @@ const recsys: Recsys = {
|
||||||
* plus recommended content, recsysId, etc.
|
* plus recommended content, recsysId, etc.
|
||||||
* Called from recommendedContent component
|
* Called from recommendedContent component
|
||||||
*/
|
*/
|
||||||
onRecsLoaded: function (claimId, uris, uuid = '') {
|
onRecsLoaded: function (uri, claimId, uuid = '') {
|
||||||
if (window && window.store) {
|
if (window && window.store) {
|
||||||
const state = window.store.getState();
|
const state = window.store.getState();
|
||||||
|
const rawRecommendations = selectRecommendedContentRawForUri(state, uri);
|
||||||
|
const rawUris = rawRecommendations ? rawRecommendations.uris : null;
|
||||||
|
|
||||||
if (!recsys.entries[claimId]) {
|
if (!recsys.entries[claimId]) {
|
||||||
recsys.createRecsysEntry(claimId, null, uuid);
|
recsys.createRecsysEntry(claimId, null, uuid);
|
||||||
}
|
}
|
||||||
const claimIds = getClaimIdsFromUris(uris);
|
|
||||||
|
const claimIds = getClaimIdsFromUris(rawUris);
|
||||||
recsys.entries[claimId]['recsysId'] = makeSelectRecommendedRecsysIdForClaimId(claimId)(state) || recsysId;
|
recsys.entries[claimId]['recsysId'] = makeSelectRecommendedRecsysIdForClaimId(claimId)(state) || recsysId;
|
||||||
recsys.entries[claimId]['pageLoadedAt'] = Date.now();
|
recsys.entries[claimId]['pageLoadedAt'] = Date.now();
|
||||||
|
|
||||||
|
|
2
flow-typed/recsys.js
vendored
2
flow-typed/recsys.js
vendored
|
@ -4,7 +4,7 @@ declare type Recsys = {
|
||||||
|
|
||||||
saveEntries: () => void,
|
saveEntries: () => void,
|
||||||
onClickedRecommended: (parentClaimId: ClaimId, newClaimId: ClaimId) => void,
|
onClickedRecommended: (parentClaimId: ClaimId, newClaimId: ClaimId) => void,
|
||||||
onRecsLoaded: (claimId: ClaimId, uris: Array<string>, uuid: string) => void,
|
onRecsLoaded: (uri: ?string, claimId: ClaimId, uuid: string) => void,
|
||||||
createRecsysEntry: (claimId: ClaimId, parentUuid?: ?string, uuid?: string) => void,
|
createRecsysEntry: (claimId: ClaimId, parentUuid?: ?string, uuid?: string) => void,
|
||||||
sendRecsysEntry: (claimId: ClaimId, isTentative?: boolean) => ?Promise<?Response>,
|
sendRecsysEntry: (claimId: ClaimId, isTentative?: boolean) => ?Promise<?Response>,
|
||||||
sendEntries: (entries: ?{ [ClaimId]: RecsysEntry }, isResumedSend: boolean) => void,
|
sendEntries: (entries: ?{ [ClaimId]: RecsysEntry }, isResumedSend: boolean) => void,
|
||||||
|
|
|
@ -107,9 +107,9 @@ export default React.memo<Props>(function RecommendedContent(props: Props) {
|
||||||
nextRecommendedUri &&
|
nextRecommendedUri &&
|
||||||
viewMode === VIEW_ALL_RELATED
|
viewMode === VIEW_ALL_RELATED
|
||||||
) {
|
) {
|
||||||
onRecommendationsLoaded(claimId, recommendedContentUris, uuid);
|
onRecommendationsLoaded(uri, claimId, uuid);
|
||||||
}
|
}
|
||||||
}, [recommendedContentUris, onRecommendationsLoaded, claimId, nextRecommendedUri, viewMode, uuid]);
|
}, [uri, recommendedContentUris, onRecommendationsLoaded, claimId, nextRecommendedUri, viewMode, uuid]);
|
||||||
|
|
||||||
function handleRecommendationClicked(e, clickedClaim) {
|
function handleRecommendationClicked(e, clickedClaim) {
|
||||||
if (claim) {
|
if (claim) {
|
||||||
|
|
Loading…
Reference in a new issue