Skip to content
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

[client] welcome message even if you've done quests #2481

Merged
merged 1 commit into from
Dec 13, 2024
Merged

Conversation

aymericdelab
Copy link
Collaborator

@aymericdelab aymericdelab commented Dec 13, 2024

Fixes #2479

Summary by CodeRabbit

  • New Features

    • The QuestsMenu component now fetches the count of unclaimed quests internally, enhancing its self-sufficiency.
    • The QuestsMenu is always displayed in the TopLeftNavigation, regardless of the unclaimed quests count.
  • Bug Fixes

    • Improved error handling in the navigation functions for better reliability.
  • UI Enhancements

    • Updated rendering logic for the QuestsMenu to show buttons based on loading and quest completion states.

Copy link

vercel bot commented Dec 13, 2024

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 Dec 13, 2024 1:14pm
eternum-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 13, 2024 1:14pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
eternum-landing ⬜️ Ignored (Inspect) Visit Preview Dec 13, 2024 1:14pm

Copy link
Contributor

coderabbitai bot commented Dec 13, 2024

Walkthrough

The changes in this pull request involve significant modifications to the QuestsMenu and TopLeftNavigation components. The QuestsMenu component now fetches the count of unclaimed quests internally, eliminating the need for the unclaimedQuestsCount prop. The rendering logic has been updated to display UI elements conditionally based on the loading state and quest completion. In TopLeftNavigation, the unclaimedQuestsCount variable has been removed, allowing the QuestsMenu to render unconditionally. Error handling improvements have also been made in navigation functions.

Changes

File Path Change Summary
client/src/ui/modules/navigation/QuestMenu.tsx Removed unclaimedQuestsCount prop; integrated internal fetching of unclaimed quests count; updated rendering logic for buttons and loading states.
client/src/ui/modules/navigation/TopLeftNavigation.tsx Removed unclaimedQuestsCount variable; updated QuestsMenu rendering to be unconditional; enhanced error handling in goToMapView.

Assessment against linked issues

Objective Addressed Explanation
Welcome message even if you've done quests (#2479) The changes do not address the welcome message feature.

Possibly related PRs

  • Add skip quest button #2083: The changes in the QuestInfo component regarding the addition of a "Skip quest" button are related to the modifications in the QuestsMenu component, which also involves UI elements for claiming and skipping quests.
  • balancing #2110: The changes in the TopLeftNavigation component, specifically the removal of the unclaimedQuestsCount variable and its impact on rendering the QuestsMenu, are directly related to the changes made in the QuestsMenu component.
  • improve top left navigation on mobile #2127: The modifications in the TopLeftNavigation component that enhance navigation and rendering logic may indirectly relate to the overall user experience when interacting with the QuestsMenu.
  • Remove quest UI while syncing #2449: The introduction of a loading state in the TopLeftNavigation that affects the visibility of the QuestsMenu is directly related to the changes made in the QuestsMenu component, which now relies on internal state management for rendering.

Suggested reviewers

  • bob0005
  • edisontim

🐰 In the land of quests, we hop with glee,
The menus now fetch, as quick as can be.
No more props to pass, just a simple call,
With buttons that shine, we’ll conquer them all!
So let’s claim our treasures, with joy and delight,
For every unclaimed quest, we’ll make it just right! 🌟


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

mentatbot bot commented Dec 13, 2024

You are out of MentatBot reviews. Your usage will refresh December 16 at 08:00 AM.

Copy link

Failed to generate code suggestions for PR

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Outside diff range and nitpick comments (3)
client/src/ui/modules/navigation/QuestMenu.tsx (3)

Line range hint 23-23: Consolidate duplicate world loading state.

The component fetches the same state twice from useWorldStore. Consider using a single variable to improve maintainability.

- const worldLoading = useWorldStore((state) => state.isWorldLoading);
- const isWorldLoading = useWorldStore((state) => state.isWorldLoading);
+ const isWorldLoading = useWorldStore((state) => state.isWorldLoading);

Also applies to: 37-37


Line range hint 44-57: Enhance error logging in claim handlers.

While the error handling is good, consider adding more context to error messages to aid debugging.

- console.error(`Failed to claim resources for quest ${currentQuest?.name}:`, error);
+ console.error(`Failed to claim resources for quest ${currentQuest?.name}. Quest ID: ${currentQuest?.id}, Prizes: ${currentQuest?.prizes.length}:`, error);

- console.error(`Failed to claim resources for quests:`, error);
+ console.error(`Failed to claim resources for quests. Total unclaimed: ${unclaimedQuests.length}, Total prizes: ${unclaimedQuests.flatMap((quest) => quest.prizes).length}:`, error);

Also applies to: 61-79


163-199: Extract skip quest buttons into a separate component.

The skip quest UI logic is complex enough to warrant its own component. This would improve readability and maintainability.

Consider extracting this into a SkipQuestButtons component:

interface SkipQuestButtonsProps {
  skipQuest: boolean;
  isLoading: boolean;
  onSkip: () => void;
  onCancel: () => void;
  onClaimAll: () => void;
  onClaim: () => void;
}

const SkipQuestButtons: React.FC<SkipQuestButtonsProps> = ({
  skipQuest,
  isLoading,
  onSkip,
  onCancel,
  onClaimAll,
  onClaim,
}) => {
  if (skipQuest) {
    return (
      <div className="flex flex-row gap-4">
        <Button
          className="text-sm font-semibold capitalize"
          onClick={onClaimAll}
          variant="red"
          disabled={isLoading}
        >
          {isLoading ? "Loading..." : "Skip All Quests"}
        </Button>
        {/* ... other buttons ... */}
      </div>
    );
  }
  
  return (
    <Button
      variant="primary"
      className="text-sm font-semibold capitalize w-6"
      onClick={onSkip}
      disabled={isLoading}
    >
      {isLoading ? "..." : "Skip"}
    </Button>
  );
};
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0f6fcc3 and 6317f8d.

📒 Files selected for processing (2)
  • client/src/ui/modules/navigation/QuestMenu.tsx (4 hunks)
  • client/src/ui/modules/navigation/TopLeftNavigation.tsx (1 hunks)
🔇 Additional comments (1)
client/src/ui/modules/navigation/TopLeftNavigation.tsx (1)

322-322: LGTM! Good error handling improvement.

The changes look good. The unconditional rendering of QuestsMenu aligns with the component's new internal state management, and the added error handling in goToMapView improves robustness.

>
{worldLoading ? "Loading..." : "Confirm"}
{worldLoading ? "Loading..." : "Claim"}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worldLoading has to be false now for the component to render, so we should remove these

@aymericdelab aymericdelab requested a review from bob0005 December 13, 2024 19:09
@bob0005 bob0005 merged commit 81e4e98 into next Dec 13, 2024
8 of 9 checks passed
@bob0005 bob0005 deleted the raschel/issue2479 branch December 13, 2024 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[client] welcome message even if you've done quests
2 participants