diff --git a/src/model/store-vault-sync.ts b/src/model/store-vault-sync.ts index 168ecc1..a2e096c 100644 --- a/src/model/store-vault-sync.ts +++ b/src/model/store-vault-sync.ts @@ -23,6 +23,17 @@ type FileWithMetadata = { metadata: CachedMetadata; }; +export function resolveIfLongformFile( + metadataCache: MetadataCache, + file: TFile +): FileWithMetadata | null { + const metadata = metadataCache.getFileCache(file); + if (metadata && metadata.frontmatter && metadata.frontmatter["longform"]) { + return { file, metadata }; + } + return null; +} + /** * Observes any file with a `longform` metadata entry and keeps its * metadata and associated scenes (if any) updated in the `drafts` @@ -54,8 +65,8 @@ export class StoreVaultSync { const start = new Date().getTime(); const files = this.vault.getMarkdownFiles(); - const resolvedFiles = await Promise.all( - files.map((f) => this.resolveIfLongformFile(f)) + const resolvedFiles = files.map((f) => + resolveIfLongformFile(this.metadataCache, f) ); const draftFiles = resolvedFiles.filter((f) => f !== null); @@ -322,16 +333,6 @@ export class StoreVaultSync { ); } - private async resolveIfLongformFile( - file: TFile - ): Promise { - const metadata = this.metadataCache.getFileCache(file); - if (metadata && metadata.frontmatter && metadata.frontmatter["longform"]) { - return { file, metadata }; - } - return null; - } - // if dirty, draft is modified from reality of index file // and should be written back to index file private async draftFor( diff --git a/src/view/explorer/SceneList.svelte b/src/view/explorer/SceneList.svelte index 8a1501d..6294742 100644 --- a/src/view/explorer/SceneList.svelte +++ b/src/view/explorer/SceneList.svelte @@ -5,7 +5,7 @@ */ import type Sortable from "sortablejs"; import { getContext, onDestroy } from "svelte"; - import { Keymap, Notice, Platform, type PaneType } from "obsidian"; + import { Keymap, Notice, Platform, type PaneType, TFile } from "obsidian"; import { activeFile } from "../stores"; import { drafts, pluginSettings, selectedDraft } from "src/model/stores"; @@ -39,6 +39,7 @@ collapsible: boolean; hidden: boolean; numbering: number[]; + status: string | undefined; }; let items: SceneItem[]; let collapsedItems: string[] = []; @@ -74,14 +75,29 @@ } const nextScene = index < scenes.length - 1 ? scenes[index + 1] : false; + const path = makeScenePath($selectedDraft as MultipleSceneDraft, title); + // TODO: Get app by some other means? + const file = app.vault.getAbstractFileByPath(path); + let status = undefined; + if (file && file instanceof TFile) { + const metadata = app.metadataCache.getFileCache(file); + if ( + metadata && + metadata.frontmatter && + metadata.frontmatter["status"] + ) { + status = `${metadata.frontmatter["status"]}`; + } + } const item = { id: title, name: title, - indent: indent, - path: makeScenePath($selectedDraft as MultipleSceneDraft, title), + indent, + path, collapsible: nextScene && nextScene.indent > indent, hidden, numbering, + status, }; itemsToReturn.push(item); }); @@ -346,6 +362,7 @@ data-scene-path={item.path} data-scene-indent={item.indent} data-scene-name={item.name} + data-scene-status={item.status} > {#if item.collapsible}