mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-03-11 08:51:45 +00:00
Remove first draw hook
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
parent
23a1e30c3a
commit
6dc6adf270
2 changed files with 3 additions and 23 deletions
src/components/editor
|
@ -22,7 +22,6 @@ import { DocumentBar } from './document-bar/document-bar'
|
|||
import { ScrollingDocumentRenderPane } from './document-renderer-pane/scrolling-document-render-pane'
|
||||
import { EditorPane } from './editor-pane/editor-pane'
|
||||
import { editorTestContent } from './editorTestContent'
|
||||
import { useFirstDraw } from './hooks/useFirstDraw'
|
||||
import { useViewModeShortcuts } from './hooks/useViewModeShortcuts'
|
||||
import { DualScrollState, ScrollState } from './scroll/scroll-props'
|
||||
import { Splitter } from './splitter/splitter'
|
||||
|
@ -45,7 +44,7 @@ export const Editor: React.FC = () => {
|
|||
const { search } = useLocation()
|
||||
const untitledNote = t('editor.untitledNote')
|
||||
const markdownContent = useSelector((state: ApplicationState) => state.documentContent.content)
|
||||
const isWide = useMedia({ minWidth: 576 })
|
||||
const isWide = useMedia({ minWidth: 576 }, true)
|
||||
const [documentTitle, setDocumentTitle] = useState(untitledNote)
|
||||
const noteMetadata = useRef<YAMLMetaData>()
|
||||
const firstHeading = useRef<string>()
|
||||
|
@ -97,17 +96,15 @@ export const Editor: React.FC = () => {
|
|||
|
||||
useViewModeShortcuts()
|
||||
|
||||
const isFirstDraw = useFirstDraw()
|
||||
|
||||
useEffect(() => {
|
||||
setNoteId(id)
|
||||
}, [id])
|
||||
|
||||
useEffect(() => {
|
||||
if (!isFirstDraw && !isWide && editorMode === EditorMode.BOTH) {
|
||||
if (!isWide && editorMode === EditorMode.BOTH) {
|
||||
setEditorMode(EditorMode.PREVIEW)
|
||||
}
|
||||
}, [editorMode, isFirstDraw, isWide])
|
||||
}, [editorMode, isWide])
|
||||
|
||||
const onMarkdownRendererScroll = useCallback((newScrollState: ScrollState) => {
|
||||
if (scrollSource.current === ScrollSource.RENDERER && editorSyncScroll) {
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
export const useFirstDraw = ():boolean => {
|
||||
const [firstDraw, setFirstDraw] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
setFirstDraw(false)
|
||||
}, [])
|
||||
|
||||
return firstDraw
|
||||
}
|
Loading…
Reference in a new issue