aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-05-30 06:49:13 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-05-30 06:49:13 +0800
commitbc28a08dd0d4db99549122fb4912b4931a3aad78 (patch)
treeba94822b58608f7c5cf22c0130adb76574de4dd5 /packages/website
parent0d3010f6fc8b14011444f090dfbd0221411a1ab0 (diff)
downloaddexon-sol-tools-bc28a08dd0d4db99549122fb4912b4931a3aad78.tar.gz
dexon-sol-tools-bc28a08dd0d4db99549122fb4912b4931a3aad78.tar.zst
dexon-sol-tools-bc28a08dd0d4db99549122fb4912b4931a3aad78.zip
Address PR feedback
Diffstat (limited to 'packages/website')
-rw-r--r--packages/website/ts/components/onboarding/onboarding_flow.tsx6
-rw-r--r--packages/website/ts/components/onboarding/portal_onboarding_flow.tsx16
-rw-r--r--packages/website/ts/components/wallet/wallet.tsx2
-rw-r--r--packages/website/ts/containers/portal_onboarding_flow.ts8
-rw-r--r--packages/website/ts/index.tsx20
-rw-r--r--packages/website/ts/local_storage/local_storage.ts8
-rw-r--r--packages/website/ts/redux/store.ts21
7 files changed, 41 insertions, 40 deletions
diff --git a/packages/website/ts/components/onboarding/onboarding_flow.tsx b/packages/website/ts/components/onboarding/onboarding_flow.tsx
index de734318e..524587358 100644
--- a/packages/website/ts/components/onboarding/onboarding_flow.tsx
+++ b/packages/website/ts/components/onboarding/onboarding_flow.tsx
@@ -20,7 +20,7 @@ export interface OnboardingFlowProps {
stepIndex: number;
isRunning: boolean;
onClose: () => void;
- setOnboardingStep: (stepIndex: number) => void;
+ updateOnboardingStep: (stepIndex: number) => void;
}
export class OnboardingFlow extends React.Component<OnboardingFlowProps> {
@@ -75,7 +75,7 @@ export class OnboardingFlow extends React.Component<OnboardingFlowProps> {
private _goToNextStep(): void {
const nextStep = this.props.stepIndex + 1;
if (nextStep < this.props.steps.length) {
- this.props.setOnboardingStep(nextStep);
+ this.props.updateOnboardingStep(nextStep);
} else {
this.props.onClose();
}
@@ -84,7 +84,7 @@ export class OnboardingFlow extends React.Component<OnboardingFlowProps> {
private _goToPrevStep(): void {
const nextStep = this.props.stepIndex - 1;
if (nextStep >= 0) {
- this.props.setOnboardingStep(nextStep);
+ this.props.updateOnboardingStep(nextStep);
} else {
this.props.onClose();
}
diff --git a/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx b/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx
index 25570b4a7..8bcb4c749 100644
--- a/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx
+++ b/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx
@@ -14,8 +14,8 @@ export interface PortalOnboardingFlowProps {
injectedProviderName: string;
blockchainIsLoaded: boolean;
hasBeenSeen: boolean;
- setIsRunning: (isRunning: boolean) => void;
- setOnboardingStep: (stepIndex: number) => void;
+ updateIsRunning: (isRunning: boolean) => void;
+ updateOnboardingStep: (stepIndex: number) => void;
}
const steps: Step[] = [
@@ -57,8 +57,8 @@ export class PortalOnboardingFlow extends React.Component<PortalOnboardingFlowPr
steps={steps}
stepIndex={this.props.stepIndex}
isRunning={this.props.isRunning}
- onClose={this.props.setIsRunning.bind(this, false)}
- setOnboardingStep={this.props.setOnboardingStep}
+ onClose={this.props.updateIsRunning.bind(this, false)}
+ updateOnboardingStep={this.props.updateOnboardingStep}
/>
);
}
@@ -75,7 +75,7 @@ export class PortalOnboardingFlow extends React.Component<PortalOnboardingFlowPr
private _adjustStepIfShould(): void {
if (this._isAddressAvailable()) {
if (this.props.stepIndex < 2) {
- this.props.setOnboardingStep(2);
+ this.props.updateOnboardingStep(2);
}
return;
}
@@ -84,14 +84,14 @@ export class PortalOnboardingFlow extends React.Component<PortalOnboardingFlowPr
this.props.injectedProviderName,
);
if (isExternallyInjected) {
- this.props.setOnboardingStep(1);
+ this.props.updateOnboardingStep(1);
return;
}
- this.props.setOnboardingStep(0);
+ this.props.updateOnboardingStep(0);
}
private _autoStartOnboardingIfShould(): void {
if (!this.props.isRunning && !this.props.hasBeenSeen && this.props.blockchainIsLoaded) {
- this.props.setIsRunning(true);
+ this.props.updateIsRunning(true);
}
}
}
diff --git a/packages/website/ts/components/wallet/wallet.tsx b/packages/website/ts/components/wallet/wallet.tsx
index eab986208..524dc1952 100644
--- a/packages/website/ts/components/wallet/wallet.tsx
+++ b/packages/website/ts/components/wallet/wallet.tsx
@@ -45,9 +45,9 @@ import {
import { backendClient } from 'ts/utils/backend_client';
import { colors } from 'ts/utils/colors';
import { constants } from 'ts/utils/constants';
+import { zIndex } from 'ts/utils/style';
import { utils } from 'ts/utils/utils';
import { styles as walletItemStyles } from 'ts/utils/wallet_item_styles';
-import { zIndex } from '../../utils/style';
export interface WalletProps {
userAddress: string;
diff --git a/packages/website/ts/containers/portal_onboarding_flow.ts b/packages/website/ts/containers/portal_onboarding_flow.ts
index a7bd86ab1..56a1db553 100644
--- a/packages/website/ts/containers/portal_onboarding_flow.ts
+++ b/packages/website/ts/containers/portal_onboarding_flow.ts
@@ -19,8 +19,8 @@ interface ConnectedState {
}
interface ConnectedDispatch {
- setIsRunning: (isRunning: boolean) => void;
- setOnboardingStep: (stepIndex: number) => void;
+ updateIsRunning: (isRunning: boolean) => void;
+ updateOnboardingStep: (stepIndex: number) => void;
}
const mapStateToProps = (state: State): ConnectedState => ({
@@ -34,13 +34,13 @@ const mapStateToProps = (state: State): ConnectedState => ({
});
const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
- setIsRunning: (isRunning: boolean): void => {
+ updateIsRunning: (isRunning: boolean): void => {
dispatch({
type: ActionTypes.UpdatePortalOnboardingShowing,
data: isRunning,
});
},
- setOnboardingStep: (stepIndex: number): void => {
+ updateOnboardingStep: (stepIndex: number): void => {
dispatch({
type: ActionTypes.UpdatePortalOnboardingStep,
data: stepIndex,
diff --git a/packages/website/ts/index.tsx b/packages/website/ts/index.tsx
index 5ab03c07c..a6bfe7dd2 100644
--- a/packages/website/ts/index.tsx
+++ b/packages/website/ts/index.tsx
@@ -1,13 +1,9 @@
-// Polyfills
-import * as _ from 'lodash';
import { MuiThemeProvider } from 'material-ui/styles';
import * as React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { BrowserRouter as Router, Redirect, Route, Switch } from 'react-router-dom';
import * as injectTapEventPlugin from 'react-tap-event-plugin';
-import { createStore, Store as ReduxStore } from 'redux';
-import { devToolsEnhancer } from 'redux-devtools-extension/developmentOnly';
import { Redirecter } from 'ts/components/redirecter';
import { About } from 'ts/containers/about';
import { FAQ } from 'ts/containers/faq';
@@ -15,14 +11,14 @@ import { Landing } from 'ts/containers/landing';
import { NotFound } from 'ts/containers/not_found';
import { Wiki } from 'ts/containers/wiki';
import { createLazyComponent } from 'ts/lazy_component';
-import { stateStorage } from 'ts/local_storage/state_storage';
import { trackedTokenStorage } from 'ts/local_storage/tracked_token_storage';
import { tradeHistoryStorage } from 'ts/local_storage/trade_history_storage';
-import { reducer, State } from 'ts/redux/reducer';
+import { store } from 'ts/redux/store';
import { WebsiteLegacyPaths, WebsitePaths } from 'ts/types';
import { analytics } from 'ts/utils/analytics';
import { muiTheme } from 'ts/utils/mui_theme';
import { utils } from 'ts/utils/utils';
+// Polyfills
import 'whatwg-fetch';
injectTapEventPlugin();
@@ -77,18 +73,6 @@ const LazyOrderUtilsDocumentation = createLazyComponent('Documentation', async (
analytics.init();
// tslint:disable-next-line:no-floating-promises
analytics.logProviderAsync((window as any).web3);
-const store: ReduxStore<State> = createStore(
- reducer,
- stateStorage.getPersistedDefaultState(),
- devToolsEnhancer({ name: '0x Website Redux Store' }),
-);
-store.subscribe(
- _.throttle(() => {
- stateStorage.saveState({
- hasPortalOnboardingBeenSeen: store.getState().hasPortalOnboardingBeenSeen,
- });
- }, 1000),
-);
render(
<Router>
diff --git a/packages/website/ts/local_storage/local_storage.ts b/packages/website/ts/local_storage/local_storage.ts
index 569e262fc..1e3258ce0 100644
--- a/packages/website/ts/local_storage/local_storage.ts
+++ b/packages/website/ts/local_storage/local_storage.ts
@@ -26,14 +26,10 @@ export const localStorage = {
}
window.localStorage.removeItem(key);
},
- getObject(key: string): object {
+ getObject(key: string): object | undefined {
const item = localStorage.getItemIfExists(key);
if (item) {
- try {
- return JSON.parse(item);
- } catch (err) {
- return undefined;
- }
+ return JSON.parse(item);
}
return undefined;
},
diff --git a/packages/website/ts/redux/store.ts b/packages/website/ts/redux/store.ts
new file mode 100644
index 000000000..203f068a1
--- /dev/null
+++ b/packages/website/ts/redux/store.ts
@@ -0,0 +1,21 @@
+import * as _ from 'lodash';
+import { createStore, Store as ReduxStore } from 'redux';
+import { devToolsEnhancer } from 'redux-devtools-extension/developmentOnly';
+import { stateStorage } from 'ts/local_storage/state_storage';
+import { reducer, State } from 'ts/redux/reducer';
+
+const ONE_SECOND = 1000;
+
+export const store: ReduxStore<State> = createStore(
+ reducer,
+ stateStorage.getPersistedDefaultState(),
+ devToolsEnhancer({ name: '0x Website Redux Store' }),
+);
+store.subscribe(
+ _.throttle(() => {
+ // Persisted state
+ stateStorage.saveState({
+ hasPortalOnboardingBeenSeen: store.getState().hasPortalOnboardingBeenSeen,
+ });
+ }, ONE_SECOND),
+);