diff --git a/frontend/app/view/preview/preview.tsx b/frontend/app/view/preview/preview.tsx index dd566f056..8383f8b5c 100644 --- a/frontend/app/view/preview/preview.tsx +++ b/frontend/app/view/preview/preview.tsx @@ -287,7 +287,8 @@ export class PreviewModel implements ViewModel { return null; } const mimeType = util.jotaiLoadableValue(get(this.fileMimeTypeLoadable), ""); - if (mimeType == "directory") { + const metaPath = get(this.metaFilePath); + if (mimeType == "directory" && metaPath == "/") { return null; } return { @@ -492,29 +493,24 @@ export class PreviewModel implements ViewModel { } async goParentDirectory() { - const blockMeta = globalStore.get(this.blockAtom)?.meta; - const metaPath = globalStore.get(this.metaFilePath); const fileInfo = await globalStore.get(this.statFile); if (fileInfo == null) { - return; + this.updateOpenFileModalAndError(false); + return true; } - let newPath: string = null; - if (!fileInfo.isdir) { - newPath = fileInfo.dir; - } else { - const lastSlash = fileInfo.dir.lastIndexOf("/"); - newPath = fileInfo.dir.slice(0, lastSlash); - if (newPath.indexOf("/") == -1) { - return; - } + const conn = globalStore.get(this.connection); + try { + const newFileInfo = await RpcApi.RemoteFileJoinCommand(WindowRpcClient, [fileInfo.dir, ".."], { + route: makeConnRoute(conn), + }); + console.log(newFileInfo.path); + this.updateOpenFileModalAndError(false); + this.goHistory(newFileInfo.path); + refocusNode(this.blockId); + } catch (e) { + globalStore.set(this.openFileError, e.message); + console.error("Error opening file", [fileInfo.dir, ".."], e); } - const updateMeta = historyutil.goHistory("file", metaPath, newPath, blockMeta); - if (updateMeta == null) { - return; - } - updateMeta.edit = false; - const blockOref = WOS.makeORef("block", this.blockId); - services.ObjectService.UpdateObjectMeta(blockOref, updateMeta); } goHistoryBack() {