mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 14:32:15 -07:00
Minor changes
This commit is contained in:
parent
c31291e95a
commit
9f85845973
2 changed files with 9 additions and 14 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import React from 'react';
|
||||
import { useGameGuard } from 'hooks';
|
||||
import { RefreshGuardModal } from '../RefreshGuardModal/RefreshGuardModal';
|
||||
import React from "react";
|
||||
import { useGameGuard } from "hooks";
|
||||
import { RefreshGuardModal } from "../RefreshGuardModal/RefreshGuardModal";
|
||||
|
||||
interface RefreshGuardProviderProps {
|
||||
children: React.ReactNode;
|
||||
|
|
@ -8,28 +8,26 @@ interface RefreshGuardProviderProps {
|
|||
|
||||
/**
|
||||
* Provider component that wraps the entire app to provide refresh and navigation guarding.
|
||||
* Should be placed high in the component tree, ideally in AppShell.
|
||||
*/
|
||||
export const RefreshGuardProvider: React.FC<RefreshGuardProviderProps> = ({ children }) => {
|
||||
export const RefreshGuardProvider: React.FC<RefreshGuardProviderProps> = ({
|
||||
children,
|
||||
}) => {
|
||||
const {
|
||||
showNavigationModal,
|
||||
setShowNavigationModal,
|
||||
handleConfirmNavigation,
|
||||
handleCancelNavigation,
|
||||
navigationMessage,
|
||||
showRefreshModal,
|
||||
setShowRefreshModal,
|
||||
handleConfirmRefresh,
|
||||
handleCancelRefresh,
|
||||
refreshMessage,
|
||||
isInActiveGame,
|
||||
shouldGuard
|
||||
} = useGameGuard();
|
||||
|
||||
return (
|
||||
<>
|
||||
{children}
|
||||
|
||||
|
||||
{/* Custom modal for SPA navigation (React Router) */}
|
||||
<RefreshGuardModal
|
||||
open={showNavigationModal}
|
||||
|
|
@ -40,7 +38,7 @@ export const RefreshGuardProvider: React.FC<RefreshGuardProviderProps> = ({ chil
|
|||
confirmButtonText={isInActiveGame ? "Leave Game" : "Leave Anyway"}
|
||||
cancelButtonText="Stay"
|
||||
/>
|
||||
|
||||
|
||||
{/* Custom modal for browser refresh (after native dialog) */}
|
||||
<RefreshGuardModal
|
||||
open={showRefreshModal}
|
||||
|
|
@ -53,4 +51,4 @@ export const RefreshGuardProvider: React.FC<RefreshGuardProviderProps> = ({ chil
|
|||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -61,9 +61,6 @@ export const useNavigationGuard = ({
|
|||
return; // Skip navigation guard if Router is not available
|
||||
}
|
||||
|
||||
// Note: React Router v6 doesn't have built-in navigation blocking like v5
|
||||
// We'll implement a custom solution by intercepting link clicks and form submissions
|
||||
|
||||
const handleLinkClick = (event: Event) => {
|
||||
const target = event.target as HTMLElement;
|
||||
const link = target.closest('a');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue