diff options
author | Leon Jiang <35908040+leonyjiang@users.noreply.github.com> | 2021-03-08 05:48:09 -0500 |
---|---|---|
committer | Leon Jiang <35908040+leonyjiang@users.noreply.github.com> | 2021-03-08 05:48:09 -0500 |
commit | 1d4dd2b2e6496374063efe7a4e1f8bde5cab32b1 (patch) | |
tree | 81ba5496aa38f4d32dd5349f16356756c734c825 | |
parent | 190d60cca929fd3869dd4ee077ccdfa854adf4dd (diff) |
Fix duplicate stores of a category
-rw-r--r-- | src/utils/users.ts | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/utils/users.ts b/src/utils/users.ts index efae6d20..15107c99 100644 --- a/src/utils/users.ts +++ b/src/utils/users.ts @@ -213,6 +213,8 @@ export const addCategoryToRecentlySearched = async ( ); if (categoriesJSON) { categories = JSON.parse(categoriesJSON); + // TODO: make this more efficient by comparing shorter key + if (categories.find((c) => c.name === category.name)) return; categories.push(category); } else { categories = [category]; |