Add flow to Content slice

This commit is contained in:
infinite-persistence 2022-04-01 16:02:03 +08:00 committed by Thomas Zarebczan
parent 143a3c83e7
commit fb998208e2
2 changed files with 23 additions and 6 deletions

16
flow-typed/content.js vendored
View file

@ -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,

View file

@ -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;