Skip to content

Commit

Permalink
Set localstorage variable when splash dialog is first shown
Browse files Browse the repository at this point in the history
  • Loading branch information
0xi4o committed Aug 23, 2024
1 parent beb2f91 commit 48f0a40
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/components/editor/splash-dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormEvent, ReactNode, useContext } from 'react'
import { FormEvent, ReactNode, useContext, useEffect } from 'react'

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

Expand Down Expand Up @@ -100,6 +100,10 @@ const SplashDialog = ({
})
}

useEffect(() => {
localStorage.setItem('aurelius:splash_shown', 'true')
}, [])

// TODO: synced devices is not picking up the correct value initially. it changes after a bit but it should be instant? investigate why.

return (
Expand Down
6 changes: 5 additions & 1 deletion app/lib/providers/aurelius.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ const AureliusProvider = ({ children }: AureliusProviderProps) => {
const [latestPosts, setLatestPosts] = useState<ReadonlyArray<PostRow>>([])
const [mainMenuOpen, setMainMenuOpen] = useState(false)
const [preferencesOpen, setPreferencesOpen] = useState(false)
const [splashOpen, setSplashOpen] = useState(!!settings?.showSplashDialog)
const [splashOpen, setSplashOpen] = useState(
!(localStorage.getItem('aurelius:splash_shown') !== 'true')
? localStorage.getItem('aurelius:splash_shown') !== 'true'
: !!settings?.showSplashDialog
)
const [writingSessionOpen, setWritingSessionOpen] = useState(false)
const [writingSessionSettings, setWritingSessionSettings] =
useState<WritingSessionSettings>({
Expand Down
1 change: 1 addition & 0 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const App = ({ children }: { children: ReactNode }) => {

return () => {
document.head.removeChild(script)
localStorage.removeItem('aurelius:splash_shown')
}
}, [])

Expand Down

0 comments on commit 48f0a40

Please sign in to comment.