Skip to content

Commit 9ee3fa9

Browse files
committed
fix: collect all button
1 parent b9e3b3d commit 9ee3fa9

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## Version 0.54.0 (2023-07-08)
44
### New Features
55
1. Import deck via URL
6+
### Fixes
7+
1. Fix "Collect All" frienship reward button
68

79
## Version 0.53.1 (2023-07-02)
810
1. Fixed changelog

src/base/friendship/collect.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,19 @@ function getLabel(type = '') {
5353
}
5454
}
5555

56-
eventManager.on(':loaded:Friendship', () => {
57-
button.prop('disabled', setting.value() || !canCollect());
58-
});
56+
function updateButton(enabled = canCollect()) {
57+
button.prop('disabled', !enabled);
58+
}
5959

60-
setting.on((disabled) => {
60+
function setupButton(disabled) {
6161
if (disabled) {
6262
button.addClass('hidden');
63+
updateButton(false);
6364
} else {
64-
button.removeClass('hidden')
65-
.prop('disabled', setting.value() || !canCollect());
65+
button.removeClass('hidden');
66+
updateButton();
6667
}
67-
});
68+
}
6869

6970
eventManager.on('Friendship:claim', ({
7071
data, reward, quantity, error,
@@ -94,16 +95,14 @@ eventManager.on('Friendship:results', (error) => {
9495
title: 'Claimed Friendship Rewards',
9596
text: lines.join('<br>'),
9697
});
97-
button.prop('disabled', !canCollect());
98+
updateButton();
9899
collecting = false;
99100
});
100101

101102
eventManager.on(':loaded:Friendship', () => {
102103
button = $('<button class="btn btn-info">Collect All</button>');
103-
if (setting.value()) {
104-
button.addClass('hidden');
105-
}
106-
button.prop('disabled', true);
104+
setting.on(setupButton);
105+
setupButton(setting.value());
107106
button.on('click.script', collect);
108107
button.hover(hover.show('Collect all rewards'));
109108
$('p[data-i18n="[html]crafting-all-cards"]').css('display', 'inline-block').after(' ', button);

0 commit comments

Comments
 (0)