Skip to content

Commit

Permalink
chore: allow smart disenchanting to be used easier
Browse files Browse the repository at this point in the history
  • Loading branch information
feildmaster committed May 24, 2024
1 parent 90b05d0 commit 4be4d77
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/base/library/craft/disenchant.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ const setting = settings.register({
key: 'underscript.disable.disenchant',
default: true,
refresh: onPage('Crafting'),
note: 'Disabled until remade.',
note: 'Enable at own risk',
category: 'Crafting',
page: 'Library',
disabled: true,
});

onPage('Crafting', function disenchantWrapper() {
if (setting.disabled || setting.value()) return;
let processing = false;

eventManager.on('jQuery', () => {
const button = $('<button class="btn btn-info">Smart Disenchant</button>');
button.click(onclick);
Expand Down Expand Up @@ -82,6 +83,7 @@ onPage('Crafting', function disenchantWrapper() {
}

function updateOrToast(toast, message) {
processing = false;
if (toast.exists()) {
toast.setText(message);
} else {
Expand All @@ -90,9 +92,10 @@ onPage('Crafting', function disenchantWrapper() {
}

function disenchant(cards) {
if (!cards.length) return;
if (!cards.length || processing) return;
processing = true;
const toast = fnToast('Please wait while disenchanting.<br />(this may take a while)');
axios.all(build(cards))
axios.all(build(cards.splice(0)))
.then(process)
.then((response) => {
if (!response) throw new Error('All errored out');
Expand Down

0 comments on commit 4be4d77

Please sign in to comment.