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

Remove quest UI while syncing #2449

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions client/src/ui/modules/navigation/TopLeftNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useEntities, useEntitiesUtils } from "@/hooks/helpers/useEntities";
import { useQuery } from "@/hooks/helpers/useQuery";
import { useUnclaimedQuestsCount } from "@/hooks/helpers/useQuests";
import useUIStore from "@/hooks/store/useUIStore";
import { useWorldStore } from "@/hooks/store/useWorldLoading";
import useNextBlockTimestamp from "@/hooks/useNextBlockTimestamp";
import { soundSelector, useUiSounds } from "@/hooks/useUISound";
import { Position } from "@/types/Position";
Expand Down Expand Up @@ -96,6 +97,8 @@ const WorkersHutTooltipContent = () => {
export const TopLeftNavigation = memo(() => {
const { setup } = useDojo();

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

const { unclaimedQuestsCount } = useUnclaimedQuestsCount();
const { isMapView, handleUrlChange, hexPosition } = useQuery();
const { playerStructures } = useEntities();
Expand Down Expand Up @@ -321,10 +324,17 @@ export const TopLeftNavigation = memo(() => {
</motion.div>
<div className="relative">
<SecondaryMenuItems />
{unclaimedQuestsCount > 0 && (
<div className="absolute right-0 px-4 top-full mt-2">
<QuestsMenu unclaimedQuestsCount={unclaimedQuestsCount} />
{worldLoading ? (
<div className="absolute right-2 p-4 mt-2 top-full flex flex-row items-center justify-center bg-black/80 rounded-lg">
<img src="/images/eternumloader.png" className="w-10" />
<div className="ml-4">Quests are loading...</div>
</div>
) : (
unclaimedQuestsCount > 0 && (
<div className="absolute right-0 px-4 top-full mt-2">
<QuestsMenu unclaimedQuestsCount={unclaimedQuestsCount} />
</div>
)
Comment on lines +327 to +337
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance loading state accessibility and maintainability

While the loading state logic is correct, consider these improvements:

  1. Add proper accessibility attributes
  2. Use consistent styling approach
  3. Make the loading message more informative

Consider applying these changes:

 {worldLoading ? (
-  <div className="absolute right-2 p-4 mt-2 top-full flex flex-row items-center justify-center bg-black/80 rounded-lg">
-    <img src="/images/eternumloader.png" className="w-10" />
-    <div className="ml-4">Quests are loading...</div>
+  <div 
+    className="absolute right-2 px-4 mt-2 top-full flex flex-row items-center justify-center bg-black/80 rounded-lg"
+    role="status"
+    aria-live="polite"
+  >
+    <img 
+      src="/images/eternumloader.png" 
+      className="w-10" 
+      alt="Loading indicator"
+    />
+    <div className="ml-4">Synchronizing quest data with the realm...</div>
   </div>
 ) : (
   unclaimedQuestsCount > 0 && (
     <div className="absolute right-0 px-4 top-full mt-2">
       <QuestsMenu unclaimedQuestsCount={unclaimedQuestsCount} />
     </div>
   )
 )}
📝 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.

Suggested change
{worldLoading ? (
<div className="absolute right-2 p-4 mt-2 top-full flex flex-row items-center justify-center bg-black/80 rounded-lg">
<img src="/images/eternumloader.png" className="w-10" />
<div className="ml-4">Quests are loading...</div>
</div>
) : (
unclaimedQuestsCount > 0 && (
<div className="absolute right-0 px-4 top-full mt-2">
<QuestsMenu unclaimedQuestsCount={unclaimedQuestsCount} />
</div>
)
{worldLoading ? (
<div
className="absolute right-2 px-4 mt-2 top-full flex flex-row items-center justify-center bg-black/80 rounded-lg"
role="status"
aria-live="polite"
>
<img
src="/images/eternumloader.png"
className="w-10"
alt="Loading indicator"
/>
<div className="ml-4">Synchronizing quest data with the realm...</div>
</div>
) : (
unclaimedQuestsCount > 0 && (
<div className="absolute right-0 px-4 top-full mt-2">
<QuestsMenu unclaimedQuestsCount={unclaimedQuestsCount} />
</div>
)

)}
</div>
</div>
Expand Down
Loading