Skip to content

fix statfile atom dependencies via formatRemoteUri #1797

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 2 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
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
16 changes: 8 additions & 8 deletions frontend/app/view/preview/directorypreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { Button } from "@/app/element/button";
import { Input } from "@/app/element/input";
import { ContextMenuModel } from "@/app/store/contextmenu";
import { PLATFORM, atoms, createBlock, getApi } from "@/app/store/global";
import { PLATFORM, atoms, createBlock, getApi, globalStore } from "@/app/store/global";
import { RpcApi } from "@/app/store/wshclientapi";
import { TabRpcClient } from "@/app/store/wshrpcutil";
import type { PreviewModel } from "@/app/view/preview/preview";
Expand Down Expand Up @@ -296,8 +296,8 @@ function DirectoryTable({
console.log(`replacing ${fileName} with ${newName}: ${path}`);
fireAndForget(async () => {
await RpcApi.FileMoveCommand(TabRpcClient, {
srcuri: await model.formatRemoteUri(path),
desturi: await model.formatRemoteUri(newPath),
srcuri: await model.formatRemoteUri(path, globalStore.get),
desturi: await model.formatRemoteUri(newPath, globalStore.get),
opts: {
recursive: true,
},
Expand Down Expand Up @@ -610,7 +610,7 @@ function TableBody({
meta: {
controller: "shell",
view: "term",
"cmd:cwd": await model.formatRemoteUri(finfo.path),
"cmd:cwd": await model.formatRemoteUri(finfo.path, globalStore.get),
},
};
await createBlock(termBlockDef);
Expand All @@ -627,7 +627,7 @@ function TableBody({
fireAndForget(async () => {
await RpcApi.FileDeleteCommand(TabRpcClient, {
info: {
path: await model.formatRemoteUri(finfo.path),
path: await model.formatRemoteUri(finfo.path, globalStore.get),
},
}).catch((e) => console.log(e));
setRefreshVersion((current) => current + 1);
Expand Down Expand Up @@ -726,7 +726,7 @@ function DirectoryPreview({ model }: DirectoryPreviewProps) {
TabRpcClient,
{
info: {
path: await model.formatRemoteUri(dirPath),
path: await model.formatRemoteUri(dirPath, globalStore.get),
},
},
null
Expand Down Expand Up @@ -825,7 +825,7 @@ function DirectoryPreview({ model }: DirectoryPreviewProps) {
TabRpcClient,
{
info: {
path: await model.formatRemoteUri(`${dirPath}/${newName}`),
path: await model.formatRemoteUri(`${dirPath}/${newName}`, globalStore.get),
},
},
null
Expand All @@ -844,7 +844,7 @@ function DirectoryPreview({ model }: DirectoryPreviewProps) {
fireAndForget(async () => {
await RpcApi.FileMkdirCommand(TabRpcClient, {
info: {
path: await model.formatRemoteUri(`${dirPath}/${newName}`),
path: await model.formatRemoteUri(`${dirPath}/${newName}`, globalStore.get),
},
});
model.refreshCallback();
Expand Down
8 changes: 4 additions & 4 deletions frontend/app/view/preview/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export class PreviewModel implements ViewModel {
}
const statFile = await RpcApi.FileInfoCommand(TabRpcClient, {
info: {
path: await this.formatRemoteUri(fileName),
path: await this.formatRemoteUri(fileName, get),
},
});
console.log("stat file", statFile);
Expand All @@ -391,7 +391,7 @@ export class PreviewModel implements ViewModel {
}
const file = await RpcApi.FileReadCommand(TabRpcClient, {
info: {
path: await this.formatRemoteUri(fileName),
path: await this.formatRemoteUri(fileName, get),
},
});
console.log("full file", file);
Expand Down Expand Up @@ -601,7 +601,7 @@ export class PreviewModel implements ViewModel {
try {
await RpcApi.FileWriteCommand(TabRpcClient, {
info: {
path: await this.formatRemoteUri(filePath),
path: await this.formatRemoteUri(filePath, globalStore.get),
},
data64: stringToBase64(newFileContent),
});
Expand Down Expand Up @@ -777,7 +777,7 @@ export class PreviewModel implements ViewModel {
return false;
}

async formatRemoteUri(path: string): Promise<string> {
async formatRemoteUri(path: string, get: Getter): Promise<string> {
const conn = (await globalStore.get(this.connection)) ?? "local";
return `wsh://${conn}/${path}`;
}
Expand Down
Loading