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
|
||||
|
||||
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 = {
|
||||
uri?: ?string,
|
||||
primaryUri?: string,
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
// @flow
|
||||
import * as ACTIONS from 'constants/action_types';
|
||||
|
||||
const reducers = {};
|
||||
const defaultState = {
|
||||
const defaultState: ContentState = {
|
||||
primaryUri: null, // Top level content uri triggered from the file page
|
||||
playingUri: {},
|
||||
channelClaimCounts: {},
|
||||
positions: {},
|
||||
history: [],
|
||||
recommendationId: {}, // { "claimId": "recommendationId" }
|
||||
recommendationParentId: {}, // { "claimId": "referrerId" }
|
||||
recommendationUrls: {}, // { "claimId": [lbryUrls...] }
|
||||
recommendationClicks: {}, // { "claimId": [clicked indices...] }
|
||||
recommendationId: {},
|
||||
recommendationParentId: {},
|
||||
recommendationUrls: {},
|
||||
recommendationClicks: {},
|
||||
};
|
||||
|
||||
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];
|
||||
if (handler) return handler(state, action);
|
||||
return state;
|
||||
|
|
Loading…
Reference in a new issue