Skip to content

Commit

Permalink
Fixed audioReady timer.
Browse files Browse the repository at this point in the history
  • Loading branch information
ctubio committed Aug 6, 2016
1 parent 54ab3f6 commit 8b95170
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/admin/trades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/common/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions src/service/broker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions src/service/persister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface Persistable {
time?: moment.Moment|Date;
pair?: Models.CurrencyPair;
exchange?: Models.Exchange;
loadedFromBD?: boolean;
loadedFromDB?: boolean;
}

export class LoaderSaver {
Expand All @@ -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) => {
Expand All @@ -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) { }
Expand Down

0 comments on commit 8b95170

Please sign in to comment.