Skip to content
This repository has been archived by the owner on Apr 22, 2021. It is now read-only.

Commit

Permalink
fix: adjust list price on unitialized quicklist panel
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Mardaneus86 committed Nov 5, 2017
1 parent 701f7d0 commit e828c25
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions app/transferlist/min-bin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* globals
GM_notification
gNavManager
gNavManager entities
window $ document
*/
import { BaseScript, SettingsEntry } from '../core';
Expand Down Expand Up @@ -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;
}
Expand All @@ -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 */
}
Expand Down

0 comments on commit e828c25

Please sign in to comment.