Add flow to Content slice
This commit is contained in:
parent
143a3c83e7
commit
fb998208e2
2 changed files with 23 additions and 6 deletions
16
flow-typed/content.js
vendored
16
flow-typed/content.js
vendored
|
@ -1,5 +1,21 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
|
declare type ContentState = {
|
||||||
|
primaryUri: ?string,
|
||||||
|
playingUri: {}, // Someone please fill in.
|
||||||
|
positions: { [string]: { [string]: number } }, // claimId: { outpoint: position }
|
||||||
|
history: Array<WatchHistory>,
|
||||||
|
recommendationId: { [string]: string }, // claimId: recommendationId
|
||||||
|
recommendationParentId: { [string]: string}, // claimId: referrerId
|
||||||
|
recommendationUrls: { [string]: Array<string>}, // claimId: [lbryUrls...]
|
||||||
|
recommendationClicks: { [string]: Array<number>}, // "claimId": [clicked indices...]
|
||||||
|
};
|
||||||
|
|
||||||
|
declare type WatchHistory = {
|
||||||
|
uri: string,
|
||||||
|
lastViewed: number,
|
||||||
|
};
|
||||||
|
|
||||||
declare type PlayingUri = {
|
declare type PlayingUri = {
|
||||||
uri?: ?string,
|
uri?: ?string,
|
||||||
primaryUri?: string,
|
primaryUri?: string,
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
|
// @flow
|
||||||
import * as ACTIONS from 'constants/action_types';
|
import * as ACTIONS from 'constants/action_types';
|
||||||
|
|
||||||
const reducers = {};
|
const reducers = {};
|
||||||
const defaultState = {
|
const defaultState: ContentState = {
|
||||||
primaryUri: null, // Top level content uri triggered from the file page
|
primaryUri: null, // Top level content uri triggered from the file page
|
||||||
playingUri: {},
|
playingUri: {},
|
||||||
channelClaimCounts: {},
|
channelClaimCounts: {},
|
||||||
positions: {},
|
positions: {},
|
||||||
history: [],
|
history: [],
|
||||||
recommendationId: {}, // { "claimId": "recommendationId" }
|
recommendationId: {},
|
||||||
recommendationParentId: {}, // { "claimId": "referrerId" }
|
recommendationParentId: {},
|
||||||
recommendationUrls: {}, // { "claimId": [lbryUrls...] }
|
recommendationUrls: {},
|
||||||
recommendationClicks: {}, // { "claimId": [clicked indices...] }
|
recommendationClicks: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
reducers[ACTIONS.SET_PRIMARY_URI] = (state, action) =>
|
reducers[ACTIONS.SET_PRIMARY_URI] = (state, action) =>
|
||||||
|
@ -123,7 +124,7 @@ reducers[ACTIONS.CLEAR_CONTENT_HISTORY_ALL] = (state) => ({ ...state, history: [
|
||||||
// };
|
// };
|
||||||
// };
|
// };
|
||||||
|
|
||||||
export default function reducer(state = defaultState, action) {
|
export default function reducer(state: ContentState = defaultState, action: any) {
|
||||||
const handler = reducers[action.type];
|
const handler = reducers[action.type];
|
||||||
if (handler) return handler(state, action);
|
if (handler) return handler(state, action);
|
||||||
return state;
|
return state;
|
||||||
|
|
Loading…
Reference in a new issue