From 6468b3e4bffcc4160179015dc9290fd7ddbccf1b Mon Sep 17 00:00:00 2001 From: Nicky Nicolson Date: Thu, 30 Nov 2023 21:05:37 +0000 Subject: [PATCH] Bypass select modal if single match found (issue #6) --- src/main.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.ts b/src/main.ts index fe58ba5..f25c893 100644 --- a/src/main.ts +++ b/src/main.ts @@ -160,8 +160,11 @@ export default class WikidataSidebarPlugin extends Plugin { async searchWikidataMetadataByProperty(propertyname: string, propertyvalue: string): Promise { const searchResults = await this.serviceProvider.getByProperty(propertyname, propertyvalue); console.log(`Found ${searchResults.length}`); - console.log('hello'); - return await this.openWikidataSuggestModal(searchResults); + if (searchResults.length == 1) { + return searchResults[0]; + } else { + return await this.openWikidataSuggestModal(searchResults); + } } async openWikidataSuggestModal(items: WikidataEntity[]): Promise {