From e828c255995c105646621a7bf99119c1e88e7252 Mon Sep 17 00:00:00 2001 From: Tim Klingeleers Date: Sun, 5 Nov 2017 22:20:24 +0100 Subject: [PATCH] fix: adjust list price on unitialized quicklist panel on the Unassigned view, the quicklist panel isn't initialized until you open it. We have to set the auction data accordingly for it to update prices on a closed panel. --- app/transferlist/min-bin.js | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/app/transferlist/min-bin.js b/app/transferlist/min-bin.js index a16dc48..fd7d2d2 100644 --- a/app/transferlist/min-bin.js +++ b/app/transferlist/min-bin.js @@ -1,6 +1,6 @@ /* globals GM_notification -gNavManager +gNavManager entities window $ document */ import { BaseScript, SettingsEntry } from '../core'; @@ -106,14 +106,27 @@ class MinBin extends BaseScript { if (settings['adjust-list-price'] && gNavManager.getCurrentScreenController()._controller._rightController ._currentController._quickListPanel) { - const quicklistpanel = gNavManager.getCurrentScreenController()._controller._rightController - ._currentController._quickListPanel._view; - const bidSpinner = quicklistpanel._bidNumericStepper; - const buySpinner = quicklistpanel._buyNowNumericStepper; + const quicklistpanelController = gNavManager.getCurrentScreenController() + ._controller._rightController + ._currentController._quickListPanel; + const quicklistpanel = quicklistpanelController._view; + const listPrice = priceTiers.determineListPrice( minimumBin * (settings['start-price-percentage'] / 100), minimumBin * (settings['buy-now-price-percentage'] / 100), ); + + if (quicklistpanelController._item) { + // sets the values when the quicklistpanel hasn't been initialized + const auction = new entities.Auction(); + auction.tradeId = -1; // anything else than 0 + auction.startingBid = listPrice.start; + auction.buyNowPrice = listPrice.buyNow; + quicklistpanelController._item.setAuctionData(auction); + } + + const bidSpinner = quicklistpanel._bidNumericStepper; + const buySpinner = quicklistpanel._buyNowNumericStepper; bidSpinner.value = listPrice.start; buySpinner.value = listPrice.buyNow; } @@ -126,8 +139,10 @@ class MinBin extends BaseScript { .getIterator().current(); } - return gNavManager.getCurrentScreenController()._controller._rightController - ._currentController._viewmodel.current()._item; + const current = gNavManager.getCurrentScreenController()._controller._rightController + ._currentController._viewmodel.current(); + + return current._item ? current._item : current; } /* eslint-enable class-methods-use-this */ }