Skip to content

Commit d82ee30

Browse files
committed
Keep empty note views scoped locally
1 parent 0972c13 commit d82ee30

2 files changed

Lines changed: 36 additions & 12 deletions

File tree

src/notes/tui/NotesView.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -542,18 +542,7 @@ export class NotesView {
542542
}
543543

544544
const currentEntries = await this.callbacks.listNotes();
545-
const currentVisible = currentEntries.filter((entry) =>
546-
matchesFilter(entry, this.filter),
547-
);
548-
if (currentVisible.length > 0) {
549-
return { entries: currentEntries, allRepos: false, fallback: false };
550-
}
551-
552-
return {
553-
entries: flattenNoteSections(await this.callbacks.listAllNotes()),
554-
allRepos: true,
555-
fallback: true,
556-
};
545+
return { entries: currentEntries, allRepos: false, fallback: false };
557546
}
558547

559548
private applyFilter(): void {

tests/notes/services/Notes.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,41 @@ describe("Notes service", () => {
128128
expect(context.warnings).toEqual([]);
129129
});
130130

131+
test("lists only the local project outside Git", async () => {
132+
const { root } = fixture();
133+
const projectDir = mkdtempSync(join(tmpdir(), "local-directory-"));
134+
temporaryDirectories.push(projectDir);
135+
const localNotesPath = join(
136+
root,
137+
"projects",
138+
"local",
139+
basename(projectDir),
140+
);
141+
mkdirSync(localNotesPath, { recursive: true });
142+
writeFileSync(
143+
join(localNotesPath, "local.md"),
144+
renderDraft(
145+
"note",
146+
{
147+
source: "local",
148+
owner: "local",
149+
repo: basename(projectDir),
150+
},
151+
"date",
152+
"Local",
153+
"Local description",
154+
),
155+
);
156+
157+
const entries = await Effect.runPromise(
158+
Effect.gen(function* () {
159+
return yield* (yield* Notes).list();
160+
}).pipe(Effect.provide(serviceLayer(root, projectDir))),
161+
);
162+
163+
expect(entries.map((entry) => entry.filename)).toEqual(["local.md"]);
164+
});
165+
131166
test("lists markdown notes newest-first with parsed metadata", async () => {
132167
const { root, path, layer } = fixture();
133168
const notesPath = join(root, "projects", "timmo001", "notes");

0 commit comments

Comments
 (0)