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