From a90a5cba08fdf6c0ceb95101c275108a152a3aed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:37 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- toolkit/components/search/SearchSettings.sys.mjs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'toolkit/components/search/SearchSettings.sys.mjs') diff --git a/toolkit/components/search/SearchSettings.sys.mjs b/toolkit/components/search/SearchSettings.sys.mjs index e355316595..b4db403bb0 100644 --- a/toolkit/components/search/SearchSettings.sys.mjs +++ b/toolkit/components/search/SearchSettings.sys.mjs @@ -615,6 +615,27 @@ export class SearchSettings { } } + /** + * Finds the settings for the engine, based on the version of the settings + * passed in. Older versions of settings used the engine name as the key, + * whereas newer versions now use the engine id. + * + * @param {object} settings + * The saved settings object. + * @param {string} engineId + * The id of the engine. + * @param {string} engineName + * The name of the engine. + * @returns {object|undefined} + * The engine settings if found, undefined otherwise. + */ + static findSettingsForEngine(settings, engineId, engineName) { + if (settings.version <= 6) { + return settings.engines?.find(e => e._name == engineName); + } + return settings.engines?.find(e => e.id == engineId); + } + /** * Returns the engine associated with the name without SearchService * initialization checks. -- cgit v1.2.3