diff options
Diffstat (limited to 'src/utils/users.ts')
-rw-r--r-- | src/utils/users.ts | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/src/utils/users.ts b/src/utils/users.ts index 15107c99..af4f3813 100644 --- a/src/utils/users.ts +++ b/src/utils/users.ts @@ -166,69 +166,3 @@ export const defaultUserProfile = () => { return defaultImage; }; -export const addUserToRecentlyViewed = async (user: ProfilePreviewType) => { - const jsonValue = await AsyncStorage.getItem('@recently_searched_users'); - let recentlySearchedList = jsonValue != null ? JSON.parse(jsonValue) : null; - if (recentlySearchedList) { - if (recentlySearchedList.length > 0) { - if ( - recentlySearchedList.some( - (saved_user: ProfilePreviewType) => saved_user.id === user.id, - ) - ) { - console.log('User already in recently searched.'); - } else { - if (recentlySearchedList.length >= 10) { - recentlySearchedList.pop(); - } - recentlySearchedList.unshift(user); - } - } - } else { - recentlySearchedList = [user]; - } - try { - let recentlySearchedListString = JSON.stringify(recentlySearchedList); - await AsyncStorage.setItem( - '@recently_searched_users', - recentlySearchedListString, - ); - } catch (e) { - console.log(e); - } -}; - -/* - * Stores `category` in AsyncStorage as a recently searched category. - */ -export const addCategoryToRecentlySearched = async ( - category: CategoryPreviewType, -) => { - const recentlySearchedCategoriesKey = '@recently_searched_categories'; - let categories: CategoryPreviewType[]; - // retrieve recently-searched categories and set new list - try { - const categoriesJSON = await AsyncStorage.getItem( - recentlySearchedCategoriesKey, - ); - 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]; - } - // store updated list of recently-searched categories - try { - AsyncStorage.setItem( - recentlySearchedCategoriesKey, - JSON.stringify(categories), - ); - } catch (e) { - console.log(e); - } - } catch (e) { - console.log(e); - } -}; |