Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/botPage/bot/TradeEngine/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Ticks from './Ticks';
import rootReducer from './state/reducers';
import * as constants from './state/constants';
import { start } from './state/actions';
import { observer as globalObserver } from '../../../common/utils/observer';

const watchBefore = store =>
watchScope({
Expand All @@ -34,7 +35,7 @@ const watchDuring = store =>
});

/* The watchScope function is called randomly and resets the prevTick
* which leads to the same problem we try to solve. So prevTick is isolated
* which leads to the same problem we try to solve. So prevTick is isolated
*/
let prevTick;
const watchScope = ({ store, stopScope, passScope, passFlag }) => {
Expand Down Expand Up @@ -90,6 +91,8 @@ export default class TradeEngine extends Balance(Purchase(Sell(OpenContract(Prop
throw createError('NotInitialized', translate('Bot.init is not called'));
}

globalObserver.emit('bot.running');

this.tradeOptions = expectTradeOptions(tradeOptions);

this.store.dispatch(start());
Expand Down
12 changes: 11 additions & 1 deletion src/botPage/view/TradeInfoPanel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class AnimateTrade extends Component {
super();
this.indicatorMessages = {
notRunning: translate('Bot is not running.'),
starting : translate('Bot is starting...'),
running : translate('Bot is running...'),
stopping : translate('Bot is stopping...'),
stopped : translate('Bot has stopped.'),
Expand All @@ -40,18 +41,27 @@ class AnimateTrade extends Component {
};
}
componentWillMount() {
globalObserver.register('bot.running', () => {
$('.stage-tooltip.top:eq(0)').addClass('running');
this.setState({ indicatorMessage: this.indicatorMessages.running });
});
globalObserver.register('bot.stop', () => {
$('.stage-tooltip.top:eq(0)').removeClass('running');
this.setState({ indicatorMessage: this.indicatorMessages.stopped });
});

$('#stopButton').click(() => {
$('.stage-tooltip.top:eq(0)').removeClass('running');
this.setState({ indicatorMessage: this.state.stopMessage });
});

$('#runButton').click(() => {
resetAnimation();
$('.stage-tooltip.top:eq(0)').addClass('running');
this.setState({ indicatorMessage: this.indicatorMessages.running });
this.setState({
indicatorMessage: this.indicatorMessages.starting,
stopMessage : this.indicatorMessages.stopped,
});
globalObserver.register('contract.status', contractStatus => {
this.animateStage(contractStatus);
});
Expand Down