From 8f2468157038e52d9f420866f0cd6f066ca298b4 Mon Sep 17 00:00:00 2001 From: kiminkim724 Date: Tue, 14 Jan 2025 18:41:57 -0500 Subject: [PATCH 1/2] Used query instead of function in Firebase --- components/EditProfilePage/FollowingTab.tsx | 27 ++++----------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/components/EditProfilePage/FollowingTab.tsx b/components/EditProfilePage/FollowingTab.tsx index ef1940cf0..a19e77722 100644 --- a/components/EditProfilePage/FollowingTab.tsx +++ b/components/EditProfilePage/FollowingTab.tsx @@ -9,6 +9,7 @@ import { TitledSectionCard } from "../shared" import UnfollowItem, { UnfollowModalConfig } from "./UnfollowModal" import { FollowedItem } from "./FollowingTabComponents" import { BillElement, UserElement } from "./FollowingTabComponents" +import { deleteItem } from "components/shared/FollowingQueries" const functions = getFunctions() @@ -97,28 +98,10 @@ export function FollowingTab({ className }: { className?: string }) { if (unfollow === null) { return } - // rest of what was inside the original if statement - if (unfollow.type == "bill") { - const billLookup = { billId: unfollow.typeId, court: unfollow.court } - try { - const response = await unfollowBillFunction({ - billLookup - }) - console.log(response.data) // This should print { status: 'success', message: 'Subscription removed' } - } catch (error: any) { - console.log(error.message) - } - } else { - const userLookup = { - profileId: unfollow.typeId, - fullName: unfollow.userName - } - try { - const response = await unfollowUserFunction({ userLookup: userLookup }) - console.log(response.data) // This should print { status: 'success', message: 'Subscription removed' } - } catch (error: any) { - console.log(error.message) - } + try { + deleteItem({ uid, unfollowItem: unfollow }) + } catch (error: any) { + console.log(error.message) } setBillsFollowing([]) From d3ad7b422531f85a441826a8fd99bb7d07c57703 Mon Sep 17 00:00:00 2001 From: kiminkim724 Date: Tue, 14 Jan 2025 18:48:01 -0500 Subject: [PATCH 2/2] Remove unused imports and functions --- components/EditProfilePage/FollowingTab.tsx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/components/EditProfilePage/FollowingTab.tsx b/components/EditProfilePage/FollowingTab.tsx index a19e77722..4eba063d5 100644 --- a/components/EditProfilePage/FollowingTab.tsx +++ b/components/EditProfilePage/FollowingTab.tsx @@ -1,5 +1,5 @@ import { collection, getDocs, query, where } from "firebase/firestore" -import { getFunctions, httpsCallable } from "firebase/functions" +import { getFunctions } from "firebase/functions" import { useTranslation } from "next-i18next" import { useCallback, useEffect, useMemo, useState } from "react" import { useAuth } from "../auth" @@ -11,11 +11,6 @@ import { FollowedItem } from "./FollowingTabComponents" import { BillElement, UserElement } from "./FollowingTabComponents" import { deleteItem } from "components/shared/FollowingQueries" -const functions = getFunctions() - -const unfollowBillFunction = httpsCallable(functions, "unfollowBill") -const unfollowUserFunction = httpsCallable(functions, "unfollowUser") - export function FollowingTab({ className }: { className?: string }) { const { user } = useAuth() const uid = user?.uid