Fix flow for User/UserState

This commit is contained in:
infinite-persistence 2022-03-17 12:55:40 +08:00
parent 637f191a24
commit ec2bf26817
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
9 changed files with 44 additions and 10 deletions

View file

@ -1,7 +1,7 @@
// @flow
import { selectClaimIdForUri } from 'redux/selectors/claims';
type State = { claims: any, stats: any, user: User };
type State = { claims: any, stats: any, user: UserState };
const selectState = (state: State) => state.stats || {};
export const selectViewCount = (state: State) => selectState(state).viewCountById;

34
flow-typed/user.js vendored
View file

@ -32,7 +32,39 @@ declare type User = {
odysee_live_enabled: boolean,
odysee_live_disabled: boolean,
global_mod: boolean,
odyseeMembershipsPerClaimIds: ?{},
publish_id: ?number,
is_odysee_user: boolean,
location: ?string,
};
declare type UserState ={
authenticationIsPending: boolean,
userIsPending: boolean,
emailNewIsPending: boolean,
emailNewErrorMessage: string,
emailToVerify: string,
emailAlreadyExists: boolean,
emailDoesNotExist: boolean,
resendingVerificationEmail: boolean,
passwordResetPending: boolean,
passwordResetSuccess: boolean,
passwordResetError: ?string,
passwordSetPending: boolean,
passwordSetSuccess: boolean,
passwordSetError: ?string,
inviteNewErrorMessage: string,
inviteNewIsPending: boolean,
inviteStatusIsPending: boolean,
invitesRemaining: ?number,
invitees: ?Array<string>,
referralLink: ?string,
referralCode: ?string,
user: ?User,
youtubeChannelImportPending: boolean,
youtubeChannelImportErrorMessage: string,
referrerSetIsPending: boolean,
referrerSetError: string,
odyseeMembershipsPerClaimIds: ?{ [string]: string },
};
declare type LocaleInfo = {

View file

@ -23,7 +23,7 @@ import {
import { isStreamPlaceholderClaim } from 'util/claim';
type Dispatch = (action: any) => any;
type GetState = () => { claims: any, file: FileState, content: any, user: User };
type GetState = () => { claims: any, file: FileState, content: any, user: UserState };
export function doOpenFileInFolder(path: string) {
return () => {
shell.showItemInFolder(path);

View file

@ -64,7 +64,7 @@ const recsysFyp = {
// ****************************************************************************
type Dispatch = (action: any) => any;
type GetState = () => { claims: any, search: SearchState, user: User };
type GetState = () => { claims: any, search: SearchState, user: UserState };
type SearchOptions = {
size?: number,

View file

@ -1,8 +1,9 @@
// @flow
import * as ACTIONS from 'constants/action_types';
const reducers = {};
const defaultState = {
const defaultState: UserState = {
authenticationIsPending: false,
userIsPending: false,
emailNewIsPending: false,
@ -29,6 +30,7 @@ const defaultState = {
youtubeChannelImportErrorMessage: '',
referrerSetIsPending: false,
referrerSetError: '',
odyseeMembershipsPerClaimIds: undefined,
};
reducers[ACTIONS.AUTHENTICATION_STARTED] = (state) =>
@ -385,7 +387,7 @@ reducers[ACTIONS.ADD_CLAIMIDS_MEMBERSHIP_DATA] = (state, action) => {
});
};
export default function userReducer(state = defaultState, action) {
export default function userReducer(state: UserState = defaultState, action: any) {
const handler = reducers[action.type];
if (handler) return handler(state, action);
return state;

View file

@ -17,7 +17,7 @@ import * as CLAIM from 'constants/claim';
import * as SETTINGS from 'constants/settings';
import { INTERNAL_TAGS } from 'constants/tags';
type State = { claims: any, user: User };
type State = { claims: any, user: UserState };
const selectState = (state: State) => state.claims || {};

View file

@ -16,7 +16,7 @@ import { isClaimNsfw, getChannelFromClaim } from 'util/claim';
import { selectSubscriptionUris } from 'redux/selectors/subscriptions';
import { getCommentsListTitle } from 'util/comments';
type State = { claims: any, comments: CommentsState, user: User };
type State = { claims: any, comments: CommentsState, user: UserState };
const selectState = (state) => state.comments || {};

View file

@ -18,7 +18,7 @@ import { FORCE_CONTENT_TYPE_PLAYER, FORCE_CONTENT_TYPE_COMIC } from 'constants/c
const RECENT_HISTORY_AMOUNT = 10;
const HISTORY_ITEMS_PER_PAGE = 50;
type State = { claims: any, content: any, user: User };
type State = { claims: any, content: any, user: UserState };
export const selectState = (state: State) => state.content || {};

View file

@ -20,7 +20,7 @@ import { selectHistory } from 'redux/selectors/content';
import { selectAllCostInfoByUri } from 'lbryinc';
import { SIMPLE_SITE } from 'config';
type State = { claims: any, search: SearchState, user: User };
type State = { claims: any, search: SearchState, user: UserState };
export const selectState = (state: State): SearchState => state.search;