Skip to content

Commit 68cf3fd

Browse files
authored
fix statfile atom dependencies via formatRemoteUri (#1797)
1 parent a982421 commit 68cf3fd

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

frontend/app/view/preview/directorypreview.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { Button } from "@/app/element/button";
55
import { Input } from "@/app/element/input";
66
import { ContextMenuModel } from "@/app/store/contextmenu";
7-
import { PLATFORM, atoms, createBlock, getApi } from "@/app/store/global";
7+
import { PLATFORM, atoms, createBlock, getApi, globalStore } from "@/app/store/global";
88
import { RpcApi } from "@/app/store/wshclientapi";
99
import { TabRpcClient } from "@/app/store/wshrpcutil";
1010
import type { PreviewModel } from "@/app/view/preview/preview";
@@ -296,8 +296,8 @@ function DirectoryTable({
296296
console.log(`replacing ${fileName} with ${newName}: ${path}`);
297297
fireAndForget(async () => {
298298
await RpcApi.FileMoveCommand(TabRpcClient, {
299-
srcuri: await model.formatRemoteUri(path),
300-
desturi: await model.formatRemoteUri(newPath),
299+
srcuri: await model.formatRemoteUri(path, globalStore.get),
300+
desturi: await model.formatRemoteUri(newPath, globalStore.get),
301301
opts: {
302302
recursive: true,
303303
},
@@ -610,7 +610,7 @@ function TableBody({
610610
meta: {
611611
controller: "shell",
612612
view: "term",
613-
"cmd:cwd": await model.formatRemoteUri(finfo.path),
613+
"cmd:cwd": await model.formatRemoteUri(finfo.path, globalStore.get),
614614
},
615615
};
616616
await createBlock(termBlockDef);
@@ -627,7 +627,7 @@ function TableBody({
627627
fireAndForget(async () => {
628628
await RpcApi.FileDeleteCommand(TabRpcClient, {
629629
info: {
630-
path: await model.formatRemoteUri(finfo.path),
630+
path: await model.formatRemoteUri(finfo.path, globalStore.get),
631631
},
632632
}).catch((e) => console.log(e));
633633
setRefreshVersion((current) => current + 1);
@@ -726,7 +726,7 @@ function DirectoryPreview({ model }: DirectoryPreviewProps) {
726726
TabRpcClient,
727727
{
728728
info: {
729-
path: await model.formatRemoteUri(dirPath),
729+
path: await model.formatRemoteUri(dirPath, globalStore.get),
730730
},
731731
},
732732
null
@@ -825,7 +825,7 @@ function DirectoryPreview({ model }: DirectoryPreviewProps) {
825825
TabRpcClient,
826826
{
827827
info: {
828-
path: await model.formatRemoteUri(`${dirPath}/${newName}`),
828+
path: await model.formatRemoteUri(`${dirPath}/${newName}`, globalStore.get),
829829
},
830830
},
831831
null
@@ -844,7 +844,7 @@ function DirectoryPreview({ model }: DirectoryPreviewProps) {
844844
fireAndForget(async () => {
845845
await RpcApi.FileMkdirCommand(TabRpcClient, {
846846
info: {
847-
path: await model.formatRemoteUri(`${dirPath}/${newName}`),
847+
path: await model.formatRemoteUri(`${dirPath}/${newName}`, globalStore.get),
848848
},
849849
});
850850
model.refreshCallback();

frontend/app/view/preview/preview.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ export class PreviewModel implements ViewModel {
371371
}
372372
const statFile = await RpcApi.FileInfoCommand(TabRpcClient, {
373373
info: {
374-
path: await this.formatRemoteUri(fileName),
374+
path: await this.formatRemoteUri(fileName, get),
375375
},
376376
});
377377
console.log("stat file", statFile);
@@ -392,7 +392,7 @@ export class PreviewModel implements ViewModel {
392392
}
393393
const file = await RpcApi.FileReadCommand(TabRpcClient, {
394394
info: {
395-
path: await this.formatRemoteUri(fileName),
395+
path: await this.formatRemoteUri(fileName, get),
396396
},
397397
});
398398
console.log("full file", file);
@@ -604,7 +604,7 @@ export class PreviewModel implements ViewModel {
604604
try {
605605
await RpcApi.FileWriteCommand(TabRpcClient, {
606606
info: {
607-
path: await this.formatRemoteUri(filePath),
607+
path: await this.formatRemoteUri(filePath, globalStore.get),
608608
},
609609
data64: stringToBase64(newFileContent),
610610
});
@@ -780,7 +780,7 @@ export class PreviewModel implements ViewModel {
780780
return false;
781781
}
782782

783-
async formatRemoteUri(path: string): Promise<string> {
783+
async formatRemoteUri(path: string, get: Getter): Promise<string> {
784784
const conn = (await globalStore.get(this.connection)) ?? "local";
785785
return `wsh://${conn}/${path}`;
786786
}

0 commit comments

Comments
 (0)