Skip to content

Commit

Permalink
Merge pull request #1188 from searchspring/prevent-scrollmap-warning
Browse files Browse the repository at this point in the history
Ensure Storage Defined
  • Loading branch information
korgon authored Nov 6, 2024
2 parents 8976ceb + 8b5a2e1 commit ff87b94
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/snap-controller/src/Search/SearchController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,15 @@ 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);
this.log.warn('Failed to save srcollMap!', err);
}
}

Expand Down

0 comments on commit ff87b94

Please sign in to comment.