From 88a731ffea4f5d8f4fa7f082ab109e500e0d68a3 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Sat, 19 Jan 2019 13:54:06 -0500 Subject: [PATCH] fix: flow errors --- .eslintrc.json | 3 +- .flowconfig | 1 + src/renderer/analytics.js | 14 +++------ src/renderer/component/cardVerify/view.jsx | 8 +++-- src/renderer/component/fileRender/view.jsx | 14 +++++---- .../fileViewer/internal/play-button.jsx | 2 +- src/renderer/component/fileViewer/view.jsx | 7 +++-- .../component/viewOnWebButton/view.jsx | 27 ++++++++++------- src/renderer/component/wunderbar/view.jsx | 30 +++++++++---------- .../modal/modalWalletDecrypt/view.jsx | 8 +++-- .../modal/modalWalletEncrypt/view.jsx | 6 ++-- src/renderer/modal/modalWalletUnlock/view.jsx | 3 +- src/renderer/page/file/view.jsx | 2 +- src/renderer/page/userHistory/view.jsx | 4 ++- 14 files changed, 71 insertions(+), 58 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 826d60329..54a2b5ea6 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -50,6 +50,7 @@ "no-prototype-builtins": 0, "flowtype/space-after-type-colon": [2, "always", { "allowLineBreak": true }], "no-restricted-syntax": 0, - "no-empty": 0 + "no-empty": 0, + "react/prefer-stateless-function": 0 } } diff --git a/.flowconfig b/.flowconfig index ffc632dcf..f603ef170 100644 --- a/.flowconfig +++ b/.flowconfig @@ -1,4 +1,5 @@ [ignore] +node_modules/ [include] diff --git a/src/renderer/analytics.js b/src/renderer/analytics.js index 1fab23a27..a946fcdc8 100644 --- a/src/renderer/analytics.js +++ b/src/renderer/analytics.js @@ -13,13 +13,13 @@ type Analytics = { track: (string, ?Object) => void, setUser: Object => void, toggle: (boolean, ?boolean) => void, - apiLogView: (string, string, string) => void, + apiLogView: (string, string, string, ?number, ?() => void) => void, }; let analyticsEnabled: boolean = false; const analytics: Analytics = { - track: (name: string, payload: ?Object): void => { + track: (name, payload) => { if (analyticsEnabled) { if (payload) { mixpanel.track(name, payload); @@ -28,7 +28,7 @@ const analytics: Analytics = { } } }, - setUser: (user: Object): void => { + setUser: user => { if (user.id) { mixpanel.identify(user.id); } @@ -44,13 +44,7 @@ const analytics: Analytics = { } analyticsEnabled = enabled; }, - apiLogView: ( - uri: string, - outpoint: string, - claimId: string, - timeToStart?: number, - onSuccessCb: ?() => void - ): void => { + apiLogView: (uri, outpoint, claimId, timeToStart, onSuccessCb) => { if (analyticsEnabled) { const params: { uri: string, diff --git a/src/renderer/component/cardVerify/view.jsx b/src/renderer/component/cardVerify/view.jsx index 44f4635b1..49a12b4ca 100644 --- a/src/renderer/component/cardVerify/view.jsx +++ b/src/renderer/component/cardVerify/view.jsx @@ -29,8 +29,12 @@ type Props = { token: string, }; -class CardVerify extends React.Component { - constructor(props) { +type State = { + open: boolean, +}; + +class CardVerify extends React.Component { + constructor(props: Props) { super(props); this.state = { open: false, diff --git a/src/renderer/component/fileRender/view.jsx b/src/renderer/component/fileRender/view.jsx index 6d40e9e90..5973eb9ca 100644 --- a/src/renderer/component/fileRender/view.jsx +++ b/src/renderer/component/fileRender/view.jsx @@ -16,15 +16,16 @@ type Props = { fileType: string, contentType: string, downloadPath: string, + url: ?string, }, currentTheme: string, }; class FileRender extends React.PureComponent { - constructor(props) { + constructor(props: Props) { super(props); - this.escapeListener = this.escapeListener.bind(this); + (this: any).escapeListener = this.escapeListener.bind(this); } componentDidMount() { @@ -35,7 +36,8 @@ class FileRender extends React.PureComponent { window.removeEventListener('keydown', this.escapeListener, true); } - processSandboxRef(element) { + // This should use React.createRef() + processSandboxRef(element: any) { if (!element) { return; } @@ -47,7 +49,7 @@ class FileRender extends React.PureComponent { console.log('permissionrequest', e); }); - element.addEventListener('console-message', e => { + element.addEventListener('console-message', (e: { message: string }) => { if (/^\$LBRY_IPC:/.test(e.message)) { // Process command let message = {}; @@ -71,7 +73,7 @@ class FileRender extends React.PureComponent { }); } - escapeListener(e) { + escapeListener(e: SyntheticKeyboardEvent<*>) { if (e.keyCode === 27) { e.preventDefault(); @@ -97,7 +99,7 @@ class FileRender extends React.PureComponent { // Supported mediaTypes const mediaTypes = { '3D-file': , - application: ( + application: !source.url ? null : ( this.processSandboxRef(element)} title="" diff --git a/src/renderer/component/fileViewer/internal/play-button.jsx b/src/renderer/component/fileViewer/internal/play-button.jsx index e2346b8b0..3fc7c1620 100644 --- a/src/renderer/component/fileViewer/internal/play-button.jsx +++ b/src/renderer/component/fileViewer/internal/play-button.jsx @@ -5,7 +5,7 @@ import Button from 'component/button'; import * as ICONS from 'constants/icons'; type Props = { - play: () => void, + play: (SyntheticInputEvent<*>) => void, isLoading: boolean, mediaType: string, fileInfo: ?{}, diff --git a/src/renderer/component/fileViewer/view.jsx b/src/renderer/component/fileViewer/view.jsx index 66cf1226c..a6f247507 100644 --- a/src/renderer/component/fileViewer/view.jsx +++ b/src/renderer/component/fileViewer/view.jsx @@ -42,6 +42,7 @@ type Props = { searchBarFocused: boolean, mediaType: string, claimRewards: () => void, + costInfo: ?{ cost: number }, }; class FileViewer extends React.PureComponent { @@ -96,7 +97,7 @@ class FileViewer extends React.PureComponent { this.props.playingUri !== prev.playingUri ) { // 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); } } @@ -167,7 +168,7 @@ class FileViewer extends React.PureComponent { } } - fireAnalyticsEvent(claim, startTime, playTime) { + fireAnalyticsEvent(claim: Claim, startTime: ?number, playTime: ?number) { const { claimRewards } = this.props; const { name, claim_id: claimId, txid, nout } = claim; @@ -264,7 +265,7 @@ class FileViewer extends React.PureComponent { style={layoverStyle} > { + play={(e: SyntheticInputEvent<*>) => { e.stopPropagation(); this.playContent(); }} diff --git a/src/renderer/component/viewOnWebButton/view.jsx b/src/renderer/component/viewOnWebButton/view.jsx index 243a74902..681c56fc1 100644 --- a/src/renderer/component/viewOnWebButton/view.jsx +++ b/src/renderer/component/viewOnWebButton/view.jsx @@ -10,16 +10,21 @@ type Props = { export default (props: Props) => { const { claimId, claimName } = props; - const speechURL = claimName.startsWith('@') - ? `${claimName}:${claimId}` - : `${claimId}/${claimName}`; - return claimId && claimName ? ( -