Skip to content
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
33 changes: 23 additions & 10 deletions frontend/app/view/preview/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -388,13 +388,20 @@ export class PreviewModel implements ViewModel {
if (fileName == null) {
return null;
}
const statFile = await RpcApi.FileInfoCommand(TabRpcClient, {
info: {
path,
},
});
console.log("stat file", statFile);
return statFile;
try {
const statFile = await RpcApi.FileInfoCommand(TabRpcClient, {
info: {
path,
},
});
return statFile;
} catch (e) {
const errorStatus: ErrorMsg = {
status: "File Read Failed",
text: `${e}`,
};
globalStore.set(this.errorMsgAtom, errorStatus);
}
});
this.fileMimeType = atom<Promise<string>>(async (get) => {
const fileInfo = await get(this.statFile);
Expand All @@ -410,21 +417,20 @@ export class PreviewModel implements ViewModel {
if (fileName == null) {
return null;
}
let file: FileData;
try {
file = await RpcApi.FileReadCommand(TabRpcClient, {
const file = await RpcApi.FileReadCommand(TabRpcClient, {
info: {
path,
},
});
return file;
} catch (e) {
const errorStatus: ErrorMsg = {
status: "File Read Failed",
text: `${e}`,
};
globalStore.set(this.errorMsgAtom, errorStatus);
}
return file;
});

this.fileContentSaved = atom(null) as PrimitiveAtom<string | null>;
Expand Down Expand Up @@ -1064,6 +1070,12 @@ function PreviewView({
}) {
const connStatus = useAtomValue(model.connStatus);
const [errorMsg, setErrorMsg] = useAtom(model.errorMsgAtom);
const connection = useAtomValue(model.connectionImmediate);

useEffect(() => {
setErrorMsg(null);
}, [connection]);

if (connStatus?.status != "connected") {
return null;
}
Expand All @@ -1089,6 +1101,7 @@ function PreviewView({
const fetchSuggestionsFn = async (query, ctx) => {
return await fetchSuggestions(model, query, ctx);
};

return (
<>
{/* <OpenFileModal blockId={blockId} model={model} blockRef={blockRef} /> */}
Expand Down
Loading