Issue: Content relationship field type is fetching forever #885

This commit is contained in:
Elio Struyf
2024-11-04 13:20:18 +01:00
parent 57b710cc61
commit 3d6359bc2e
2 changed files with 8 additions and 4 deletions

View File

@@ -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

View File

@@ -39,8 +39,9 @@ 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;
}
@@ -48,7 +49,7 @@ export class FieldsListener extends BaseListener {
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
@@ -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);