@@ -5,7 +5,6 @@ import { BlockNodeModel } from "@/app/block/blocktypes";
55import { Button } from "@/app/element/button" ;
66import { CopyButton } from "@/app/element/copybutton" ;
77import { CenteredDiv } from "@/app/element/quickelems" ;
8- import { TypeAheadModal } from "@/app/modals/typeaheadmodal" ;
98import { ContextMenuModel } from "@/app/store/contextmenu" ;
109import { tryReinjectKey } from "@/app/store/keymodel" ;
1110import { RpcApi } from "@/app/store/wshclientapi" ;
@@ -18,7 +17,7 @@ import * as services from "@/store/services";
1817import * as WOS from "@/store/wos" ;
1918import { getWebServerEndpoint } from "@/util/endpoints" ;
2019import { goHistory , goHistoryBack , goHistoryForward } from "@/util/historyutil" ;
21- import { adaptFromReactOrNativeKeyEvent , checkKeyPressed , keydownWrapper } from "@/util/keyutil" ;
20+ import { adaptFromReactOrNativeKeyEvent , checkKeyPressed } from "@/util/keyutil" ;
2221import { addOpenMenuItems } from "@/util/previewutil" ;
2322import { base64ToString , fireAndForget , isBlank , jotaiLoadableValue , makeConnRoute , stringToBase64 } from "@/util/util" ;
2423import { formatRemoteUri } from "@/util/waveutil" ;
@@ -28,7 +27,7 @@ import { Atom, atom, Getter, PrimitiveAtom, useAtom, useAtomValue, useSetAtom, W
2827import { loadable } from "jotai/utils" ;
2928import type * as MonacoTypes from "monaco-editor/esm/vs/editor/editor.api" ;
3029import { OverlayScrollbarsComponent } from "overlayscrollbars-react" ;
31- import { createRef , memo , useCallback , useEffect , useMemo , useState } from "react" ;
30+ import { createRef , memo , useCallback , useEffect , useMemo } from "react" ;
3231import { TransformComponent , TransformWrapper , useControls } from "react-zoom-pan-pinch" ;
3332import { CSVView } from "./csvview" ;
3433import { DirectoryPreview } from "./directorypreview" ;
@@ -1073,17 +1072,17 @@ function PreviewView({
10731072 model : PreviewModel ;
10741073} ) {
10751074 const connStatus = useAtomValue ( model . connStatus ) ;
1076- const filePath = useAtomValue ( model . metaFilePath ) ;
10771075 const [ errorMsg , setErrorMsg ] = useAtom ( model . errorMsgAtom ) ;
10781076 const connection = useAtomValue ( model . connectionImmediate ) ;
10791077 const fileInfo = useAtomValue ( model . statFile ) ;
10801078
10811079 useEffect ( ( ) => {
1080+ console . log ( "fileInfo or connection changed" , fileInfo , connection ) ;
10821081 if ( ! fileInfo ) {
10831082 return ;
10841083 }
10851084 setErrorMsg ( null ) ;
1086- } , [ connection , filePath , fileInfo ] ) ;
1085+ } , [ connection , fileInfo ] ) ;
10871086
10881087 if ( connStatus ?. status != "connected" ) {
10891088 return null ;
@@ -1113,7 +1112,6 @@ function PreviewView({
11131112
11141113 return (
11151114 < >
1116- { /* <OpenFileModal blockId={blockId} model={model} blockRef={blockRef} /> */ }
11171115 < div key = "fullpreview" className = "full-preview scrollbar-hide-until-hover" >
11181116 { errorMsg && < ErrorOverlay errorMsg = { errorMsg } resetOverlay = { ( ) => setErrorMsg ( null ) } /> }
11191117 < div ref = { contentRef } className = "full-preview-content" >
@@ -1133,72 +1131,6 @@ function PreviewView({
11331131 ) ;
11341132}
11351133
1136- const OpenFileModal = memo (
1137- ( {
1138- model,
1139- blockRef,
1140- blockId,
1141- } : {
1142- model : PreviewModel ;
1143- blockRef : React . RefObject < HTMLDivElement > ;
1144- blockId : string ;
1145- } ) => {
1146- const openFileModal = useAtomValue ( model . openFileModal ) ;
1147- const curFileName = useAtomValue ( model . metaFilePath ) ;
1148- const [ filePath , setFilePath ] = useState ( "" ) ;
1149- const isNodeFocused = useAtomValue ( model . nodeModel . isFocused ) ;
1150- const handleKeyDown = useCallback (
1151- keydownWrapper ( ( waveEvent : WaveKeyboardEvent ) : boolean => {
1152- if ( checkKeyPressed ( waveEvent , "Escape" ) ) {
1153- model . updateOpenFileModalAndError ( false ) ;
1154- return true ;
1155- }
1156-
1157- const handleCommandOperations = async ( ) => {
1158- if ( checkKeyPressed ( waveEvent , "Enter" ) ) {
1159- await model . handleOpenFile ( filePath ) ;
1160- return true ;
1161- }
1162- return false ;
1163- } ;
1164-
1165- handleCommandOperations ( ) . catch ( ( error ) => {
1166- console . error ( "Error handling key down:" , error ) ;
1167- model . updateOpenFileModalAndError ( true , "An error occurred during operation." ) ;
1168- return false ;
1169- } ) ;
1170- return false ;
1171- } ) ,
1172- [ model , blockId , filePath , curFileName ]
1173- ) ;
1174- const handleFileSuggestionSelect = ( value ) => {
1175- globalStore . set ( model . openFileModal , false ) ;
1176- } ;
1177- const handleFileSuggestionChange = ( value ) => {
1178- setFilePath ( value ) ;
1179- } ;
1180- const handleBackDropClick = ( ) => {
1181- globalStore . set ( model . openFileModal , false ) ;
1182- } ;
1183- if ( ! openFileModal ) {
1184- return null ;
1185- }
1186- return (
1187- < TypeAheadModal
1188- label = "Open path"
1189- blockRef = { blockRef }
1190- anchorRef = { model . previewTextRef }
1191- onKeyDown = { handleKeyDown }
1192- onSelect = { handleFileSuggestionSelect }
1193- onChange = { handleFileSuggestionChange }
1194- onClickBackdrop = { handleBackDropClick }
1195- autoFocus = { isNodeFocused }
1196- giveFocusRef = { model . openFileModalGiveFocusRef }
1197- />
1198- ) ;
1199- }
1200- ) ;
1201-
12021134const ErrorOverlay = memo ( ( { errorMsg, resetOverlay } : { errorMsg : ErrorMsg ; resetOverlay : ( ) => void } ) => {
12031135 const showDismiss = errorMsg . showDismiss ?? true ;
12041136 const buttonClassName = "outlined grey font-size-11 vertical-padding-3 horizontal-padding-7" ;
0 commit comments