diff --git a/src/core/local-disk/use-local-disk.hook.ts b/src/core/local-disk/use-local-disk.hook.ts index b5acf272..5c127b7f 100644 --- a/src/core/local-disk/use-local-disk.hook.ts +++ b/src/core/local-disk/use-local-disk.hook.ts @@ -13,7 +13,7 @@ const DEFAULT_FILE_EXTENSION = 'qm'; const DEFAULT_EXTENSION_DESCRIPTION = 'quick mock'; export const useLocalDisk = () => { - const { fullDocument, loadDocument, fileName, setFileName } = + const { fullDocument, loadDocument, fileName, setFileName, setIsFileLoaded } = useCanvasContext(); const serializeShapes = (): string => { @@ -72,6 +72,7 @@ export const useLocalDisk = () => { } }; reader.readAsText(file); + setIsFileLoaded(true); }; const handleLoad = () => { diff --git a/src/core/providers/canvas/canvas.model.ts b/src/core/providers/canvas/canvas.model.ts index 6ec874d7..c42e333b 100644 --- a/src/core/providers/canvas/canvas.model.ts +++ b/src/core/providers/canvas/canvas.model.ts @@ -110,4 +110,6 @@ export interface CanvasContextModel { setIsThumbnailContextMenuVisible: React.Dispatch< React.SetStateAction >; + isFileLoaded: boolean; + setIsFileLoaded: React.Dispatch>; } diff --git a/src/core/providers/canvas/canvas.provider.tsx b/src/core/providers/canvas/canvas.provider.tsx index e6a0ba56..2492cc8f 100644 --- a/src/core/providers/canvas/canvas.provider.tsx +++ b/src/core/providers/canvas/canvas.provider.tsx @@ -25,6 +25,7 @@ export const CanvasProvider: React.FC = props => { const [fileName, setFileName] = React.useState(''); const [isThumbnailContextMenuVisible, setIsThumbnailContextMenuVisible] = React.useState(false); + const [isFileLoaded, setIsFileLoaded] = React.useState(false); const { addSnapshot, @@ -331,6 +332,8 @@ export const CanvasProvider: React.FC = props => { activePageIndex: document.activePageIndex, isThumbnailContextMenuVisible, setIsThumbnailContextMenuVisible, + isFileLoaded, + setIsFileLoaded, }} > {children} diff --git a/src/scenes/main.scene.tsx b/src/scenes/main.scene.tsx index c25929b3..8e5c05e7 100644 --- a/src/scenes/main.scene.tsx +++ b/src/scenes/main.scene.tsx @@ -14,11 +14,15 @@ import { PropertiesPod } from '@/pods/properties'; import { FooterPod } from '@/pods/footer/footer.pod'; import { ThumbPagesPod } from '@/pods/thumb-pages'; import { useAccordionSectionVisibility } from './accordion-section-visibility.hook'; +import { useCanvasContext } from '@/core/providers'; export const MainScene = () => { const { isThumbPagesPodOpen, thumbPagesPodRef } = useAccordionSectionVisibility(); + const { isFileLoaded } = useCanvasContext(); + const forceOpenThumbsPages = isFileLoaded && { open: true }; + return ( @@ -27,6 +31,7 @@ export const MainScene = () => { className={classes.container} name="toolsLeft" ref={thumbPagesPodRef} + {...forceOpenThumbsPages} > Pages