🐛 fix the export dialogue
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { ExportDialog } from './components/Export/ExportDialog'
|
||||
import type { ExportOptions } from './components/Export/ExportDialog'
|
||||
import { FileTree } from './components/FileTree/FileTree'
|
||||
@@ -58,6 +58,7 @@ export default function App(): JSX.Element {
|
||||
const [isFirstRun, setIsFirstRun] = useState(false)
|
||||
const [focusPeek, setFocusPeek] = useState(false)
|
||||
const [projectTitle, setProjectTitle] = useState('')
|
||||
const menuHandlerRef = useRef<((action: string) => Promise<void>) | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (!focusMode) {
|
||||
@@ -99,8 +100,7 @@ export default function App(): JSX.Element {
|
||||
}, [])
|
||||
|
||||
// Handle menu actions sent from the main process
|
||||
useEffect(() => {
|
||||
return window.api.onMenuAction(async (action) => {
|
||||
menuHandlerRef.current = async (action: string): Promise<void> => {
|
||||
if (action === 'save') {
|
||||
if (activeFilePath && isDirty) {
|
||||
await window.api.writeFile(activeFilePath, activeFileContent)
|
||||
@@ -140,8 +140,11 @@ export default function App(): JSX.Element {
|
||||
} else if (action === 'exportProjectPDF') {
|
||||
setExportOpen(true)
|
||||
}
|
||||
})
|
||||
}, [activeFilePath, isDirty, activeFileContent, fontSize])
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
return window.api.onMenuAction((action) => menuHandlerRef.current?.(action))
|
||||
}, [])
|
||||
|
||||
// Handle Cmd+S / Ctrl+S and Cmd+Shift+F / Ctrl+Shift+F
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user