Skip to content

Commit

Permalink
Merge pull request #1653 from mertbagt/follow-user-button
Browse files Browse the repository at this point in the history
fix following button
  • Loading branch information
mertbagt authored Dec 4, 2024
2 parents 9b8a98a + b896150 commit 0afeb59
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 128 deletions.
4 changes: 2 additions & 2 deletions components/EditProfilePage/FollowingTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ export function FollowingTab({ className }: { className?: string }) {
const q = query(
subscriptionRef,
where("uid", "==", `${uid}`),
where("type", "==", "org")
where("type", "==", "testimony")
)
const querySnapshot = await getDocs(q)
querySnapshot.forEach(doc => {
// doc.data() is never undefined for query doc snapshots
usersList.push(doc.data().userLookup)
})

if (usersFollowing.length === 0 && usersFollowing.length != 0) {
if (usersFollowing.length === 0 && usersList.length != 0) {
setUsersFollowing(usersList)
}
}, [subscriptionRef, uid, usersFollowing])
Expand Down
115 changes: 0 additions & 115 deletions components/ProfilePage/FollowButton.tsx

This file was deleted.

6 changes: 3 additions & 3 deletions components/ProfilePage/ProfileButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import styled from "styled-components"
import { FillButton, GearButton, ToggleButton } from "components/buttons"
import { Internal } from "components/links"
import { useProfile, ProfileHook } from "components/db"
import { FollowButton } from "./FollowButton"
import { useFlags } from "components/featureFlags"
import { FollowOrgButton } from "components/shared/FollowButton"
import { useAuth } from "../auth"

export const StyledButton = styled(Button).attrs(props => ({
Expand Down Expand Up @@ -68,7 +68,7 @@ export function ProfileButtonsUser({
const handleSave = async () => {
await updateProfile({ actions })
}
/** Only regular users are allowed to have a private profile. */
/* Only regular users are allowed to have a private profile. */
async function updateProfile({ actions }: { actions: ProfileHook }) {
const { updateIsPublic } = actions

Expand Down Expand Up @@ -103,7 +103,7 @@ export function ProfileButtonsOrg({
{isUser ? (
<EditProfileButton />
) : followOrg && user ? (
<FollowButton profileId={profileId} user={user} />
<FollowOrgButton profileId={profileId} />
) : null}
</>
)
Expand Down
4 changes: 1 addition & 3 deletions components/ProfilePage/ProfileHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ export const ProfileHeader = ({
<ProfileDisplayName className={`col-3 col-md-auto`}>
{profile.fullName}
</ProfileDisplayName>
{isOrg ? (
<ProfileButtonsOrg profileId={profileId} isUser={isUser} />
) : null}
<ProfileButtonsOrg profileId={profileId} isUser={isUser} />
</div>
</div>
<div className="col-12 col-md-2 d-flex justify-content-center justify-content-md-end align-items-center ms-md-auto ">
Expand Down
8 changes: 5 additions & 3 deletions components/ProfilePage/ProfilePage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PendingUpgradeBanner } from "components/PendingUpgradeBanner"
import { firestore } from "components/firebase"
import { PendingUpgradeBanner } from "components/PendingUpgradeBanner"
import { FollowContext, OrgFollowStatus } from "components/shared/FollowContext"
import { collectionGroup, getDocs, query, where } from "firebase/firestore"
import { useTranslation } from "next-i18next"
import ErrorPage from "next/error"
Expand Down Expand Up @@ -50,6 +51,7 @@ export function ProfilePage(profileprops: {
}, [profileprops.id])

const { t } = useTranslation("profile")
const [followStatus, setFollowStatus] = useState<OrgFollowStatus>({})

const [isProfilePublic, onProfilePublicityChanged] = useState<
boolean | undefined
Expand Down Expand Up @@ -81,7 +83,7 @@ export function ProfilePage(profileprops: {
}

return (
<>
<FollowContext.Provider value={{ followStatus, setFollowStatus }}>
{isPendingUpgrade && isCurrentUser && <PendingUpgradeBanner />}
{["user", "admin"].includes(role) && isCurrentUser ? (
<>
Expand Down Expand Up @@ -140,6 +142,6 @@ export function ProfilePage(profileprops: {
</Col>
</Row>
</Container>
</>
</FollowContext.Provider>
)
}
1 change: 0 additions & 1 deletion components/ProfilePage/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from "./ProfilePage"
export * from "./FollowButton"
2 changes: 1 addition & 1 deletion public/locales/en/editProfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"follow": {
"bills": "Bills You Follow",
"orgs": "Organizations You Follow",
"orgs": "Users You Follow",
"unfollow": "Unfollow"
},
"confirmation": {
Expand Down

0 comments on commit 0afeb59

Please sign in to comment.