From 3d6359bc2e03da816abcf6eb6aeb999d4bf5539b Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Mon, 4 Nov 2024 13:20:18 +0100 Subject: [PATCH] Issue: Content relationship field type is fetching forever #885 --- CHANGELOG.md | 1 + src/listeners/panel/FieldsListener.ts | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11117adb..a049c497 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/listeners/panel/FieldsListener.ts b/src/listeners/panel/FieldsListener.ts index 6ebc62e0..ef68963f 100644 --- a/src/listeners/panel/FieldsListener.ts +++ b/src/listeners/panel/FieldsListener.ts @@ -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 = { 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);