aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-10-31 06:43:38 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-10-31 06:43:38 +0800
commitdc9013652914333bfdc3c067d9b83a71f28c7382 (patch)
tree0caf8804363e80add1a2267c682d7a673d0b5eb2 /packages/instant/src
parentabaa39a5e24daa8a1a7ff5617a14d2f3088cb0e3 (diff)
downloaddexon-sol-tools-dc9013652914333bfdc3c067d9b83a71f28c7382.tar
dexon-sol-tools-dc9013652914333bfdc3c067d9b83a71f28c7382.tar.gz
dexon-sol-tools-dc9013652914333bfdc3c067d9b83a71f28c7382.tar.bz2
dexon-sol-tools-dc9013652914333bfdc3c067d9b83a71f28c7382.tar.lz
dexon-sol-tools-dc9013652914333bfdc3c067d9b83a71f28c7382.tar.xz
dexon-sol-tools-dc9013652914333bfdc3c067d9b83a71f28c7382.tar.zst
dexon-sol-tools-dc9013652914333bfdc3c067d9b83a71f28c7382.zip
Remove old files
Diffstat (limited to 'packages/instant/src')
-rw-r--r--packages/instant/src/components/progress_bar.tsx34
-rw-r--r--packages/instant/src/components/zero_ex_instant_container.tsx3
-rw-r--r--packages/instant/src/containers/selected_asset_progress_bar.tsx37
-rw-r--r--packages/instant/src/redux/actions.ts4
-rw-r--r--packages/instant/src/redux/reducer.ts9
-rw-r--r--packages/instant/src/types.ts5
-rw-r--r--packages/instant/src/util/progress.ts108
7 files changed, 0 insertions, 200 deletions
diff --git a/packages/instant/src/components/progress_bar.tsx b/packages/instant/src/components/progress_bar.tsx
deleted file mode 100644
index d5d1f3ded..000000000
--- a/packages/instant/src/components/progress_bar.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import * as React from 'react';
-
-import { ColorOption } from '../style/theme';
-
-import { Container } from './ui/container';
-import { Flex } from './ui/flex';
-import { Text } from './ui/text';
-
-export interface ProgressBarProps {
- percentageDone: number;
- estTimeMs: number;
- elapsedTimeMs: number;
-}
-
-// TODO: Est time to minutes with suffix
-// TODO: time in minutes
-export const ProgressBar: React.StatelessComponent<ProgressBarProps> = props => (
- <Container padding="20px 20px 0px 20px" width="100%">
- <Container marginBottom="5px">
- <Flex justify="space-between">
- <Text>Est. Time ({props.estTimeMs / 1000} seconds)</Text>
- <Text>{props.elapsedTimeMs / 1000}</Text>
- </Flex>
- </Container>
- <Container width="100%" backgroundColor={ColorOption.lightGrey} borderRadius="6px">
- <Container
- width={`${props.percentageDone}%`}
- backgroundColor={ColorOption.primaryColor}
- borderRadius="6px"
- height="6px"
- />
- </Container>
- </Container>
-);
diff --git a/packages/instant/src/components/zero_ex_instant_container.tsx b/packages/instant/src/components/zero_ex_instant_container.tsx
index ae315da47..6b1042668 100644
--- a/packages/instant/src/components/zero_ex_instant_container.tsx
+++ b/packages/instant/src/components/zero_ex_instant_container.tsx
@@ -5,8 +5,6 @@ import { LatestError } from '../containers/latest_error';
import { SelectedAssetBuyOrderStateButtons } from '../containers/selected_asset_buy_order_state_buttons';
import { SelectedAssetInstantHeading } from '../containers/selected_asset_instant_heading';
-// TODO: delete this import and this actual file
-import { SelectedAssetProgressBar } from '../containers/selected_asset_progress_bar';
import { SelectedAssetSimulatedProgressBar } from '../containers/selected_asset_simulated_progress_bar';
import { ColorOption } from '../style/theme';
@@ -29,7 +27,6 @@ export const ZeroExInstantContainer: React.StatelessComponent<ZeroExInstantConta
<Flex direction="column" justify="flex-start">
<SelectedAssetInstantHeading />
<SelectedAssetSimulatedProgressBar />
- <SelectedAssetProgressBar />
<LatestBuyQuoteOrderDetails />
<Container padding="20px" width="100%">
<SelectedAssetBuyOrderStateButtons />
diff --git a/packages/instant/src/containers/selected_asset_progress_bar.tsx b/packages/instant/src/containers/selected_asset_progress_bar.tsx
deleted file mode 100644
index 4564c790a..000000000
--- a/packages/instant/src/containers/selected_asset_progress_bar.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-import * as React from 'react';
-
-import { connect } from 'react-redux';
-
-import { ProgressBar } from '../components/progress_bar';
-import { State } from '../redux/reducer';
-import { OrderProcessState, OrderState } from '../types';
-
-interface SelectedAssetProgressComponentProps {
- buyOrderState: OrderState;
- percentageDone?: number;
-}
-export const SelectedAssetProgressComponent: React.StatelessComponent<SelectedAssetProgressComponentProps> = props => {
- const { buyOrderState, percentageDone } = props;
-
- // TODO: uncomment after done testing
- // const isOrderStateOk =
- // buyOrderState.processState === OrderProcessState.PROCESSING ||
- // buyOrderState.processState === OrderProcessState.SUCCESS;
- const isOrderStateOk = true;
-
- if (isOrderStateOk && percentageDone) {
- return <ProgressBar percentageDone={percentageDone} estTimeMs={1000} elapsedTimeMs={2000} />;
- }
-
- return null;
-};
-
-interface ConnectedState {
- buyOrderState: OrderState;
- percentageDone?: number;
-}
-const mapStateToProps = (state: State, _ownProps: {}): ConnectedState => ({
- buyOrderState: state.buyOrderState,
- percentageDone: state.orderProgress && state.orderProgress.percentageDone,
-});
-export const SelectedAssetProgressBar = connect(mapStateToProps)(SelectedAssetProgressComponent);
diff --git a/packages/instant/src/redux/actions.ts b/packages/instant/src/redux/actions.ts
index e8002aa3b..c27c188bf 100644
--- a/packages/instant/src/redux/actions.ts
+++ b/packages/instant/src/redux/actions.ts
@@ -28,7 +28,6 @@ export enum ActionTypes {
UPDATE_BUY_ORDER_STATE = 'UPDATE_BUY_ORDER_STATE',
UPDATE_LATEST_BUY_QUOTE = 'UPDATE_LATEST_BUY_QUOTE',
UPDATE_SELECTED_ASSET = 'UPDATE_SELECTED_ASSET',
- UPDATE_ORDER_PROGRESS_PERCENTAGE = 'UPDATE_ORDER_PROGRESS_PERCENTAGE',
UPDATE_SIMULATED_ORDER_PROGRESS = 'UPDATE_SIMULATED_ORDER_PROGRESS',
SET_QUOTE_REQUEST_STATE_PENDING = 'SET_QUOTE_REQUEST_STATE_PENDING',
SET_QUOTE_REQUEST_STATE_FAILURE = 'SET_QUOTE_REQUEST_STATE_FAILURE',
@@ -45,9 +44,6 @@ export const actions = {
updateBuyOrderState: (orderState: OrderState) => createAction(ActionTypes.UPDATE_BUY_ORDER_STATE, orderState),
updateLatestBuyQuote: (buyQuote?: BuyQuote) => createAction(ActionTypes.UPDATE_LATEST_BUY_QUOTE, buyQuote),
updateSelectedAsset: (assetData?: string) => createAction(ActionTypes.UPDATE_SELECTED_ASSET, assetData),
- // TODO: this is old, delete
- updateOrderProgressPercentage: (percentDone: number) =>
- createAction(ActionTypes.UPDATE_ORDER_PROGRESS_PERCENTAGE, percentDone),
updateSimulatedOrderProgress: (orderProgress: SimulatedProgress) =>
createAction(ActionTypes.UPDATE_SIMULATED_ORDER_PROGRESS, orderProgress),
setQuoteRequestStatePending: () => createAction(ActionTypes.SET_QUOTE_REQUEST_STATE_PENDING),
diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts
index 428cf0984..3540bd4eb 100644
--- a/packages/instant/src/redux/reducer.ts
+++ b/packages/instant/src/redux/reducer.ts
@@ -12,7 +12,6 @@ import {
DisplayStatus,
Network,
OrderProcessState,
- OrderProgress,
OrderState,
SimulatedProgress,
} from '../types';
@@ -33,8 +32,6 @@ export interface State {
quoteRequestState: AsyncProcessState;
latestErrorMessage?: string;
latestErrorDisplayStatus: DisplayStatus;
- // TODO: this is old, cleanup
- orderProgress?: OrderProgress;
simulatedProgress?: SimulatedProgress;
}
@@ -124,12 +121,6 @@ export const reducer = (state: State = INITIAL_STATE, action: Action): State =>
...state,
selectedAsset: newSelectedAsset,
};
- // TODO: this is old, delete
- case ActionTypes.UPDATE_ORDER_PROGRESS_PERCENTAGE:
- return {
- ...state,
- orderProgress: { percentageDone: action.data },
- };
case ActionTypes.UPDATE_SIMULATED_ORDER_PROGRESS:
return {
...state,
diff --git a/packages/instant/src/types.ts b/packages/instant/src/types.ts
index 4b63abdda..58d6692e4 100644
--- a/packages/instant/src/types.ts
+++ b/packages/instant/src/types.ts
@@ -16,11 +16,6 @@ export enum OrderProcessState {
FAILURE = 'Failure',
}
-// TODO: this is old, delete
-export interface OrderProgress {
- percentageDone: number;
-}
-
export interface SimulatedProgress {
startTimeUnix: number;
expectedEndTimeUnix: number;
diff --git a/packages/instant/src/util/progress.ts b/packages/instant/src/util/progress.ts
deleted file mode 100644
index 2d74ef354..000000000
--- a/packages/instant/src/util/progress.ts
+++ /dev/null
@@ -1,108 +0,0 @@
-// TODO: delete!!
-import * as _ from 'lodash';
-import { Dispatch } from 'redux';
-
-import { PROGRESS_STALL_AT_PERCENTAGE, PROGRESS_TICK_INTERVAL_MS } from '../constants';
-import { Action, actions } from '../redux/actions';
-
-const curTimeUnix = () => {
- return new Date().getTime();
-};
-
-enum TickingState {
- None,
- Running,
- Finishing,
-}
-interface TickingNoneState {
- state: TickingState.None;
-}
-interface TickingRunningStatus {
- state: TickingState.Running;
-}
-interface TickingFinishingStatus {
- state: TickingState.Finishing;
- increasePercentageEveryTick: number;
-}
-type TickingStatus = TickingNoneState | TickingRunningStatus | TickingFinishingStatus;
-
-const TICKS_PER_SECOND = 1000 / PROGRESS_TICK_INTERVAL_MS;
-class Progress {
- private _startTimeUnix?: number;
- private _expectedTimeMs?: number;
- private _intervalId?: number;
- private _percentageDone: number;
- private _tickingStatus: TickingStatus;
- private _dispatcher: Dispatch<Action>;
-
- constructor(dispatcher: Dispatch<Action>) {
- this._startTimeUnix = undefined;
- this._expectedTimeMs = undefined;
- this._percentageDone = 0;
- this._intervalId = undefined;
- this._tickingStatus = { state: TickingState.None };
- this._dispatcher = dispatcher;
- }
-
- public beginRunning(expectedTimeMs: number): void {
- this._clearTimer();
- this._startTimeUnix = curTimeUnix();
- this._expectedTimeMs = expectedTimeMs;
- this._percentageDone = 0;
- this._intervalId = window.setInterval(this._tick.bind(this), PROGRESS_TICK_INTERVAL_MS);
- this._tickingStatus = { state: TickingState.Running };
- }
-
- public setFinishing(): void {
- const percentLeft = 100 - this._percentageDone;
- const increasePercentageEveryTick = percentLeft / TICKS_PER_SECOND;
- this._tickingStatus = {
- state: TickingState.Finishing,
- increasePercentageEveryTick,
- };
- }
-
- private _tick(): void {
- const rawPercentageDone =
- this._tickingStatus.state === TickingState.Finishing
- ? this._getNewPercentageFinishing(this._tickingStatus)
- : this._getNewPercentageNormal();
-
- const maxPercentage = this._tickingStatus.state === TickingState.Finishing ? 100 : PROGRESS_STALL_AT_PERCENTAGE;
- const percentageDone = Math.floor(Math.min(rawPercentageDone, maxPercentage));
- this._percentageDone = percentageDone;
- this._dispatcher(actions.updateOrderProgressPercentage(this._percentageDone));
- console.log('percentageDone', this._percentageDone);
- if (percentageDone >= 100) {
- this._clearTimer();
- }
- return;
- }
-
- private _clearTimer(): void {
- if (this._intervalId) {
- window.clearTimeout(this._intervalId);
- }
- }
-
- private _getNewPercentageNormal(): number {
- if (_.isUndefined(this._startTimeUnix) || _.isUndefined(this._expectedTimeMs)) {
- throw new Error('Cant tick, missing var');
- }
-
- const elapsedTimeMs = curTimeUnix() - this._startTimeUnix;
- const safeElapsedTimeMs = Math.max(elapsedTimeMs, 1);
- const percentageDone = safeElapsedTimeMs / this._expectedTimeMs * 100;
- return percentageDone;
- }
-
- private _getNewPercentageFinishing(finishingState: TickingFinishingStatus): number {
- return this._percentageDone + finishingState.increasePercentageEveryTick;
- }
-}
-
-let _currentProgress: Progress | undefined;
-export const progress = (dispatcher: Dispatch<Action>): Progress => {
- _currentProgress = _currentProgress || new Progress(dispatcher);
- return _currentProgress;
-};