広場投稿追加画面の刷新 (#399) #413
@@ -7,7 +7,7 @@ import {
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react'
|
||||
import { useBlocker, useLocation } from 'react-router-dom'
|
||||
import { useLocation } from 'react-router-dom'
|
||||
|
||||
import { useDialogue } from '@/lib/dialogues/useDialogue'
|
||||
|
||||
@@ -65,31 +65,6 @@ export const UnsavedChangesGuardProvider: FC<PropsWithChildren> = ({ children })
|
||||
return true
|
||||
}, [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 (() => {
|
||||
bypassNextNavigationRef.current = false
|
||||
}, [location.hash, location.pathname, location.search])
|
||||
|
||||
新しい課題から参照
ユーザをブロックする