-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/donkeys empty balance #2611
Conversation
* Fix missing arrival when sending lords & donkeys (#2594) * contracts: fix share points check * contracts: fix share points check * Add resource filter for contributions (#2596) * Add resource filter for contributions * Change % for specific resource contribution * Fix missing donkeys in bridge step 2 (#2598) * Fix missing donkeys in bridge step 2 * fix rerenders * Remove filter * Fix registration delay (#2602) * Fix registration delay * styling * Open popup on load * Add burned donkeys back (#2601) --------- Co-authored-by: Credence <[email protected]> Co-authored-by: Loaf <[email protected]>
* Fix missing arrival when sending lords & donkeys (#2594) * contracts: fix share points check * contracts: fix share points check * Add resource filter for contributions (#2596) * Add resource filter for contributions * Change % for specific resource contribution * Fix missing donkeys in bridge step 2 (#2598) * Fix missing donkeys in bridge step 2 * fix rerenders * Remove filter * Fix registration delay (#2602) * Fix registration delay * styling * Open popup on load * Add burned donkeys back (#2601) * im (#2604) --------- Co-authored-by: Credence <[email protected]> Co-authored-by: Loaf <[email protected]>
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe pull request introduces modifications to two files: Changes
Sequence DiagramsequenceDiagram
participant UI as Bridge Out UI
participant Hook as useDonkeyArrivals
participant Query as Donkey Queries
UI->>Hook: Request donkey information
Hook->>Query: Fetch donkey data
Query-->>Hook: Return donkey data
Hook->>Hook: Filter donkeys with positive balances
Hook-->>UI: Provide filtered donkey info
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Failed to generate code suggestions for PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
landing/src/hooks/helpers/useDonkeyArrivals.tsx (1)
Line range hint
97-104
: Optimize the accumulator to avoid performance overhead from the spread operator.
Using the spread syntax within a reduce accumulator can incur O(n^2) complexity. Consider mutating the accumulator object directly or using other approaches (e.g., pushing or assigning values) to avoid repetitive copying.- allResources.reduce( - (acc, r) => ({ - ...acc, - [r.resourceId]: (acc[r.resourceId] || 0) + r.amount / RESOURCE_PRECISION, - }), - {}, - ) + allResources.reduce((acc, r) => { + acc[r.resourceId] = (acc[r.resourceId] || 0) + r.amount / RESOURCE_PRECISION; + return acc; + }, {})landing/src/components/modules/bridge-out-step-2.tsx (1)
89-105
: Refactor from memoized to standard function.
Removing the memoization can simplify the code and keep logic consistent. However, if performance was a concern with frequent re-renders, it may be worth considering an alternative optimization strategy (e.g.,useCallback
) if the function is computationally heavy or triggered frequently.🧰 Tools
🪛 Biome (1.9.4)
[error] 99-99: Avoid the use of spread (
...
) syntax on accumulators.Spread syntax should be avoided on accumulators (like those in
.reduce
) because it causes a time complexity ofO(n^2)
.
Consider methods such as .splice or .push instead.(lint/performance/noAccumulatingSpread)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
landing/src/components/modules/bridge-out-step-2.tsx
(2 hunks)landing/src/hooks/helpers/useDonkeyArrivals.tsx
(2 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
landing/src/components/modules/bridge-out-step-2.tsx
[error] 99-99: Avoid the use of spread (...
) syntax on accumulators.
Spread syntax should be avoided on accumulators (like those in .reduce
) because it causes a time complexity of O(n^2)
.
Consider methods such as .splice or .push instead.
(lint/performance/noAccumulatingSpread)
🔇 Additional comments (3)
landing/src/hooks/helpers/useDonkeyArrivals.tsx (2)
37-37
: Consider the increased refetch interval carefully.
Increasing the refetchInterval
to 100,000 ms (from the previous 10,000 ms) will decrease the frequency of updates, potentially delaying the latest donkey information. Ensure that this aligns with the desired user experience.
112-114
: Confirm filtering logic for resource balances.
Filtering out donkey entries with zero balances is logical. Ensure that any donkey intended to be displayed, even if it lacks resources, is handled as desired outside this function. If zero-balance donkeys need display for user awareness, consider including them or surfacing a reason for their omission.
landing/src/components/modules/bridge-out-step-2.tsx (1)
115-115
: Consider re-adding dependencies if needed.
Not re-running this effect when selectedDonkeys
changes could allow for stale data in scenarios where donkey arrivals or states change. Verify whether this new behavior accurately reflects your intended logic.
* Fix/donkeys empty balance (#2611) * Merge into main (#2603) * Fix missing arrival when sending lords & donkeys (#2594) * contracts: fix share points check * contracts: fix share points check * Add resource filter for contributions (#2596) * Add resource filter for contributions * Change % for specific resource contribution * Fix missing donkeys in bridge step 2 (#2598) * Fix missing donkeys in bridge step 2 * fix rerenders * Remove filter * Fix registration delay (#2602) * Fix registration delay * styling * Open popup on load * Add burned donkeys back (#2601) --------- Co-authored-by: Credence <[email protected]> Co-authored-by: Loaf <[email protected]> * merge into main (#2605) * Fix missing arrival when sending lords & donkeys (#2594) * contracts: fix share points check * contracts: fix share points check * Add resource filter for contributions (#2596) * Add resource filter for contributions * Change % for specific resource contribution * Fix missing donkeys in bridge step 2 (#2598) * Fix missing donkeys in bridge step 2 * fix rerenders * Remove filter * Fix registration delay (#2602) * Fix registration delay * styling * Open popup on load * Add burned donkeys back (#2601) * im (#2604) --------- Co-authored-by: Credence <[email protected]> Co-authored-by: Loaf <[email protected]> * Fix build (#2610) * filter out donkeys w/ empty balance --------- Co-authored-by: Credence <[email protected]> Co-authored-by: Loaf <[email protected]> * add stats resources bridged on empire (#2618) * add resourcers bridged * change logo * remove looping gql calls (#2620) * remove looping gql calls * batch queries --------- Co-authored-by: Credence <[email protected]> Co-authored-by: Loaf <[email protected]> Co-authored-by: raschel <[email protected]>
* Fix/donkeys empty balance (#2611) * Merge into main (#2603) * Fix missing arrival when sending lords & donkeys (#2594) * contracts: fix share points check * contracts: fix share points check * Add resource filter for contributions (#2596) * Add resource filter for contributions * Change % for specific resource contribution * Fix missing donkeys in bridge step 2 (#2598) * Fix missing donkeys in bridge step 2 * fix rerenders * Remove filter * Fix registration delay (#2602) * Fix registration delay * styling * Open popup on load * Add burned donkeys back (#2601) --------- * merge into main (#2605) * Fix missing arrival when sending lords & donkeys (#2594) * contracts: fix share points check * contracts: fix share points check * Add resource filter for contributions (#2596) * Add resource filter for contributions * Change % for specific resource contribution * Fix missing donkeys in bridge step 2 (#2598) * Fix missing donkeys in bridge step 2 * fix rerenders * Remove filter * Fix registration delay (#2602) * Fix registration delay * styling * Open popup on load * Add burned donkeys back (#2601) * im (#2604) --------- * Fix build (#2610) * filter out donkeys w/ empty balance --------- * add stats resources bridged on empire (#2618) * add resourcers bridged * change logo * remove looping gql calls (#2620) * remove looping gql calls * batch queries --------- Co-authored-by: Loaf <[email protected]> Co-authored-by: Bob <[email protected]> Co-authored-by: Credence <[email protected]>
Summary by CodeRabbit