Skip to content

Back Arrow goes back to existing parent #979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions frontend/app/view/preview/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,12 @@ export class PreviewModel implements ViewModel {
}
}

async goParentDirectory() {
const fileInfo = await globalStore.get(this.statFile);
async goParentDirectory({ fileInfo = null }: { fileInfo?: FileInfo | null }) {
// optional parameter needed for recursive case
const defaultFileInfo = await globalStore.get(this.statFile);
if (fileInfo === null) {
fileInfo = defaultFileInfo;
}
if (fileInfo == null) {
this.updateOpenFileModalAndError(false);
return true;
Expand All @@ -520,6 +524,11 @@ export class PreviewModel implements ViewModel {
const newFileInfo = await RpcApi.RemoteFileJoinCommand(WindowRpcClient, [fileInfo.path, ".."], {
route: makeConnRoute(conn),
});
if (newFileInfo.path != "" && newFileInfo.notfound) {
console.log("does not exist, ", newFileInfo.path);
this.goParentDirectory({ fileInfo: newFileInfo });
return;
}
console.log(newFileInfo.path);
this.updateOpenFileModalAndError(false);
this.goHistory(newFileInfo.path);
Expand Down Expand Up @@ -694,7 +703,7 @@ export class PreviewModel implements ViewModel {
}
if (keyutil.checkKeyPressed(e, "Cmd:ArrowUp")) {
// handle up directory
this.goParentDirectory();
this.goParentDirectory({});
return true;
}
const openModalOpen = globalStore.get(this.openFileModal);
Expand Down