このコミットが含まれているのは:
@@ -7,7 +7,7 @@ import {
|
|||||||
useRef,
|
useRef,
|
||||||
useState,
|
useState,
|
||||||
} from 'react'
|
} from 'react'
|
||||||
import { useBlocker, useLocation } from 'react-router-dom'
|
import { useLocation } from 'react-router-dom'
|
||||||
|
|
||||||
import { useDialogue } from '@/lib/dialogues/useDialogue'
|
import { useDialogue } from '@/lib/dialogues/useDialogue'
|
||||||
|
|
||||||
@@ -65,31 +65,6 @@ export const UnsavedChangesGuardProvider: FC<PropsWithChildren> = ({ children })
|
|||||||
return true
|
return true
|
||||||
}, [dialogue, source])
|
}, [dialogue, source])
|
||||||
|
|
||||||
const blocker = useBlocker (() =>
|
|
||||||
source?.dirty === true && !(bypassNextNavigationRef.current))
|
|
||||||
|
|
||||||
useEffect (() => {
|
|
||||||
if (blocker.state !== 'blocked')
|
|
||||||
return
|
|
||||||
|
|
||||||
let cancelled = false
|
|
||||||
|
|
||||||
void (async () => {
|
|
||||||
const confirmed = await confirmDiscardNavigation ()
|
|
||||||
if (cancelled)
|
|
||||||
return
|
|
||||||
|
|
||||||
if (confirmed)
|
|
||||||
blocker.proceed ()
|
|
||||||
else
|
|
||||||
blocker.reset ()
|
|
||||||
}) ()
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
cancelled = true
|
|
||||||
}
|
|
||||||
}, [blocker, confirmDiscardNavigation])
|
|
||||||
|
|
||||||
useEffect (() => {
|
useEffect (() => {
|
||||||
bypassNextNavigationRef.current = false
|
bypassNextNavigationRef.current = false
|
||||||
}, [location.hash, location.pathname, location.search])
|
}, [location.hash, location.pathname, location.search])
|
||||||
|
|||||||
新しい課題から参照
ユーザをブロックする