Skip to content

Commit 8735713

Browse files
Hide deleted pages from mention suggestions
Verify page search results still exist before rendering them in the @ mention menu.
1 parent 15b63ae commit 8735713

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

apps/desktop/src/services/mentions.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -569,14 +569,28 @@ async function getPageSuggestions(query: string,): Promise<MentionSuggestion[]>
569569
limit: PAGE_SUGGESTION_LIMIT,
570570
},);
571571

572-
return dedupeSuggestions(
573-
results
574-
.map((result,) =>
575-
parsePageTitleFromLinkTarget(result.relativePath,) ?? parsePageTitleFromLinkTarget(result.title,)
576-
)
577-
.filter((title,): title is string => Boolean(title,))
578-
.map((title,) => buildPageSuggestion(title,)),
572+
const titles = Array.from(
573+
new Set(
574+
results
575+
.map((result,) =>
576+
parsePageTitleFromLinkTarget(result.relativePath,) ?? parsePageTitleFromLinkTarget(result.title,)
577+
)
578+
.filter((title,): title is string => Boolean(title,)),
579+
),
579580
);
581+
const existingTitles = await Promise.all(
582+
titles.map(async (title,) => {
583+
try {
584+
return await exists(await getPagePath(title,),) ? title : null;
585+
} catch {
586+
return null;
587+
}
588+
},),
589+
);
590+
591+
return existingTitles
592+
.filter((title,): title is string => Boolean(title,))
593+
.map((title,) => buildPageSuggestion(title,));
580594
}
581595

582596
async function getCreatePageTitle(query: string,): Promise<string | null> {

0 commit comments

Comments
 (0)