Recsys: pass isFollowing
and incognito
Additional data requested. isFollowing - is the user following the creator incognito - authenticated or not
This commit is contained in:
parent
e6f432c69d
commit
72b0977817
3 changed files with 24 additions and 0 deletions
|
@ -9,6 +9,7 @@ import { X_LBRY_AUTH_TOKEN } from 'constants/token';
|
|||
import { makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||
import { selectPlayingUri, selectPrimaryUri } from 'redux/selectors/content';
|
||||
import { selectClientSetting, selectDaemonSettings } from 'redux/selectors/settings';
|
||||
import { selectIsSubscribedForClaimId } from 'redux/selectors/subscriptions';
|
||||
import { history } from 'ui/store';
|
||||
|
||||
const recsysEndpoint = RECSYS_ENDPOINT;
|
||||
|
@ -109,6 +110,8 @@ const recsys = {
|
|||
recClickedVideoIdx: [],
|
||||
pageLoadedAt: Date.now(),
|
||||
events: [],
|
||||
incognito: !(user && user.has_verified_email),
|
||||
isFollowing: selectIsSubscribedForClaimId(state, claimId),
|
||||
};
|
||||
|
||||
if (parentUuid) {
|
||||
|
|
|
@ -93,8 +93,11 @@ export const selectClaimIdForUri = (state: State, uri: string) => selectClaimIds
|
|||
|
||||
export const selectReflectingById = (state: State) => selectState(state).reflectingById;
|
||||
|
||||
// OBSOLETE: use selectClaimForClaimId instead
|
||||
export const makeSelectClaimForClaimId = (claimId: string) => createSelector(selectClaimsById, (byId) => byId[claimId]);
|
||||
|
||||
export const selectClaimForClaimId = (state: State, claimId: string) => selectClaimsById(state)[claimId];
|
||||
|
||||
export const selectClaimForUri = createCachedSelector(
|
||||
selectClaimIdsByUri,
|
||||
selectClaimsById,
|
||||
|
|
|
@ -7,6 +7,7 @@ import {
|
|||
makeSelectChannelForClaimUri,
|
||||
makeSelectClaimForUri,
|
||||
selectClaimForUri,
|
||||
selectClaimForClaimId,
|
||||
} from 'redux/selectors/claims';
|
||||
import { swapKeyAndValue } from 'util/swap-json';
|
||||
import { getChannelFromClaim, isChannelClaim } from 'util/claim';
|
||||
|
@ -135,6 +136,23 @@ export const selectIsSubscribedForUri = createCachedSelector(
|
|||
}
|
||||
)((state, uri) => String(uri));
|
||||
|
||||
/**
|
||||
* Unlike its 'selectIsSubscribedForUri' counterpart, this does not try to use
|
||||
* parseURI as a fallback (since it only has claimId and not the uri).
|
||||
*/
|
||||
export const selectIsSubscribedForClaimId = createCachedSelector(
|
||||
selectClaimForClaimId, // (state, claimId)
|
||||
selectSubscriptions, // (state)
|
||||
(claim, subscriptions) => {
|
||||
const channelClaim = getChannelFromClaim(claim);
|
||||
if (channelClaim) {
|
||||
const permanentUrl = channelClaim.permanent_url;
|
||||
return subscriptions.some((sub) => isURIEqual(sub.uri, permanentUrl));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
)((state, claimId) => String(claimId));
|
||||
|
||||
export const makeSelectNotificationsDisabled = (uri) =>
|
||||
createSelector(
|
||||
selectFollowing,
|
||||
|
|
Loading…
Reference in a new issue