From dc9013652914333bfdc3c067d9b83a71f28c7382 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Tue, 30 Oct 2018 15:43:38 -0700 Subject: Remove old files --- packages/instant/src/components/progress_bar.tsx | 34 ------- .../src/components/zero_ex_instant_container.tsx | 3 - .../src/containers/selected_asset_progress_bar.tsx | 37 ------- packages/instant/src/redux/actions.ts | 4 - packages/instant/src/redux/reducer.ts | 9 -- packages/instant/src/types.ts | 5 - packages/instant/src/util/progress.ts | 108 --------------------- 7 files changed, 200 deletions(-) delete mode 100644 packages/instant/src/components/progress_bar.tsx delete mode 100644 packages/instant/src/containers/selected_asset_progress_bar.tsx delete mode 100644 packages/instant/src/util/progress.ts (limited to 'packages') 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 = props => ( - - - - Est. Time ({props.estTimeMs / 1000} seconds) - {props.elapsedTimeMs / 1000} - - - - - - -); 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 - 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 = 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 ; - } - - 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; - - constructor(dispatcher: Dispatch) { - 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): Progress => { - _currentProgress = _currentProgress || new Progress(dispatcher); - return _currentProgress; -}; -- cgit v1.2.3