mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-15 07:34:42 -04: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
|
@ -22,7 +22,6 @@ import { DocumentBar } from './document-bar/document-bar'
|
||||||
import { ScrollingDocumentRenderPane } from './document-renderer-pane/scrolling-document-render-pane'
|
import { ScrollingDocumentRenderPane } from './document-renderer-pane/scrolling-document-render-pane'
|
||||||
import { EditorPane } from './editor-pane/editor-pane'
|
import { EditorPane } from './editor-pane/editor-pane'
|
||||||
import { editorTestContent } from './editorTestContent'
|
import { editorTestContent } from './editorTestContent'
|
||||||
import { useFirstDraw } from './hooks/useFirstDraw'
|
|
||||||
import { useViewModeShortcuts } from './hooks/useViewModeShortcuts'
|
import { useViewModeShortcuts } from './hooks/useViewModeShortcuts'
|
||||||
import { DualScrollState, ScrollState } from './scroll/scroll-props'
|
import { DualScrollState, ScrollState } from './scroll/scroll-props'
|
||||||
import { Splitter } from './splitter/splitter'
|
import { Splitter } from './splitter/splitter'
|
||||||
|
@ -45,7 +44,7 @@ export const Editor: React.FC = () => {
|
||||||
const { search } = useLocation()
|
const { search } = useLocation()
|
||||||
const untitledNote = t('editor.untitledNote')
|
const untitledNote = t('editor.untitledNote')
|
||||||
const markdownContent = useSelector((state: ApplicationState) => state.documentContent.content)
|
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 [documentTitle, setDocumentTitle] = useState(untitledNote)
|
||||||
const noteMetadata = useRef<YAMLMetaData>()
|
const noteMetadata = useRef<YAMLMetaData>()
|
||||||
const firstHeading = useRef<string>()
|
const firstHeading = useRef<string>()
|
||||||
|
@ -97,17 +96,15 @@ export const Editor: React.FC = () => {
|
||||||
|
|
||||||
useViewModeShortcuts()
|
useViewModeShortcuts()
|
||||||
|
|
||||||
const isFirstDraw = useFirstDraw()
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setNoteId(id)
|
setNoteId(id)
|
||||||
}, [id])
|
}, [id])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isFirstDraw && !isWide && editorMode === EditorMode.BOTH) {
|
if (!isWide && editorMode === EditorMode.BOTH) {
|
||||||
setEditorMode(EditorMode.PREVIEW)
|
setEditorMode(EditorMode.PREVIEW)
|
||||||
}
|
}
|
||||||
}, [editorMode, isFirstDraw, isWide])
|
}, [editorMode, isWide])
|
||||||
|
|
||||||
const onMarkdownRendererScroll = useCallback((newScrollState: ScrollState) => {
|
const onMarkdownRendererScroll = useCallback((newScrollState: ScrollState) => {
|
||||||
if (scrollSource.current === ScrollSource.RENDERER && editorSyncScroll) {
|
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…
Add table
Add a link
Reference in a new issue