Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable autobuy when changing VSP modes #3182

Merged
merged 2 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion app/components/views/TicketsPage/PurchaseTab/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const usePurchaseTab = () => {
const ticketPrice = useSelector(sel.ticketPrice);
const availableVSPs = useSelector(sel.getAvailableVSPs);
const availableVSPsError = useSelector(sel.getDiscoverAvailableVSPError);
const autoBuyerRunning = useSelector(sel.isTicketAutoBuyerEnabled);
const ticketAutoBuyerRunning = useSelector(sel.getTicketAutoBuyerRunning);
const isLegacy = useSelector(sel.getIsLegacy);
const isLoading = useSelector(sel.purchaseTicketsRequestAttempt);
Expand Down Expand Up @@ -75,6 +76,14 @@ export const usePurchaseTab = () => {
};

const toggleIsLegacy = (isLegacy) => {
if (autoBuyerRunning) {
// stop runnig legacy autobuyer
dispatch(ca.ticketBuyerV2Cancel());
}
if (ticketAutoBuyerRunning) {
// stop running new autobuyer
dispatch(ca.ticketBuyerCancel());
}
dispatch(vspa.toggleIsLegacy(isLegacy));
};

Expand All @@ -84,7 +93,8 @@ export const usePurchaseTab = () => {
const setRememberedVspHost = (vsp) =>
dispatch(vspa.setRememberedVspHost(vsp));

const onListUnspentOutputs = (accountNum) => dispatch(listUnspentOutputs(accountNum));
const onListUnspentOutputs = (accountNum) =>
dispatch(listUnspentOutputs(accountNum));

// purchase cspp ticket
const mixedAccount = useSelector(sel.getMixedAccount);
Expand Down
15 changes: 13 additions & 2 deletions app/reducers/snackbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import {
PURCHASETICKETS_SUCCESS,
PURCHASETICKETS_FAILED,
STARTTICKETBUYERV2_SUCCESS,
STARTTICKETBUYERV3_SUCCESS,
STARTTICKETBUYERV2_FAILED,
STOPTICKETBUYERV2_SUCCESS,
STOPTICKETBUYER_SUCCESS,
REVOKETICKETS_SUCCESS,
REVOKETICKETS_FAILED,
IMPORTSCRIPT_MANUAL_SUCCESS,
Expand Down Expand Up @@ -305,6 +307,10 @@ const messages = defineMessages({
id: "runTicketBuyer.Success",
defaultMessage: "Ticket Buyer successfully started."
},
STARTTICKETBUYERV3_SUCCESS: {
id: "runTicketBuyerNew.Success",
defaultMessage: "Ticket Buyer successfully started."
},
STARTTICKETBUYERV2_FAILED: {
id: "runTicketBuyer.Failed",
defaultMessage: "Invalid private password. Please try again."
Expand All @@ -313,10 +319,13 @@ const messages = defineMessages({
id: "stopTicketBuyer.Success",
defaultMessage: "Ticket Buyer successfully stopped."
},
STOPTICKETBUYER_SUCCESS: {
id: "stopTicketBuyerNew.Success",
defaultMessage: "Ticket Buyer successfully stopped."
},
WRONG_PASSPHRASE_MSG: {
id: "errors.wrongPassphrase",
defaultMessage:
"Wrong private passphrase entered."
defaultMessage: "Wrong private passphrase entered."
},
TRZ_TOGGLEPINPROTECTION_SUCCESS_ENABLED: {
id: "trezor.pinProtectionSuccess.enabled",
Expand Down Expand Up @@ -568,7 +577,9 @@ export default function snackbar(state = {}, action) {
case REVOKETICKETS_SUCCESS:
case IMPORTSCRIPT_MANUAL_SUCCESS:
case STARTTICKETBUYERV2_SUCCESS:
case STARTTICKETBUYERV3_SUCCESS:
case STOPTICKETBUYERV2_SUCCESS:
case STOPTICKETBUYER_SUCCESS:
case UPDATESTAKEPOOLCONFIG_SUCCESS:
case REMOVESTAKEPOOLCONFIG:
case SEEDCOPIEDTOCLIPBOARD:
Expand Down