Skip to content

Commit

Permalink
Redirect to editor/posts page when starting a writing session
Browse files Browse the repository at this point in the history
  • Loading branch information
0xi4o committed Aug 27, 2024
1 parent 866bdfa commit fc69e13
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app/components/editor/writing-session-timer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from 'react'
import { Timer, TimerRenderer, useTimer } from 'react-use-precision-timer'

import { Form } from '@remix-run/react'
import { Form, useLocation, useNavigate } from '@remix-run/react'

import * as S from '@effect/schema/Schema'
import { PositiveInt } from '@evolu/common'
Expand Down Expand Up @@ -41,6 +41,7 @@ import {
TooltipTrigger,
} from '~/components/ui/tooltip'
import { useToast } from '~/components/ui/use-toast'
import { ROUTES } from '~/lib/constants'
import { AureliusContext, AureliusProviderData } from '~/lib/providers/aurelius'
import {
WritingSessionDialogProps,
Expand Down Expand Up @@ -109,9 +110,12 @@ const WritingSessionTimer = ({
writingSessionOpen,
writingSessionSettings,
}: WritingSessionTimerProps) => {
const { contentId, effortId, sessionTimer } =
const { contentId, effortId, handleSplashOpen, sessionTimer, splashOpen } =
useContext<AureliusProviderData>(AureliusContext)

const location = useLocation()
const navigate = useNavigate()

const [elapsedMinutes, setElapsedMinutes] = useState(0)
const [startingWordCount, setStartingWordCount] = useState(wordCount)

Expand Down Expand Up @@ -162,6 +166,12 @@ const WritingSessionTimer = ({
sessionTimer.start()
setWritingSessionOpen(false)
setWritingSessionStatus(WritingSessionStatus.RUNNING)
if (splashOpen) {
handleSplashOpen(false)
}
if (location.pathname !== ROUTES.EDITOR.POST) {
navigate(ROUTES.EDITOR.POST)
}
}

const stopWritingSession = () => {
Expand Down

0 comments on commit fc69e13

Please sign in to comment.