diff --git a/src/admin/trades.ts b/src/admin/trades.ts index 17c41754d..c1a26e07f 100644 --- a/src/admin/trades.ts +++ b/src/admin/trades.ts @@ -119,7 +119,7 @@ var TradesListController = ($scope : TradesScope, $log : ng.ILogService, subscri if ($scope.trade_statuses[i].alloc >= $scope.trade_statuses[i].quantity) $scope.trade_statuses[i].side = 'K'; $scope.gridApi.grid.notifyDataChange(uiGridConstants.dataChange.ALL); - if (!t.loadedFromBD && $scope.audio) { + if (t.loadedFromDB === false && $scope.audio) { var audio = new Audio('/audio/'+(merged?'boom':'erang')+'.mp3'); audio.volume = 0.5; audio.play(); @@ -129,7 +129,7 @@ var TradesListController = ($scope : TradesScope, $log : ng.ILogService, subscri } if (!exists) { $scope.trade_statuses.push(new DisplayTrade($scope, t)); - if (!t.loadedFromBD && $scope.audio) { + if (t.loadedFromDB === false && $scope.audio) { var audio = new Audio('/audio/boom.mp3'); audio.volume = 0.5; audio.play(); diff --git a/src/common/models.ts b/src/common/models.ts index d765f647e..9627400d7 100644 --- a/src/common/models.ts +++ b/src/common/models.ts @@ -253,7 +253,7 @@ export class Trade implements ITimestamped { public alloc: number, public allocprice: number, public feeCharged: number, - public loadedFromBD: boolean) {} + public loadedFromDB: boolean) {} } export class CurrencyPosition { diff --git a/src/service/broker.ts b/src/service/broker.ts index cab719714..367faa52d 100644 --- a/src/service/broker.ts +++ b/src/service/broker.ts @@ -249,6 +249,7 @@ export class OrderBroker implements Interfaces.IOrderBroker { trade.value = Math.abs(trade.price*trade.quantity); if (this._trades[i].quantity<=this._trades[i].alloc) this._trades[i].value = Math.abs((this._trades[i].quantity*this._trades[i].price)-(this._trades[i].alloc*this._trades[i].allocprice)); + this._trades[i].loadedFromDB = false; this._tradePublisher.publish(this._trades[i]); this._tradePersister.repersist(this._trades[i], this._trades[i]); break; @@ -263,6 +264,7 @@ export class OrderBroker implements Interfaces.IOrderBroker { this._trades[i].time = trade.time; this._trades[i].quantity += trade.quantity; this._trades[i].value += trade.value; + this._trades[i].loadedFromDB = false; this._tradePublisher.publish(this._trades[i]); this._tradePersister.repersist(this._trades[i], this._trades[i]); break; diff --git a/src/service/persister.ts b/src/service/persister.ts index c0b2f45e3..2b0037d5f 100644 --- a/src/service/persister.ts +++ b/src/service/persister.ts @@ -27,7 +27,7 @@ export interface Persistable { time?: moment.Moment|Date; pair?: Models.CurrencyPair; exchange?: Models.Exchange; - loadedFromBD?: boolean; + loadedFromDB?: boolean; } export class LoaderSaver { @@ -39,7 +39,7 @@ export class LoaderSaver { if (typeof x.pair === "undefined") x.pair = this._pair; if (setDBFlag === true) - x.loadedFromBD = true; + x.loadedFromDB = true; }; public saver = (x: Persistable) => { @@ -49,6 +49,8 @@ export class LoaderSaver { x.exchange = this._exchange; if (typeof x.pair === "undefined") x.pair = this._pair; + if (typeof x.loadedFromDB !== "undefined") + delete x.loadedFromDB; }; constructor(private _exchange: Models.Exchange, private _pair: Models.CurrencyPair) { }