Skip to content

Commit 7dd515b

Browse files
committed
Fix double toasts
1 parent c0152e5 commit 7dd515b

6 files changed

Lines changed: 28 additions & 25 deletions

File tree

assets/locales/en/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,7 @@
771771
"no_results": "No results found.",
772772
"showing_results": "Showing {{max}} of {{total}} total results.",
773773
"item_added": "{{itemName}} was added to the batch.",
774+
"item_removed": "{{itemName}} was removed from the batch.",
774775
"item_unique": "{{itemName}} is unique and already added."
775776
},
776777
"settings": {

assets/locales/fr/translation.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -769,12 +769,13 @@
769769
"min_ilvl": "ILvl min",
770770
"max_ilvl": "ILvl max",
771771
"no_results": "Aucun résultat trouvé.",
772-
"showing_results": "Affichage de {max} sur {total} résultats totaux.",
773-
"item_added": "{itemName} a été ajouté au lot.",
774-
"item_unique": "{itemName} est unique et a déjà été ajouté."
772+
"showing_results": "Affichage de {{max}} sur {{total}} résultats totaux.",
773+
"item_added": "{{itemName}} a été ajouté au lot.",
774+
"item_removed": "{{itemName}} a été retiré du lot.",
775+
"item_unique": "{{itemName}} est unique et a déjà été ajouté."
775776
},
776777
"settings": {
777-
"combinations_count": "{count} Combinaisons",
778+
"combinations_count": "{{count}} Combinaisons",
778779
"combination_singular": "1 Combinaison",
779780
"iterations": "Itérations",
780781
"default_gems": "Gemmes par défaut",

schemas/translation.schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3200,6 +3200,9 @@
32003200
"item_added": {
32013201
"type": "string"
32023202
},
3203+
"item_removed": {
3204+
"type": "string"
3205+
},
32033206
"item_unique": {
32043207
"type": "string"
32053208
}
@@ -3214,6 +3217,7 @@
32143217
"no_results",
32153218
"showing_results",
32163219
"item_added",
3220+
"item_removed",
32173221
"item_unique"
32183222
]
32193223
},

ui/core/components/gear_picker/item_list.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -613,17 +613,6 @@ export default class ItemList<T extends ItemListType> {
613613
compareButton.value!.addEventListener('click', () => {
614614
const hasItem = checkHasItem();
615615
simUI.bt?.[hasItem ? 'removeItem' : 'addItem'](ItemSpec.create({ id: itemData.id }));
616-
617-
new Toast({
618-
delay: 1000,
619-
variant: 'success',
620-
body: (
621-
<>
622-
<strong>{itemData.name}</strong> was {hasItem ? <>removed from the batch</> : <>added to the batch</>}.
623-
</>
624-
),
625-
});
626-
// TODO: should we open the bulk sim UI or should we run in the background showing progress, and then sort the items in the picker?
627616
});
628617
}
629618
}

ui/core/components/individual_sim_ui/bulk/bulk_item_picker_group.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,28 @@ export default class BulkItemPickerGroup extends ContentBlock {
7777
picker.setItem(newItem);
7878
}
7979

80-
remove(idx: number) {
80+
remove(idx: number, silent = false) {
8181
const picker = this.pickers.get(idx);
8282
if (!picker) {
83-
new Toast({
84-
variant: 'error',
85-
body: 'Failed to remove item, please report this issue.',
86-
});
83+
if (!silent)
84+
new Toast({
85+
variant: 'error',
86+
body: 'Failed to remove item, please report this issue.',
87+
});
8788
return;
8889
}
8990

9091
picker.dispose();
9192
this.pickers.delete(idx);
9293

9394
if (!this.pickers.size) this.addEmptyElement();
95+
96+
if (!silent)
97+
new Toast({
98+
delay: 1000,
99+
variant: 'success',
100+
body: <>{i18n.t('bulk_tab.search.item_removed', { itemName: picker.item._item.name })}</>,
101+
});
94102
}
95103

96104
private addEmptyElement() {

ui/core/components/individual_sim_ui/bulk_tab.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,10 @@ export class BulkTab extends SimTab {
197197
// Clear all previously equipped items from the pickers
198198
for (const group of this.pickerGroups.values()) {
199199
if (group.has(-1)) {
200-
group.remove(-1);
200+
group.remove(-1, true);
201201
}
202202
if (group.has(-2)) {
203-
group.remove(-2);
203+
group.remove(-2, true);
204204
}
205205
}
206206

@@ -400,7 +400,7 @@ export class BulkTab extends SimTab {
400400
}
401401
});
402402
}
403-
removeItemByIndex(idx: number) {
403+
removeItemByIndex(idx: number, silent = false) {
404404
if (idx < 0 || this.items.length < idx || !this.items[idx]) {
405405
new Toast({
406406
variant: 'error',
@@ -419,15 +419,15 @@ export class BulkTab extends SimTab {
419419
if (!canEquipItem(equippedItem.item, this.simUI.player.getPlayerSpec(), slot)) return;
420420
const bulkSlot = getBulkItemSlotFromSlot(slot, this.playerCanDualWield);
421421
const group = this.pickerGroups.get(bulkSlot)!;
422-
group.remove(idx);
422+
group.remove(idx, silent);
423423
});
424424
this.itemsChangedEmitter.emit(TypedEvent.nextEventID());
425425
}
426426
}
427427

428428
clearItems() {
429429
for (let idx = 0; idx < this.items.length; idx++) {
430-
this.removeItemByIndex(idx);
430+
this.removeItemByIndex(idx, true);
431431
}
432432
this.items = new Array<ItemSpec>();
433433
this.itemsChangedEmitter.emit(TypedEvent.nextEventID());

0 commit comments

Comments
 (0)