small update, show actual path iff path is ~ (#314)

This commit is contained in:
Mike Sawka 2024-09-03 21:18:52 -07:00 committed by GitHub
parent a7746bc5cc
commit f252531197
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -103,6 +103,7 @@ export class PreviewModel implements ViewModel {
statFilePath: jotai.Atom<Promise<string>>;
normFilePath: jotai.Atom<Promise<string>>;
loadableStatFilePath: jotai.Atom<Loadable<string>>;
loadableFileInfo: jotai.Atom<Loadable<FileInfo>>;
connection: jotai.Atom<string>;
statFile: jotai.Atom<Promise<FileInfo>>;
fullFile: jotai.Atom<Promise<FullFile>>;
@ -189,9 +190,12 @@ export class PreviewModel implements ViewModel {
const loadableSV = get(this.loadableSpecializedView);
const isCeView = loadableSV.state == "hasData" && loadableSV.data.specializedView == "codeedit";
let headerPath = get(this.metaFilePath);
const loadablePath: Loadable<string> = get(this.loadableStatFilePath);
if (loadablePath.state == "hasData" && !util.isBlank(loadablePath.data)) {
headerPath = loadablePath.data;
const loadableFileInfo = get(this.loadableFileInfo);
if (loadableFileInfo.state == "hasData") {
headerPath = loadableFileInfo.data?.path;
if (headerPath == "~") {
headerPath = `~ (${loadableFileInfo.data?.dir})`;
}
}
const viewTextChildren: HeaderElem[] = [
{
@ -337,6 +341,7 @@ export class PreviewModel implements ViewModel {
});
this.loadableSpecializedView = loadable(this.specializedView);
this.canPreview = jotai.atom(false);
this.loadableFileInfo = loadable(this.statFile);
}
async getSpecializedView(getFn: jotai.Getter): Promise<{ specializedView?: string; errorStr?: string }> {
@ -876,7 +881,7 @@ const OpenFileModal = React.memo(
}
return (
<TypeAheadModal
label="Open file"
label="Open path"
suggestions={[]}
blockRef={blockRef}
anchorRef={model.previewTextRef}