-
Notifications
You must be signed in to change notification settings - Fork 78
[Cleanup] Enable noUnusedLocals/Parameters and remove all refs #877
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import * as _ from "lodash" | ||
import React from "react" | ||
import { AppRegistry, View, ViewProperties } from "react-native" | ||
import { TrackingInfo } from "react-tracking" | ||
import { AppRegistry, View } from "react-native" | ||
|
||
import Consignments from "./Components/Consignments" | ||
import Containers from "./Containers/index" | ||
|
@@ -12,24 +10,18 @@ import { | |
InboxRenderer, | ||
InquiryRenderer, | ||
MyProfileRenderer, | ||
RenderCallback, | ||
SaleRenderer, | ||
WorksForYouRenderer, | ||
} from "./relay/QueryRenderers" | ||
import FavoritesScene from "./Scenes/Favorites" | ||
import HomeScene from "./Scenes/Home" | ||
import renderWithLoadProgress from "./utils/renderWithLoadProgress" | ||
import { Schema, screenTrack as track, Track } from "./utils/track" | ||
|
||
// Analytics wrapper for all of our top level React components | ||
function AddTrack(pageName: string) { | ||
return component => component | ||
} | ||
import { Schema, screenTrack as track } from "./utils/track" | ||
|
||
interface ArtistProps { | ||
artistID: string | ||
isPad: boolean | ||
} | ||
|
||
const Artist: React.SFC<ArtistProps> = track<ArtistProps>(props => { | ||
return { | ||
context_screen: Schema.PageNames.ArtistPage, | ||
|
@@ -38,7 +30,7 @@ const Artist: React.SFC<ArtistProps> = track<ArtistProps>(props => { | |
} | ||
})(props => <ArtistRenderer {...props} render={renderWithLoadProgress(Containers.Artist, props)} />) | ||
|
||
const Inbox: React.SFC<{}> = track<{}>(props => { | ||
const Inbox: React.SFC<{}> = track<{}>(() => { | ||
return { context_screen: Schema.PageNames.InboxPage, context_screen_owner_type: null } | ||
})(props => <InboxRenderer {...props} render={renderWithLoadProgress(Containers.Inbox, props)} />) | ||
|
||
|
@@ -52,10 +44,11 @@ const Gene: React.SFC<GeneProps> = ({ geneID, refineSettings: { medium, price_ra | |
return <GeneRenderer {...initialProps} render={renderWithLoadProgress(Containers.Gene, initialProps)} /> | ||
} | ||
|
||
const Sale: React.SFC<{ saleID: string }> = ({ saleID }) => { | ||
const initialProps = { saleID } | ||
return <SaleRenderer {...initialProps} render={renderWithLoadProgress(Containers.Sale, initialProps)} /> | ||
} | ||
// FIXME: This isn't being used | ||
// const Sale: React.SFC<{ saleID: string }> = ({ saleID }) => { | ||
// const initialProps = { saleID } | ||
// return <SaleRenderer {...initialProps} render={renderWithLoadProgress(Containers.Sale, initialProps)} /> | ||
// } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe the sale view is a WIP that @ashfurrow works on. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After talking with ash confirmed this is on hold for the time being but will leave it around for now |
||
|
||
// TODO: This was required to trigger the 1px wake-up hack (in case the scrollview goes blank) | ||
// | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import React from "react" | ||
import React, { Component } from "react" | ||
import { StyleSheet, View, ViewProperties } from "react-native" | ||
import { createFragmentContainer, graphql } from "react-relay" | ||
|
||
|
@@ -19,33 +19,22 @@ interface RenderSectionParams { | |
mapPropsToArtworksConnection: (Props) => any | ||
} | ||
|
||
interface Props extends ViewProperties { | ||
artist: { | ||
counts: { | ||
for_sale_artworks: number | ||
artworks: number | ||
} | ||
not_for_sale_artworks: any[] | ||
for_sale_artworks: any[] | ||
} | ||
relay: any | ||
interface Props extends RelayProps, ViewProperties { | ||
relay?: RelayProps | ||
} | ||
|
||
interface State { | ||
completedForSaleWorks: boolean | ||
} | ||
|
||
class Artworks extends React.Component<Props, State> { | ||
constructor(props) { | ||
super(props) | ||
this.state = { | ||
completedForSaleWorks: false, | ||
} | ||
class Artworks extends Component<Props, State> { | ||
state = { | ||
completedForSaleWorks: false, | ||
} | ||
|
||
render() { | ||
const forSaleCount = this.props.artist.counts.for_sale_artworks | ||
const otherCount = this.props.artist.counts.artworks - forSaleCount | ||
const otherCount = (this.props.artist.counts.artworks as number) - (forSaleCount as number) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alloy - after fixing my typechecker and eliminating some of those top-of-the file Props overrides things got a little stricter and this one was interesting to try to understand... If you look here and here (this components child) and notice the types, they both say
Since they're both cast to any of four types the compiler can't make basic inferences, right? And so casting it explicitly above set it through the whole chain? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, you’re code is correct. Because this value could be of a non number type (according to the typing at least), TS will complain that you can’t just subtract. Casting as a subtype, that is, one of the types in this union allows you to do so. I don’t recall exactly why these typings are a union like that. Is the field a custom GraphQL scalar? If so, iirc those are indeed not very specific :( |
||
if (forSaleCount === 0) { | ||
return this.renderSection({ | ||
title: "Works", | ||
|
@@ -75,7 +64,7 @@ class Artworks extends React.Component<Props, State> { | |
<View style={styles.section}> | ||
{this.renderSection({ | ||
title: "Works for Sale", | ||
count: forSaleCount, | ||
count: forSaleCount as number, | ||
filter: "IS_FOR_SALE", | ||
onComplete: () => this.setState({ completedForSaleWorks: true }), | ||
Component: ArtistForSaleArtworksGrid, | ||
|
@@ -144,7 +133,5 @@ interface RelayProps { | |
artworks: boolean | number | string | null | ||
for_sale_artworks: boolean | number | string | null | ||
} | null | ||
for_sale_artworks: Array<boolean | number | string | null> | null | ||
not_for_sale_artworks: Array<boolean | number | string | null> | null | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For whatever reason, rules like "require trailing comma" would auto-fix in
.json
files making it impossible to produce correct JSON.