Closed aymericdelab closed 3 months ago
The latest updates on your projects. Learn more about Vercel for Git โ๏ธ
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
eternum | โ Ready (Inspect) | Visit Preview | ๐ฌ Add feedback | Jun 20, 2024 1:57pm |
โฑ๏ธ Estimated effort to review [1-5] | 4 |
๐งช Relevant tests | No |
๐ Security concerns | No |
โก Key issues to review |
Possible Bug: The useArmyAnimation hook in useArmyAnimation.tsx uses the position object directly in the dependency array of useEffect . This could lead to excessive re-renders or unexpected behavior if the position object is recreated on each render. Consider using destructured properties of position or memoizing the object. |
Performance Concern: The useArmyAnimation hook also plays a sound effect every time the army moves. This could lead to performance issues or a poor user experience if the sound effect is too frequent or too loud. Consider adding conditions to limit when the sound is played. | |
Code Clarity: In ArmyHitBox.tsx , the onRightClick function is complex and does multiple things (setting selected entity and playing sounds). It might be beneficial to split this into smaller, more focused functions. |
Category | Suggestion | Score |
Enhancement |
Add error handling for sound playback to enhance application robustness___ **Consider adding error handling or a fallback mechanism for the sound playback functions tohandle cases where the sound file might not load or play correctly. This can prevent the application from crashing or behaving unexpectedly due to audio issues.** [client/src/hooks/useUISound.tsx [83-87]](https://github.com/BibliothecaDAO/eternum/pull/966/files#diff-ed5fa149d5d1bf0c1b193d171a333e40fbab6f8043d4ecb30f9236761b83675fR83-R87) ```diff const repeat = useCallback(() => { if (sound) { sound.loop(true); play(); + } else { + console.error("Failed to load sound"); + // Optionally, implement a fallback sound or handle the error appropriately } }, [sound, play]); ``` Suggestion importance[1-10]: 8Why: Adding error handling for sound playback is a good enhancement to prevent the application from crashing or behaving unexpectedly due to audio issues. This suggestion is contextually accurate and improves the robustness of the application. | 8 |
Check if
___
**Consider checking if | 6 | |
Best practice |
Improve type safety by specifying a more accurate type for event parameters___ **Use a more specific type for the event parameter in event handlers to provide better typesafety and to take advantage of TypeScript's type checking.** [client/src/ui/components/worldmap/armies/ArmyHitBox.tsx [39]](https://github.com/BibliothecaDAO/eternum/pull/966/files#diff-2dd1c84f2d9bb67d297d72c8c18345fa06b591e9f2ab0eae41c55f09407d7a35R39-R39) ```diff -const onPointerEnter = useCallback((e: any) => { +const onPointerEnter = useCallback((e: React.PointerEvent) => { e.stopPropagation(); }, []); ``` Suggestion importance[1-10]: 7Why: Using a more specific type for the event parameter in event handlers improves type safety and leverages TypeScript's type checking. This is a best practice that enhances code quality and maintainability. | 7 |
Possible bug |
Initialize
___
**Initialize | 5 |
PR Type
Enhancement, Bug fix
Description
WarriorModel
with hover effects and props.Army
component to pass props and manage animation.ArmyHitBox
component.hoveredHexRef
in event handler.Changes walkthrough ๐
8 files
_mapStore.tsx
Add travelPaths state to map store slice.
client/src/hooks/store/_mapStore.tsx - Added `travelPaths` state to the map store slice.
useUISound.tsx
Add new sound hooks and selectors for army actions.
client/src/hooks/useUISound.tsx
repeat
method for looping sounds.WarriorModel.tsx
Enhance WarriorModel with hover effects and props.
client/src/ui/components/models/armies/WarriorModel.tsx
WarriorModelProps
type.ArmyHitBox
component.Army.tsx
Update Army component to pass props and manage animation.
client/src/ui/components/worldmap/armies/Army.tsx
useArmyAnimation
hook call to includeisMine
.army
prop toWarriorModel
.ArmyHitBox.tsx
Add sound effects and refactor ArmyHitBox component.
client/src/ui/components/worldmap/armies/ArmyHitBox.tsx
hovered
state from props.useArmyAnimation.tsx
Add marching sound effect to army animation.
client/src/ui/components/worldmap/armies/useArmyAnimation.tsx
HexLayers.tsx
Add mouse event handlers for click and drag actions.
client/src/ui/components/worldmap/hexagon/HexLayers.tsx - Added mouse event handlers to manage click and drag actions.
HoveredHexagon.tsx
Add shovel sound effect on travel path detection.
client/src/ui/components/worldmap/hexagon/HoveredHexagon.tsx - Added shovel sound effect when a travel path is detected.
1 files
useEventHandlers.tsx
Add null check for hoveredHexRef in event handler.
client/src/ui/components/worldmap/hexagon/useEventHandlers.tsx - Added null check for `hoveredHexRef` in `handleArmyActionClick`.