Skip to content
Merged
Changes from 1 commit
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
12 changes: 6 additions & 6 deletions apps/webpanel/src/pages/setup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect } from 'react';
import { useState, useEffect, useRef } from 'react';
import { Server } from 'lucide-react';
import { cn } from '@fxmanager/ui/lib/utils';

Expand All @@ -23,9 +23,8 @@ export function SetupApp() {
resourcePath: '',
adminGroups: [],
});

const [isExiting, setIsExiting] = useState(false);
const [loading, setLoading] = useState(false);
const isExitingRef = useRef(false);

function setError(message: string) {
toast.error('An error occured', {
Expand Down Expand Up @@ -93,15 +92,16 @@ export function SetupApp() {
}

function handleExit() {
setIsExiting(true);
isExitingRef.current = true;
setTimeout(() => {
window.location.href = '/';
}, 0);
}, 10);
}

useEffect(() => {
const handleBeforeUnload = (event: BeforeUnloadEvent) => {
if (isExiting && step === 'import') {
console.log('beforeunload', step, isExitingRef.current);
Comment thread
Maximus7474 marked this conversation as resolved.
Resolved
if (isExitingRef.current) {
return;
}
event.preventDefault();
Expand Down
Loading