Skip to content

Commit

Permalink
Issue: Content relationship field type is fetching forever #885
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Nov 4, 2024
1 parent 57b710c commit 3d6359b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- [#859](https://github.com/estruyf/vscode-front-matter/issues/859): Fix label in the data view dropdown field
- [#876](https://github.com/estruyf/vscode-front-matter/issues/876): Fix snippet type on the snippet card
- [#879](https://github.com/estruyf/vscode-front-matter/issues/879): Fix for auto updating last modified date on save
- [#885](https://github.com/estruyf/vscode-front-matter/issues/885): Fix content relationship for none i18n content

## [10.5.1] - 2024-10-23

Expand Down
11 changes: 7 additions & 4 deletions src/listeners/panel/FieldsListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,17 @@ export class FieldsListener extends BaseListener {
return;
}

const isLocaleEnabled = await i18n.isLocaleEnabled(data.activePath);
const activeLocale = await i18n.getLocale(data.activePath);
if (!activeLocale?.locale) {
if (isLocaleEnabled && !activeLocale?.locale) {
return;
}

PagesListener.getPagesData(false, async (pages) => {
const fuseOptions: Fuse.IFuseOptions<Page> = {
keys: [
{ name: 'fmContentType', weight: 1 },
...(data.sameLocale ? [{ name: 'fmLocale.locale', weight: 1 }] : [])
...(isLocaleEnabled && data.sameLocale ? [{ name: 'fmLocale.locale', weight: 1 }] : [])
],
findAllMatches: true,
threshold: 0
Expand All @@ -62,8 +63,10 @@ export class FieldsListener extends BaseListener {
const fuse = new Fuse(pages || [], fuseOptions, fuseIndex);
const results = fuse.search({
$and: [
{ fmContentType: data.type! },
...(data.sameLocale ? [{ 'fmLocale.locale': activeLocale.locale }] : [])
{ fmContentType: data.type ?? '' },
...(isLocaleEnabled && activeLocale?.locale && data.sameLocale
? [{ 'fmLocale.locale': activeLocale.locale }]
: [])
]
});
const pageResults = results.map((page) => page.item);
Expand Down

0 comments on commit 3d6359b

Please sign in to comment.