fix: flow errors

This commit is contained in:
Sean Yesmunt 2019-01-19 13:54:06 -05:00
parent b1633481e7
commit 88a731ffea
14 changed files with 71 additions and 58 deletions

View file

@ -50,6 +50,7 @@
"no-prototype-builtins": 0, "no-prototype-builtins": 0,
"flowtype/space-after-type-colon": [2, "always", { "allowLineBreak": true }], "flowtype/space-after-type-colon": [2, "always", { "allowLineBreak": true }],
"no-restricted-syntax": 0, "no-restricted-syntax": 0,
"no-empty": 0 "no-empty": 0,
"react/prefer-stateless-function": 0
} }
} }

View file

@ -1,4 +1,5 @@
[ignore] [ignore]
node_modules/
[include] [include]

View file

@ -13,13 +13,13 @@ type Analytics = {
track: (string, ?Object) => void, track: (string, ?Object) => void,
setUser: Object => void, setUser: Object => void,
toggle: (boolean, ?boolean) => void, toggle: (boolean, ?boolean) => void,
apiLogView: (string, string, string) => void, apiLogView: (string, string, string, ?number, ?() => void) => void,
}; };
let analyticsEnabled: boolean = false; let analyticsEnabled: boolean = false;
const analytics: Analytics = { const analytics: Analytics = {
track: (name: string, payload: ?Object): void => { track: (name, payload) => {
if (analyticsEnabled) { if (analyticsEnabled) {
if (payload) { if (payload) {
mixpanel.track(name, payload); mixpanel.track(name, payload);
@ -28,7 +28,7 @@ const analytics: Analytics = {
} }
} }
}, },
setUser: (user: Object): void => { setUser: user => {
if (user.id) { if (user.id) {
mixpanel.identify(user.id); mixpanel.identify(user.id);
} }
@ -44,13 +44,7 @@ const analytics: Analytics = {
} }
analyticsEnabled = enabled; analyticsEnabled = enabled;
}, },
apiLogView: ( apiLogView: (uri, outpoint, claimId, timeToStart, onSuccessCb) => {
uri: string,
outpoint: string,
claimId: string,
timeToStart?: number,
onSuccessCb: ?() => void
): void => {
if (analyticsEnabled) { if (analyticsEnabled) {
const params: { const params: {
uri: string, uri: string,

View file

@ -29,8 +29,12 @@ type Props = {
token: string, token: string,
}; };
class CardVerify extends React.Component { type State = {
constructor(props) { open: boolean,
};
class CardVerify extends React.Component<Props, State> {
constructor(props: Props) {
super(props); super(props);
this.state = { this.state = {
open: false, open: false,

View file

@ -16,15 +16,16 @@ type Props = {
fileType: string, fileType: string,
contentType: string, contentType: string,
downloadPath: string, downloadPath: string,
url: ?string,
}, },
currentTheme: string, currentTheme: string,
}; };
class FileRender extends React.PureComponent<Props> { class FileRender extends React.PureComponent<Props> {
constructor(props) { constructor(props: Props) {
super(props); super(props);
this.escapeListener = this.escapeListener.bind(this); (this: any).escapeListener = this.escapeListener.bind(this);
} }
componentDidMount() { componentDidMount() {
@ -35,7 +36,8 @@ class FileRender extends React.PureComponent<Props> {
window.removeEventListener('keydown', this.escapeListener, true); window.removeEventListener('keydown', this.escapeListener, true);
} }
processSandboxRef(element) { // This should use React.createRef()
processSandboxRef(element: any) {
if (!element) { if (!element) {
return; return;
} }
@ -47,7 +49,7 @@ class FileRender extends React.PureComponent<Props> {
console.log('permissionrequest', e); console.log('permissionrequest', e);
}); });
element.addEventListener('console-message', e => { element.addEventListener('console-message', (e: { message: string }) => {
if (/^\$LBRY_IPC:/.test(e.message)) { if (/^\$LBRY_IPC:/.test(e.message)) {
// Process command // Process command
let message = {}; let message = {};
@ -71,7 +73,7 @@ class FileRender extends React.PureComponent<Props> {
}); });
} }
escapeListener(e) { escapeListener(e: SyntheticKeyboardEvent<*>) {
if (e.keyCode === 27) { if (e.keyCode === 27) {
e.preventDefault(); e.preventDefault();
@ -97,7 +99,7 @@ class FileRender extends React.PureComponent<Props> {
// Supported mediaTypes // Supported mediaTypes
const mediaTypes = { const mediaTypes = {
'3D-file': <ThreeViewer source={{ fileType, downloadPath }} theme={currentTheme} />, '3D-file': <ThreeViewer source={{ fileType, downloadPath }} theme={currentTheme} />,
application: ( application: !source.url ? null : (
<webview <webview
ref={element => this.processSandboxRef(element)} ref={element => this.processSandboxRef(element)}
title="" title=""

View file

@ -5,7 +5,7 @@ import Button from 'component/button';
import * as ICONS from 'constants/icons'; import * as ICONS from 'constants/icons';
type Props = { type Props = {
play: () => void, play: (SyntheticInputEvent<*>) => void,
isLoading: boolean, isLoading: boolean,
mediaType: string, mediaType: string,
fileInfo: ?{}, fileInfo: ?{},

View file

@ -42,6 +42,7 @@ type Props = {
searchBarFocused: boolean, searchBarFocused: boolean,
mediaType: string, mediaType: string,
claimRewards: () => void, claimRewards: () => void,
costInfo: ?{ cost: number },
}; };
class FileViewer extends React.PureComponent<Props> { class FileViewer extends React.PureComponent<Props> {
@ -96,7 +97,7 @@ class FileViewer extends React.PureComponent<Props> {
this.props.playingUri !== prev.playingUri this.props.playingUri !== prev.playingUri
) { ) {
// suppress autoplay after download error // suppress autoplay after download error
if (!(this.props.uri in this.props.fileInfoErrors)) { if (!this.props.fileInfoErrors || !(this.props.uri in this.props.fileInfoErrors)) {
this.handleAutoplay(this.props); this.handleAutoplay(this.props);
} }
} }
@ -167,7 +168,7 @@ class FileViewer extends React.PureComponent<Props> {
} }
} }
fireAnalyticsEvent(claim, startTime, playTime) { fireAnalyticsEvent(claim: Claim, startTime: ?number, playTime: ?number) {
const { claimRewards } = this.props; const { claimRewards } = this.props;
const { name, claim_id: claimId, txid, nout } = claim; const { name, claim_id: claimId, txid, nout } = claim;
@ -264,7 +265,7 @@ class FileViewer extends React.PureComponent<Props> {
style={layoverStyle} style={layoverStyle}
> >
<PlayButton <PlayButton
play={e => { play={(e: SyntheticInputEvent<*>) => {
e.stopPropagation(); e.stopPropagation();
this.playContent(); this.playContent();
}} }}

View file

@ -10,16 +10,21 @@ type Props = {
export default (props: Props) => { export default (props: Props) => {
const { claimId, claimName } = props; const { claimId, claimName } = props;
const speechURL = claimName.startsWith('@')
? `${claimName}:${claimId}`
: `${claimId}/${claimName}`;
return claimId && claimName ? ( if (claimId && claimName) {
<Button const speechURL = claimName.startsWith('@')
icon={ICONS.GLOBE} ? `${claimName}:${claimId}`
button="alt" : `${claimId}/${claimName}`;
label={__('Share')}
href={`https://spee.ch/${speechURL}`} return (
/> <Button
) : null; icon={ICONS.GLOBE}
button="alt"
label={__('Share')}
href={`https://spee.ch/${speechURL}`}
/>
);
}
return null;
}; };

View file

@ -55,24 +55,22 @@ class WunderBar extends React.PureComponent<Props> {
const { ctrlKey, metaKey, keyCode } = event; const { ctrlKey, metaKey, keyCode } = event;
const { doFocus, doBlur, focused } = this.props; const { doFocus, doBlur, focused } = this.props;
if (!this.input) { if (this.input) {
return; if (focused && keyCode === ESC_KEY_CODE) {
} this.input.blur();
doBlur();
return;
}
if (focused && keyCode === ESC_KEY_CODE) { const shouldFocus =
doBlur(); process.platform === 'darwin'
this.input.blur(); ? keyCode === L_KEY_CODE && metaKey
return; : keyCode === L_KEY_CODE && ctrlKey;
}
const shouldFocus = if (shouldFocus) {
process.platform === 'darwin' this.input.focus();
? keyCode === L_KEY_CODE && metaKey doFocus();
: keyCode === L_KEY_CODE && ctrlKey; }
if (shouldFocus) {
doFocus();
this.input.focus();
} }
} }

View file

@ -6,11 +6,15 @@ import Button from 'component/button';
type Props = { type Props = {
closeModal: () => void, closeModal: () => void,
decryptWallet: () => void, decryptWallet: () => void,
updateWalletStatus: () => void,
walletDecryptSucceded: boolean, walletDecryptSucceded: boolean,
updateWalletStatus: boolean,
}; };
class ModalWalletDecrypt extends React.PureComponent<Props> { type State = {
submitted: boolean,
};
class ModalWalletDecrypt extends React.PureComponent<Props, State> {
state = { state = {
submitted: false, // Prior actions could be marked complete submitted: false, // Prior actions could be marked complete
}; };

View file

@ -8,7 +8,7 @@ type Props = {
closeModal: () => void, closeModal: () => void,
walletEncryptSucceded: boolean, walletEncryptSucceded: boolean,
updateWalletStatus: boolean, updateWalletStatus: boolean,
encryptWallet: string => void, encryptWallet: (?string) => void,
updateWalletStatus: () => void, updateWalletStatus: () => void,
}; };
@ -19,7 +19,7 @@ type State = {
understandConfirmed: boolean, understandConfirmed: boolean,
understandError: boolean, understandError: boolean,
submitted: boolean, submitted: boolean,
failMessage: boolean, failMessage: ?string,
}; };
class ModalWalletEncrypt extends React.PureComponent<Props, State> { class ModalWalletEncrypt extends React.PureComponent<Props, State> {
@ -30,7 +30,7 @@ class ModalWalletEncrypt extends React.PureComponent<Props, State> {
understandConfirmed: false, understandConfirmed: false,
understandError: false, understandError: false,
submitted: false, // Prior actions could be marked complete submitted: false, // Prior actions could be marked complete
failMessage: false, failMessage: undefined,
}; };
componentDidUpdate() { componentDidUpdate() {

View file

@ -6,7 +6,8 @@ import Button from 'component/button';
type Props = { type Props = {
quit: () => void, quit: () => void,
unlockWallet: string => void, closeModal: () => void,
unlockWallet: (?string) => void,
walletUnlockSucceded: boolean, walletUnlockSucceded: boolean,
}; };

View file

@ -146,7 +146,7 @@ class FilePage extends React.Component<Props> {
// We will select the claim id before they publish // We will select the claim id before they publish
let editUri; let editUri;
if (claimIsMine) { if (claimIsMine) {
const uriObject: { contentName: string, claimId: string, channelName: ?string } = { const uriObject: { contentName: string, claimId: string, channelName?: string } = {
contentName: claim.name, contentName: claim.name,
claimId: claim.claim_id, claimId: claim.claim_id,
}; };

View file

@ -3,7 +3,9 @@ import React from 'react';
import Page from 'component/page'; import Page from 'component/page';
import UserHistory from 'component/userHistory'; import UserHistory from 'component/userHistory';
class UserHistoryPage extends React.PureComponent { type Props = {};
class UserHistoryPage extends React.PureComponent<Props> {
render() { render() {
return ( return (
<Page> <Page>