-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add discord invite button #1985
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
You are out of MentatBot reviews. Your usage will refresh November 11 at 08:00 AM. |
WalkthroughThe changes in this pull request introduce a new Discord image path in the Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
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: 1
🧹 Outside diff range and nitpick comments (5)
client/src/ui/modules/navigation/TopNavigation.tsx (1)
3-3
: Consider documenting the UI reorganization rationale.Moving the SettingsWindow from SecondaryMenuItems to TopNavigation represents a significant UI structure change. Please document:
- Why this reorganization was necessary
- How it improves the user experience
- Whether this impacts the visibility and accessibility of settings
This documentation will help maintain architectural consistency in future UI changes.
Also applies to: 14-14
client/src/ui/config.tsx (1)
Line range hint
5-21
: Improve error handling in device detection.The current implementation has several potential issues:
- Setting
LOW_GRAPHICS_FLAG
to "true" by default might unnecessarily degrade performance on capable devices- Setting
INITIAL_LAPTOP_CHECK
prevents retrying on subsequent page loads- Users aren't notified of detection failures
Consider this improved implementation:
const checkIfGameIsRunningOnLaptop = async () => { - if (!localStorage.getItem("INITIAL_LAPTOP_CHECK")) { - try { - const battery = await (navigator as any).getBattery(); - if (battery.charging && battery.chargingTime === 0) { - // It's likely a desktop - localStorage.setItem("LOW_GRAPHICS_FLAG", "false"); - } else { - // It's likely a laptop or mobile device - localStorage.setItem("LOW_GRAPHICS_FLAG", "true"); - } - } catch (error) { - console.error("Error calling getBattery():", error); - // Set default values if getBattery() is not supported - localStorage.setItem("LOW_GRAPHICS_FLAG", "true"); - } finally { - localStorage.setItem("INITIAL_LAPTOP_CHECK", "true"); - } + try { + // Check if battery API is supported + if (!('getBattery' in navigator)) { + throw new Error('Battery API not supported'); + } + + const battery = await (navigator as any).getBattery(); + const isDesktop = battery.charging && battery.chargingTime === 0; + + localStorage.setItem("LOW_GRAPHICS_FLAG", (!isDesktop).toString()); + return !isDesktop; + } catch (error) { + console.warn("Device detection failed:", error); + // Keep existing setting if available + const existing = localStorage.getItem("LOW_GRAPHICS_FLAG"); + if (existing === null) { + // Default to system memory as fallback + const lowMemory = (navigator as any).deviceMemory < 4; + localStorage.setItem("LOW_GRAPHICS_FLAG", lowMemory.toString()); + return lowMemory; + } + return existing === "true"; } - return localStorage.getItem("LOW_GRAPHICS_FLAG") === "true"; };client/src/ui/modules/navigation/SecondaryMenuItems.tsx (1)
90-96
: Consider enhancing the Discord button implementation.While the implementation meets the basic requirement, consider these improvements:
- Move the Discord URL to a configuration file for easier maintenance
- Add error handling for the window.open call
- Add aria-label for better accessibility
<CircleButton tooltipLocation="bottom" image={BuildingThumbs.discord} label={"Discord"} size="lg" - onClick={() => window.open("https://discord.gg/realmsworld")} + aria-label="Join our Discord community for support" + onClick={() => { + try { + window.open(DISCORD_INVITE_URL, '_blank')?.focus(); + } catch (error) { + console.error('Failed to open Discord link:', error); + } + }} />client/src/ui/modules/settings/Settings.tsx (2)
Line range hint
91-116
: Improve graphics settings toggle implementation.The current implementation has several areas for improvement:
- Window reload creates a jarring user experience
- No loading state or user warning about the page reload
- Missing error handling for localStorage operations
Consider applying these improvements:
<Button disabled={!!isLowGraphics} variant={isLowGraphics ? "success" : "outline"} onClick={() => { if (!isLowGraphics) { + if (!confirm('Changing graphics settings requires a page reload. Continue?')) { + return; + } + try { localStorage.setItem("LOW_GRAPHICS_FLAG", "true"); + } catch (error) { + toast.error("Failed to save graphics settings"); + return; + } + toast.info("Reloading with new graphics settings..."); window.location.reload(); } }} > - Low + {isLowGraphics ? "Low (Active)" : "Low"} </Button>Similar changes should be applied to the High graphics button.
Line range hint
146-152
: Add Discord support button as per PR objectives.The PR's main objective is to add a Discord support button, but it's missing from the social links section. Consider adding it alongside the existing Realms.World and Dojo links.
Add the Discord button:
<div className="flex py-3 space-x-3"> <a target="_blank" href="https://realms.world"> <RealmsWorld className="w-16" /> </a> <a href="https://www.dojoengine.org/en/"> <DojoMark className="w-16" /> </a> + <a href="https://discord.gg/realmsworld" target="_blank" rel="noopener noreferrer"> + <Button variant="outline" className="!py-1"> + Support + </Button> + </a> </div>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
client/public/images/buildings/thumb/discord.png
is excluded by!**/*.png
📒 Files selected for processing (4)
client/src/ui/config.tsx
(1 hunks)client/src/ui/modules/navigation/SecondaryMenuItems.tsx
(3 hunks)client/src/ui/modules/navigation/TopNavigation.tsx
(2 hunks)client/src/ui/modules/settings/Settings.tsx
(1 hunks)
🔇 Additional comments (6)
client/src/ui/modules/navigation/TopNavigation.tsx (1)
3-3
: Verify the Discord button implementation.
While these changes reorganize the UI by moving the SettingsWindow component, I don't see the implementation of the Discord 'Support' button mentioned in the PR objectives. Please clarify how these changes relate to the Discord integration.
Also applies to: 14-14
client/src/ui/config.tsx (2)
72-72
: LGTM: Discord image path added correctly.
The addition follows the established pattern in BuildingThumbs and supports the PR objective of adding a Discord support button.
72-72
: Verify Discord image exists.
Let's ensure the Discord image is present in the repository.
✅ Verification successful
Discord image is correctly placed and accessible ✅
The image file exists at the expected location: client/public/images/buildings/thumb/discord.png
, which matches the configured path in the code.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify Discord image exists
# Expected: File exists at the specified path
fd -t f "discord.png" public/images/buildings/thumb/
Length of output: 170
Script:
#!/bin/bash
# Let's first check if the image exists in any directory
fd -t f "discord.png"
# Also check the directory structure for images/buildings
fd -t d "buildings"
# And check for any thumb directories
fd -t d "thumb"
Length of output: 272
client/src/ui/modules/navigation/SecondaryMenuItems.tsx (1)
76-76
: Verify the impact of removed quest dependencies.
The removal of quest-related dependencies might affect the component's reactivity to quest state changes.
✅ Verification successful
Based on the search results, I can now generate the final response. The codebase analysis shows that the removal of quest-related dependencies from SecondaryMenuItems.tsx is safe because:
- The component still maintains the necessary quest-related hooks (
useQuests
anduseUnclaimedQuestsCount
) - The removed
selectedQuest
dependency was not being used in the component's logic - The changes align with the PR's objective of adding a Discord invite button and simplifying the component
Dependency cleanup is safe and aligned with changes
The removal of quest-related dependencies from the useEffect's dependency array is correct as these dependencies are no longer used in the component's logic after the quest-related state management cleanup.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any remaining quest-related state usage that might be affected
rg -A 3 "selectedQuest" --type tsx
Length of output: 62
Script:
#!/bin/bash
# Search for any remaining quest-related state usage with correct file extension
rg -A 3 "selectedQuest" --type ts --type tsx --type jsx --type js
# Also check for any quest-related hooks or state management
rg -A 3 "useQuest|questState" --type ts --type tsx --type jsx --type js
# Look for the component's implementation to understand the context better
rg -A 10 "SecondaryMenuItems" --type ts --type tsx --type jsx --type js
Length of output: 295
Script:
#!/bin/bash
# Search for any remaining quest-related state usage without file type restrictions
rg -A 3 "selectedQuest"
# Also check for any quest-related hooks or state management
rg -A 3 "useQuest|questState"
# Look for the component's implementation to understand the context
rg -A 10 "SecondaryMenuItems"
Length of output: 28149
client/src/ui/modules/settings/Settings.tsx (2)
14-14
: LGTM: Import changes are well-organized.
The imports are logically grouped and the new IS_LOW_GRAPHICS_ENABLED
constant is appropriately placed with other configuration imports.
Also applies to: 22-22
Line range hint 146-152
: Verify Discord button implementation location.
The AI summary indicates that the Discord button was added to the SecondaryMenuItems
component, but we're suggesting adding it to the Settings component. Please clarify the intended location for the Discord button to ensure consistent implementation.
Let's verify the current implementation:
<CircleButton | ||
tooltipLocation="bottom" | ||
active={isPopupOpen(settings)} | ||
image={BuildingThumbs.settings} | ||
label={"Settings"} | ||
label={"Support"} |
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.
Reconsider labeling the Settings button as "Support".
This change creates potential user confusion:
- The button still triggers settings functionality but is labeled "Support"
- Having both a Discord button and a "Support" button might confuse users about where to seek help
- label={"Support"}
+ label={"Settings"}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
label={"Support"} | |
label={"Settings"} |
Closes #1957
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Refactor
SecondaryMenuItems
component by removing unused state management related to quests.Style