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