From 5fd19d176a12688cd590debeb698c4563f80ab5a Mon Sep 17 00:00:00 2001 From: Ivan Tivonenko Date: Mon, 27 Apr 2015 23:31:04 +0300 Subject: [PATCH] [FIX] Save last trade page (RT-3259) Save last trade page user went to (Simple or Advanced) to user blob. --- src/js/services/id.service.js | 2 ++ src/js/tabs/exchange.controller.js | 13 +++++++++++++ src/js/tabs/trade.controller.js | 20 ++++++++++++++++++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/js/services/id.service.js b/src/js/services/id.service.js index efe94d7c4..b680a62be 100644 --- a/src/js/services/id.service.js +++ b/src/js/services/id.service.js @@ -148,6 +148,8 @@ module.factory('rpId', ['$rootScope', '$location', '$route', '$routeParams', '$t $scope.$on('$blobUpdate', function() { if (!settings.blobIsValid($scope.userBlob)) return; + $scope.ripple_exchange_selection_trade = settings.getSetting($scope.userBlob, 'rippleExchangeSelectionTrade', false); + var d = $scope.userBlob.data; Options.advanced_feature_switch = settings.getSetting($scope.userBlob, 'trust.advancedMode', false); Options.historyApi = settings.getSetting($scope.userBlob, 'historyApi', Options.historyApi).replace(/[\/]*$/, ''); diff --git a/src/js/tabs/exchange.controller.js b/src/js/tabs/exchange.controller.js index cc496afbb..5ea47b5c0 100644 --- a/src/js/tabs/exchange.controller.js +++ b/src/js/tabs/exchange.controller.js @@ -1,5 +1,6 @@ var util = require('util'), webutil = require('../util/web'), + settings = require('../util/settings'), Tab = require('../client/tab').Tab, Amount = ripple.Amount, Base = ripple.Base, @@ -27,6 +28,18 @@ ExchangeTab.prototype.angular = function (module) var timer; var pf = null; + if (settings.blobIsValid($scope.userBlob)) { + if (settings.getSetting($scope.userBlob, 'rippleExchangeSelectionTrade', false)) { + $scope.userBlob.set('/clients/rippletradecom/rippleExchangeSelectionTrade', false); + } + } else { + var removeListener = $scope.$on('$blobUpdate', function() { + if (settings.getSetting($scope.userBlob, 'rippleExchangeSelectionTrade', false)) { + $scope.userBlob.set('/clients/rippletradecom/rippleExchangeSelectionTrade', false); + } + removeListener(); + }); + } // Remember user preference on Convert vs. Trade $rootScope.ripple_exchange_selection_trade = false; diff --git a/src/js/tabs/trade.controller.js b/src/js/tabs/trade.controller.js index a3f48751f..ed394652a 100644 --- a/src/js/tabs/trade.controller.js +++ b/src/js/tabs/trade.controller.js @@ -55,6 +55,24 @@ TradeTab.prototype.angular = function(module) reverse: false }; + function onBlobIsValid() { + $scope.pairs_query = settings.getSetting($scope.userBlob, 'trade_currency_pairs'); + // Remember user preference on Convert vs. Trade + if (!settings.getSetting($scope.userBlob, 'rippleExchangeSelectionTrade', false)) { + $scope.userBlob.set('/clients/rippletradecom/rippleExchangeSelectionTrade', true); + } + } + + if (settings.blobIsValid($scope.userBlob)) { + onBlobIsValid(); + } else { + var removeListener = $scope.$on('$blobUpdate', function() { + if (!settings.blobIsValid($scope.userBlob)) return; + onBlobIsValid(); + removeListener(); + }); + } + $scope.sortOptions.sortFieldName = $scope.ordersSortFieldChoicesKeyed[$scope.sortOptions.sortField]; $scope.$watch('sortOptions.sortFieldName', function () { @@ -70,8 +88,6 @@ TradeTab.prototype.angular = function(module) // Remember user preference on Convert vs. Trade $rootScope.ripple_exchange_selection_trade = true; - $scope.pairs_query = settings.getSetting($scope.userBlob, 'trade_currency_pairs'); - $scope.currencies_all = require('../data/currencies'); $scope.currencies = [];