mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 15:06:20 +00:00
Merge pull request #240 from simoleo89/fix/room-widget-bugs
fix(room): name-bubble, pet-fertilize chat & word-quiz bugs
This commit is contained in:
@@ -361,7 +361,7 @@ const useAvatarInfoWidgetState = () =>
|
|||||||
{
|
{
|
||||||
let index = nameBubbles.findIndex(bubble => (bubble.roomIndex === event.id));
|
let index = nameBubbles.findIndex(bubble => (bubble.roomIndex === event.id));
|
||||||
|
|
||||||
if(index > -1) setNameBubbles(prevValue => prevValue.filter(bubble => (bubble.roomIndex === event.id)));
|
if(index > -1) setNameBubbles(prevValue => prevValue.filter(bubble => (bubble.roomIndex !== event.id)));
|
||||||
|
|
||||||
index = productBubbles.findIndex(bubble => (bubble.id === event.id));
|
index = productBubbles.findIndex(bubble => (bubble.id === event.id));
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ const useChatWidgetState = () =>
|
|||||||
|
|
||||||
if(chatType === RoomSessionChatEvent.CHAT_TYPE_PET_REBREED_FERTILIZE)
|
if(chatType === RoomSessionChatEvent.CHAT_TYPE_PET_REBREED_FERTILIZE)
|
||||||
{
|
{
|
||||||
textKey = 'widget.chatbubble.petrefertilized;';
|
textKey = 'widget.chatbubble.petrefertilized';
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(chatType === RoomSessionChatEvent.CHAT_TYPE_PET_SPEED_FERTILIZE)
|
else if(chatType === RoomSessionChatEvent.CHAT_TYPE_PET_SPEED_FERTILIZE)
|
||||||
@@ -162,7 +162,7 @@ const useChatWidgetState = () =>
|
|||||||
|
|
||||||
if(newRoomObject)
|
if(newRoomObject)
|
||||||
{
|
{
|
||||||
const newUserData = roomSession.userDataManager.getUserDataByIndex(roomObject.id);
|
const newUserData = roomSession.userDataManager.getUserDataByIndex(newRoomObject.id);
|
||||||
|
|
||||||
if(newUserData) targetUserName = newUserData.name;
|
if(newUserData) targetUserName = newUserData.name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,19 +112,21 @@ const useWordQuizWidgetState = () =>
|
|||||||
{
|
{
|
||||||
setUserAnswers(prevValue =>
|
setUserAnswers(prevValue =>
|
||||||
{
|
{
|
||||||
const keysToRemove: number[] = [];
|
if(prevValue.size === 0) return prevValue;
|
||||||
|
|
||||||
prevValue.forEach((value, key) =>
|
// Build new value objects + a new Map — don't decrement
|
||||||
|
// secondsLeft on the objects still referenced by prevValue
|
||||||
|
// (in-place mutation breaks memoization / StrictMode replay).
|
||||||
|
const next = new Map(prevValue);
|
||||||
|
|
||||||
|
next.forEach((value, key) =>
|
||||||
{
|
{
|
||||||
value.secondsLeft--;
|
const secondsLeft = value.secondsLeft - 1;
|
||||||
|
|
||||||
if(value.secondsLeft <= 0) keysToRemove.push(key);
|
if(secondsLeft <= 0) next.delete(key);
|
||||||
|
else next.set(key, { ...value, secondsLeft });
|
||||||
});
|
});
|
||||||
|
|
||||||
if(keysToRemove.length === 0) return prevValue;
|
|
||||||
|
|
||||||
const next = new Map(prevValue);
|
|
||||||
keysToRemove.forEach(key => next.delete(key));
|
|
||||||
return next;
|
return next;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user