From 5606a22c6309f4f64c22726f637bddd3f19c9002 Mon Sep 17 00:00:00 2001 From: kevin Date: Mon, 4 Nov 2024 17:15:50 -0700 Subject: [PATCH 1/2] fix(controller/search): modifying logic to prevent warning when the lastRequest is not defined --- .../snap-controller/src/Search/SearchController.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/snap-controller/src/Search/SearchController.ts b/packages/snap-controller/src/Search/SearchController.ts index f23b51cca..a0c39101c 100644 --- a/packages/snap-controller/src/Search/SearchController.ts +++ b/packages/snap-controller/src/Search/SearchController.ts @@ -239,11 +239,12 @@ export class SearchController extends AbstractController { // store element position data to scrollMap if (selector || storedHref || domRect) { try { - const stringyParams = JSON.parse(this.storage.get('lastStringyParams')); - const storableRequestParams = getStorableRequestParams(stringyParams); - const storableStringyParams = JSON.stringify(storableRequestParams); - - scrollMap[storableStringyParams] = { domRect, href: storedHref, selector }; + const lastRequest = this.storage.get('lastStringyParams'); + if (lastRequest) { + const storableRequestParams = getStorableRequestParams(JSON.parse(lastRequest)); + const storableStringyParams = JSON.stringify(storableRequestParams); + scrollMap[storableStringyParams] = { domRect, href: storedHref, selector }; + } } catch (err) { // failed to get lastStringParams this.log.warn('Failed to save scollMap!', err); From 8b5a2e1b5c26045930a661d4a76245bbd4f3ee64 Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 6 Nov 2024 09:34:17 -0700 Subject: [PATCH 2/2] fix(controller/search): fixing typo in warning log --- packages/snap-controller/src/Search/SearchController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/snap-controller/src/Search/SearchController.ts b/packages/snap-controller/src/Search/SearchController.ts index a0c39101c..896718b4b 100644 --- a/packages/snap-controller/src/Search/SearchController.ts +++ b/packages/snap-controller/src/Search/SearchController.ts @@ -247,7 +247,7 @@ export class SearchController extends AbstractController { } } catch (err) { // failed to get lastStringParams - this.log.warn('Failed to save scollMap!', err); + this.log.warn('Failed to save srcollMap!', err); } }