mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-30 00:50:50 +01:00
Update badges again
This commit is contained in:
parent
69e21b3e6e
commit
b479210aca
@ -61,13 +61,26 @@ const useInventoryBadgesState = () =>
|
|||||||
useMessageEvent<BadgesEvent>(BadgesEvent, event =>
|
useMessageEvent<BadgesEvent>(BadgesEvent, event =>
|
||||||
{
|
{
|
||||||
const parser = event.getParser();
|
const parser = event.getParser();
|
||||||
const newBadgeCodes = parser.getAllBadgeCodes();
|
const badgesToAdd: string[] = [];
|
||||||
const newBadgeIds: number[] = [];
|
|
||||||
|
|
||||||
for(const newBadgeCode of newBadgeCodes) newBadgeIds.push(parser.getBadgeId(newBadgeCode));
|
setBadgeIds(prevValue =>
|
||||||
|
{
|
||||||
|
const newValue = [ ...prevValue ];
|
||||||
|
|
||||||
setBadgeCodes(prevValue => [ ...prevValue, ...newBadgeCodes ]);
|
parser.getAllBadgeCodes().forEach(code =>
|
||||||
setBadgeIds(prevValue => [ ...prevValue, ...newBadgeIds ]);
|
{
|
||||||
|
const badgeId = parser.getBadgeId(code);
|
||||||
|
|
||||||
|
if(newValue.indexOf(badgeId) >= 0) return;
|
||||||
|
|
||||||
|
newValue.push(badgeId);
|
||||||
|
badgesToAdd.push(code);
|
||||||
|
});
|
||||||
|
|
||||||
|
return newValue;
|
||||||
|
});
|
||||||
|
|
||||||
|
setBadgeCodes(prevValue => [ ...prevValue, ...badgesToAdd ]);
|
||||||
setActiveBadgeCodes(parser.getActiveBadgeCodes());
|
setActiveBadgeCodes(parser.getActiveBadgeCodes());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user