Skip to content

Conversation

@Ilnur-Su
Copy link

@Ilnur-Su Ilnur-Su commented Oct 1, 2025


This Pull request Fixes #1369

Adding a loading screen and error message with a restart button.

Type of PR.

  • refactor
  • feature
  • bug fix
  • documentation
  • optimization
  • other

Description

Added loading and error state handling for the map:

  • Spinner during loading
  • Timeout (10 seconds) with error display if the map fails to load
  • Handling map error events with error output
  • UI screen for errors with a Reboot button to restart the map
  • Notifications via react-toastify

Related Issues

issue #1369

What this PR achieves

  • Added isLoading and hasError states
  • Handling map events (onLoad, onError)
  • Map loading timeout (useEffect)
  • Error display component (red screen with restart button)
  • "Reboot" button causes the map to reload

Screenshots

Loading Error

Снимок экрана 2025-10-02 в 00 40 03

Normal loading

Снимок экрана 2025-10-02 в 00 40 14

Rolled back the formatting of the <FullScreenMap.tsx> file to its previous appearance.  
There are no functional changes — the original design of the code has been returned, accidental format changes have been removed.
fix: bugs fixed after review(2)
@mikeschen mikeschen requested a review from Copilot October 28, 2025 01:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements loading and error handling for the GlobalMap component to fix issue #1369. The changes add visual feedback during map loading and provide a user-friendly error recovery mechanism when the map fails to load.

Key Changes

  • Added loading state with spinner and timeout mechanism (10 seconds)
  • Implemented error handling for map load failures with error event listener
  • Created error UI with reload functionality to recover from map errors

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


setIsLoading(false)
setHasError(false)

Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

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

Trailing whitespace on line 107 should be removed to maintain clean code formatting.

Suggested change

Copilot uses AI. Check for mistakes.

useEffect(() => {
if (!mapInstance) return
const handleError = (err: any) => {
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

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

The error parameter type is 'any' which bypasses type safety. Consider using a more specific type like 'Error' or 'MapboxError' if available from the map library.

Suggested change
const handleError = (err: any) => {
const handleError = (err: Error) => {

Copilot uses AI. Check for mistakes.
<div className='relative w-full h-full'>
<Map
{hasError && (
<div className="absolute inset-0 flex items-center justify-center bg-white/20 ">
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

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

Trailing space inside the className string should be removed for cleaner code.

Suggested change
<div className="absolute inset-0 flex items-center justify-center bg-white/20 ">
<div className="absolute inset-0 flex items-center justify-center bg-white/20">

Copilot uses AI. Check for mistakes.
</div>
)}

{!hasError &&<Map
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

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

Missing space between '&&' and '<Map' reduces readability. Add a space for proper formatting.

Suggested change
{!hasError &&<Map
{!hasError && <Map

Copilot uses AI. Check for mistakes.
)}
{children}
</Map>
</Map>}
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

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

[nitpick] The closing JSX brace should be on the same line as '' or properly indented on a new line for better readability.

Suggested change
</Map>}
</Map>
}

Copilot uses AI. Check for mistakes.
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.

missing loading screen on /maps

1 participant