2021-11-15 15:08:23 +01:00
|
|
|
// @flow
|
|
|
|
import { selectClaimIdForUri } from 'redux/selectors/claims';
|
2021-10-17 10:36:14 +02:00
|
|
|
|
2022-03-17 05:55:40 +01:00
|
|
|
type State = { claims: any, stats: any, user: UserState };
|
2021-10-17 10:36:14 +02:00
|
|
|
|
2021-11-15 15:08:23 +01:00
|
|
|
const selectState = (state: State) => state.stats || {};
|
|
|
|
export const selectViewCount = (state: State) => selectState(state).viewCountById;
|
|
|
|
export const selectSubCount = (state: State) => selectState(state).subCountById;
|
2021-10-17 10:36:14 +02:00
|
|
|
|
2021-11-15 15:08:23 +01:00
|
|
|
export const selectViewCountForUri = (state: State, uri: string) => {
|
|
|
|
const claimId = selectClaimIdForUri(state, uri);
|
|
|
|
const viewCountById = selectViewCount(state);
|
|
|
|
return claimId ? viewCountById[claimId] || 0 : 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const selectSubCountForUri = (state: State, uri: string) => {
|
|
|
|
const claimId = selectClaimIdForUri(state, uri);
|
|
|
|
const subCountById = selectSubCount(state);
|
|
|
|
return claimId ? subCountById[claimId] || 0 : 0;
|
|
|
|
};
|