Skip to content

Commit

Permalink
fix(fe): comment out popstate (#2233)
Browse files Browse the repository at this point in the history
* fix(fe): clearly stated the pushState url

* fix(fe): fix url

* fix(fe): remove popstate

* chore(fe): add TODO
  • Loading branch information
Kohminchae authored Nov 23, 2024
1 parent b71e24a commit 4ed9e3e
Showing 1 changed file with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default function Editor({
)
const { currentModal, showSignIn } = useAuthModalStore((state) => state)
const [showModal, setShowModal] = useState<boolean>(false)
const pushed = useRef(false)
//const pushed = useRef(false)
const whereToPush = useRef('')
const isModalConfrimed = useRef(false)

Expand All @@ -102,7 +102,7 @@ export default function Editor({
? `/contest/${contestId}/problem/${problem.id}/submission/${submissionId}`
: `/problem/${problem.id}/submission/${submissionId}`
router.replace(href as Route)
window.history.pushState(null, '', '')
//window.history.pushState(null, '', window.location.href)
if (submission.result === 'Accepted') {
confetti?.addConfetti()
}
Expand Down Expand Up @@ -249,22 +249,26 @@ export default function Editor({
contestId
)

const handlePopState = () => {
if (!checkSaved()) {
whereToPush.current = contestId ? `/contest/${contestId}` : '/problem'
setShowModal(true)
} else window.history.back()
}
if (!pushed.current) {
window.history.pushState(null, '', '')
pushed.current = true
}
// TODO: 배포 후 뒤로 가기 로직 재구현

// const handlePopState = () => {
// if (!checkSaved()) {
// whereToPush.current = contestId
// ? `/contest/${contestId}/problem`
// : '/problem'
// setShowModal(true)
// } else window.history.back()
// }
// if (!pushed.current) {
// window.history.pushState(null, '', window.location.href)
// pushed.current = true
// }
window.addEventListener('beforeunload', handleBeforeUnload)
window.addEventListener('popstate', handlePopState)
//window.addEventListener('popstate', handlePopState)

return () => {
window.removeEventListener('beforeunload', handleBeforeUnload)
window.removeEventListener('popstate', handlePopState)
//window.removeEventListener('popstate', handlePopState)
}
}, [])

Expand Down

0 comments on commit 4ed9e3e

Please sign in to comment.