Skip to content

Commit

Permalink
🔁 Rename profile to account for v3 preparation: v10 (#v3-profile-to-a…
Browse files Browse the repository at this point in the history
…ccount)

Summary: Renamed `useProfileStore` to `useAccountStore` across components.

Highlights:

• Updated imports and references from `useProfileStore` to `useAccountStore`.
• Changed `currentProfile` to `currentAccount` in logic and UI conditions.
• Added `useAccountStore.ts` to manage account state with `zustand`.

Read more: https://pierre.co/hey/hey/v3-profile-to-account
  • Loading branch information
Yoginth authored and Pierre committed Nov 20, 2024
1 parent fd3a99e commit 26fa63d
Show file tree
Hide file tree
Showing 121 changed files with 489 additions and 489 deletions.
6 changes: 3 additions & 3 deletions apps/web/src/components/Account/AccountFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { Virtuoso } from "react-virtuoso";
import { useImpressionsStore } from "src/store/non-persisted/useImpressionsStore";
import { useProfileFeedStore } from "src/store/non-persisted/useProfileFeedStore";
import { useTipsStore } from "src/store/non-persisted/useTipsStore";
import { useProfileStore } from "src/store/persisted/useProfileStore";
import { useAccountStore } from "src/store/persisted/useAccountStore";
import { useTransactionStore } from "src/store/persisted/useTransactionStore";

let virtuosoState: any = { ranges: [], screenTop: 0 };
Expand All @@ -39,7 +39,7 @@ const AccountFeed: FC<AccountFeedProps> = ({
profileId,
type
}) => {
const { currentProfile } = useProfileStore();
const { currentAccount } = useAccountStore();
const { mediaFeedFilters } = useProfileFeedStore();
const { fetchAndStoreViews } = useImpressionsStore();
const { fetchAndStoreTips } = useTipsStore();
Expand Down Expand Up @@ -113,7 +113,7 @@ const AccountFeed: FC<AccountFeedProps> = ({
const hasMore = pageInfo?.next;

useEffect(() => {
if (indexedPostHash && currentProfile?.id === profileId) {
if (indexedPostHash && currentAccount?.id === profileId) {
refetch();
}
}, [indexedPostHash]);
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/components/Account/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import Link from "next/link";
import { useRouter } from "next/router";
import type { FC, ReactNode } from "react";
import { useState } from "react";
import { useProfileStore } from "src/store/persisted/useProfileStore";
import { useAccountStore } from "src/store/persisted/useAccountStore";
import urlcat from "urlcat";
import AccountStatus from "./AccountStatus";
import Badges from "./Badges";
Expand Down Expand Up @@ -61,7 +61,7 @@ interface DetailsProps {

const Details: FC<DetailsProps> = ({ isSuspended = false, profile }) => {
const { push } = useRouter();
const { currentProfile } = useProfileStore();
const { currentAccount } = useAccountStore();
const [expandedImage, setExpandedImage] = useState<null | string>(null);
const [showPersonalizeModal, setShowPersonalizeModal] = useState(false);
const isStaff = useFlag(FeatureFlag.Staff);
Expand Down Expand Up @@ -120,7 +120,7 @@ const Details: FC<DetailsProps> = ({ isSuspended = false, profile }) => {
<ScamWarning profileId={profile.id} />
<Followerings profile={profile} />
<div className="flex items-center space-x-2">
{currentProfile?.id === profile.id ? (
{currentAccount?.id === profile.id ? (
<>
<Button
icon={<Cog6ToothIcon className="size-5" />}
Expand All @@ -142,7 +142,7 @@ const Details: FC<DetailsProps> = ({ isSuspended = false, profile }) => {
) : null}
<AccountMenu profile={profile} />
</div>
{currentProfile?.id !== profile.id ? (
{currentAccount?.id !== profile.id ? (
<MutualFollowersOverview
handle={getAccount(profile).slug}
profileId={profile.id}
Expand Down
12 changes: 6 additions & 6 deletions apps/web/src/components/Account/Lists/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ import axios from "axios";
import type { FC } from "react";
import { useState } from "react";
import toast from "react-hot-toast";
import { useProfileStore } from "src/store/persisted/useProfileStore";
import { useAccountStore } from "src/store/persisted/useAccountStore";
import CreateOrEdit from "../../Shared/List/CreateOrEdit";

interface ListsProps {
profile: Profile;
}

const Lists: FC<ListsProps> = ({ profile }) => {
const { currentProfile } = useProfileStore();
const { currentAccount } = useAccountStore();
const [showCreateModal, setShowCreateModal] = useState(false);
const [deleting, setDeleting] = useState(false);
const [deletingList, setDeletingList] = useState<string | null>(null);
Expand Down Expand Up @@ -67,7 +67,7 @@ const Lists: FC<ListsProps> = ({ profile }) => {
);

queryClient.setQueryData<List[]>(
[GET_LISTS_QUERY_KEY, currentProfile?.id],
[GET_LISTS_QUERY_KEY, currentAccount?.id],
(oldData) => oldData?.filter((list) => list.id !== id)
);
toast.success("List deleted");
Expand All @@ -90,7 +90,7 @@ const Lists: FC<ListsProps> = ({ profile }) => {
);

queryClient.setQueryData<List[]>(
[GET_LISTS_QUERY_KEY, currentProfile?.id],
[GET_LISTS_QUERY_KEY, currentAccount?.id],
(oldData) =>
oldData?.map((list) =>
list.id === id ? { ...list, pinned: !pinned } : list
Expand All @@ -109,7 +109,7 @@ const Lists: FC<ListsProps> = ({ profile }) => {
<Card>
<div className="flex items-center justify-between space-x-5 p-5">
<H5>{getAccount(profile).slugWithPrefix}'s Lists</H5>
{profile.id === currentProfile?.id && (
{profile.id === currentAccount?.id && (
<Button onClick={() => setShowCreateModal(!showCreateModal)}>
Create
</Button>
Expand All @@ -126,7 +126,7 @@ const Lists: FC<ListsProps> = ({ profile }) => {
{data?.map((list) => (
<div key={list.id} className="flex items-center justify-between">
<SingleList list={list} />
{profile.id === currentProfile?.id && (
{profile.id === currentAccount?.id && (
<div className="flex items-center gap-3">
<Tooltip
content={list.pinned ? "Unpin from Home" : "Pin to Home"}
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/components/Account/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import stopEventPropagation from "@hey/helpers/stopEventPropagation";
import type { Profile } from "@hey/lens";
import type { FC } from "react";
import { Fragment } from "react";
import { useProfileStore } from "src/store/persisted/useProfileStore";
import { useAccountStore } from "src/store/persisted/useAccountStore";
import AddToList from "./AddToList";
import Block from "./Block";
import CopyAddress from "./CopyAddress";
Expand All @@ -18,7 +18,7 @@ interface AccountMenuProps {
}

const AccountMenu: FC<AccountMenuProps> = ({ profile }) => {
const { currentProfile } = useProfileStore();
const { currentAccount } = useAccountStore();

return (
<Menu as="div" className="relative">
Expand All @@ -40,7 +40,7 @@ const AccountMenu: FC<AccountMenuProps> = ({ profile }) => {
<CopyLink profile={profile} />
<CopyAddress address={profile.ownedBy.address} />
<CopyID id={profile.id} />
{currentProfile && currentProfile?.id !== profile.id ? (
{currentAccount && currentAccount?.id !== profile.id ? (
<>
<AddToList profile={profile} />
<Block profile={profile} />
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/components/Account/MutualFollowersOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { LimitType, useMutualFollowersQuery } from "@hey/lens";
import { Modal, StackedAvatars } from "@hey/ui";
import cn from "@hey/ui/cn";
import { type FC, type ReactNode, useState } from "react";
import { useProfileStore } from "src/store/persisted/useProfileStore";
import { useAccountStore } from "src/store/persisted/useAccountStore";

interface MutualFollowersOverviewProps {
handle: string;
Expand All @@ -21,16 +21,16 @@ const MutualFollowersOverview: FC<MutualFollowersOverviewProps> = ({
profileId,
viaPopover = false
}) => {
const { currentProfile } = useProfileStore();
const { currentAccount } = useAccountStore();
const [showMutualFollowersModal, setShowMutualFollowersModal] =
useState(false);

const { data, error, loading } = useMutualFollowersQuery({
skip: !profileId || !currentProfile?.id,
skip: !profileId || !currentAccount?.id,
variables: {
request: {
limit: LimitType.Ten,
observer: currentProfile?.id,
observer: currentAccount?.id,
viewing: profileId
}
}
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/components/Account/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { useRouter } from "next/router";
import { useEffect } from "react";
import Custom404 from "src/pages/404";
import Custom500 from "src/pages/500";
import { useProfileStore } from "src/store/persisted/useProfileStore";
import { useAccountStore } from "src/store/persisted/useAccountStore";
import AccountFeed from "./AccountFeed";
import Details from "./Details";
import FeedType from "./FeedType";
Expand All @@ -39,7 +39,7 @@ const ViewProfile: NextPage = () => {
pathname,
query: { handle, id, source, type }
} = useRouter();
const { currentProfile } = useProfileStore();
const { currentAccount } = useAccountStore();
const isStaff = useFlag(FeatureFlag.Staff);

useEffect(() => {
Expand Down Expand Up @@ -142,7 +142,7 @@ const ViewProfile: NextPage = () => {
) : (
<>
<FeedType feedType={feedType as AccountFeedType} />
{currentProfile?.id === profile?.id &&
{currentAccount?.id === profile?.id &&
feedType !== AccountFeedType.Lists ? (
<NewPost />
) : null}
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/components/Analytics/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { GridItemTwelve, GridLayout } from "@hey/ui";
import type { NextPage } from "next";
import { useRouter } from "next/router";
import { useEffect } from "react";
import { useProfileStore } from "src/store/persisted/useProfileStore";
import { useAccountStore } from "src/store/persisted/useAccountStore";
import AnalyticsType from "./AnalyticsType";
import Impressions from "./Impressions";
import Overview from "./Overview";
Expand All @@ -17,7 +17,7 @@ const Analytics: NextPage = () => {
const {
query: { type }
} = useRouter();
const { currentProfile } = useProfileStore();
const { currentAccount } = useAccountStore();

useEffect(() => {
Leafwatch.track(PAGEVIEW, { page: "analytics" });
Expand All @@ -34,7 +34,7 @@ const Analytics: NextPage = () => {
: AnalyticsTabType.Overview
: AnalyticsTabType.Overview;

if (!currentProfile) {
if (!currentAccount) {
return <NotLoggedIn />;
}

Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/components/Bookmarks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ import type { PublicationMetadataMainFocusType } from "@hey/lens";
import { GridItemEight, GridItemFour, GridLayout } from "@hey/ui";
import type { NextPage } from "next";
import { useEffect, useState } from "react";
import { useProfileStore } from "src/store/persisted/useProfileStore";
import { useAccountStore } from "src/store/persisted/useAccountStore";
import BookmarksFeed from "./BookmarksFeed";

const Bookmarks: NextPage = () => {
const { currentProfile } = useProfileStore();
const { currentAccount } = useAccountStore();
const [focus, setFocus] = useState<PublicationMetadataMainFocusType>();

useEffect(() => {
Leafwatch.track(PAGEVIEW, { page: "bookmarks" });
}, []);

if (!currentProfile) {
if (!currentAccount) {
return <NotLoggedIn />;
}

Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/components/Club/Members.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import axios from "axios";
import Link from "next/link";
import type { FC } from "react";
import { Virtuoso } from "react-virtuoso";
import { useProfileStore } from "src/store/persisted/useProfileStore";
import { useAccountStore } from "src/store/persisted/useAccountStore";

const GET_CLUB_MEMBERS_QUERY_KEY = "getClubMembers";

Expand All @@ -21,7 +21,7 @@ interface MembersProps {
}

const Members: FC<MembersProps> = ({ clubId, handle }) => {
const { currentProfile } = useProfileStore();
const { currentAccount } = useAccountStore();

const getClubMembers = async (): Promise<{
items: ClubProfile[];
Expand Down Expand Up @@ -113,8 +113,8 @@ const Members: FC<MembersProps> = ({ clubId, handle }) => {
itemContent={(_, member) => (
<div className="p-5">
<SingleAccount
hideFollowButton={currentProfile?.id === member.id}
hideUnfollowButton={currentProfile?.id === member.id}
hideFollowButton={currentAccount?.id === member.id}
hideUnfollowButton={currentAccount?.id === member.id}
profile={member as Profile}
showBio
showUserPreview={false}
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/components/Club/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useRouter } from "next/router";
import { useEffect } from "react";
import Custom404 from "src/pages/404";
import Custom500 from "src/pages/500";
import { useProfileStore } from "src/store/persisted/useProfileStore";
import { useAccountStore } from "src/store/persisted/useAccountStore";
import ClubFeed from "./ClubFeed";
import Details from "./Details";
import Members from "./Members";
Expand All @@ -24,7 +24,7 @@ const ViewClub: NextPage = () => {
pathname,
query: { handle }
} = useRouter();
const { currentProfile } = useProfileStore();
const { currentAccount } = useAccountStore();

const showMembers = pathname === "/c/[handle]/members";

Expand All @@ -46,7 +46,7 @@ const ViewClub: NextPage = () => {
queryFn: () =>
getClub({
club_handle: handle as string,
profile_id: currentProfile?.id
profile_id: currentAccount?.id
}),
queryKey: [GET_CLUB_QUERY_KEY, handle]
});
Expand Down Expand Up @@ -79,7 +79,7 @@ const ViewClub: NextPage = () => {
<Members clubId={club.id} handle={club.handle} />
) : (
<>
{currentProfile && club.isMember && (
{currentAccount && club.isMember && (
<NewPost
tags={[
`orbcommunities${club.handle}`,
Expand Down
10 changes: 5 additions & 5 deletions apps/web/src/components/Common/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import { useEffect } from "react";
import { Toaster } from "react-hot-toast";
import { useNonceStore } from "src/store/non-persisted/useNonceStore";
import { useProfileStatus } from "src/store/non-persisted/useProfileStatus";
import { useAccountStore } from "src/store/persisted/useAccountStore";
import { hydrateAuthTokens, signOut } from "src/store/persisted/useAuthStore";
import { usePreferencesStore } from "src/store/persisted/usePreferencesStore";
import { useProfileStore } from "src/store/persisted/useProfileStore";
import { useProfileThemeStore } from "src/store/persisted/useProfileThemeStore";
import { isAddress } from "viem";
import { useDisconnect } from "wagmi";
Expand All @@ -33,8 +33,8 @@ const Layout: FC<LayoutProps> = ({ children }) => {
const { reload } = useRouter();
const { resolvedTheme } = useTheme();
const { theme } = useProfileThemeStore();
const { currentProfile, setCurrentProfile, setFallbackToCuratedFeed } =
useProfileStore();
const { currentAccount, setCurrentAccount, setFallbackToCuratedFeed } =
useAccountStore();
const { resetPreferences } = usePreferencesStore();
const { resetStatus } = useProfileStatus();
const { setLensHubOnchainSigNonce } = useNonceStore();
Expand All @@ -55,7 +55,7 @@ const Layout: FC<LayoutProps> = ({ children }) => {

const { loading } = useCurrentProfileQuery({
onCompleted: ({ profile, userSigNonces }) => {
setCurrentProfile(profile as Profile);
setCurrentAccount(profile as Profile);
setLensHubOnchainSigNonce(userSigNonces.lensHubOnchainSigNonce);

// If the profile has no following, we should fallback to the curated feed
Expand All @@ -80,7 +80,7 @@ const Layout: FC<LayoutProps> = ({ children }) => {
validateAuthentication();
}, []);

const profileLoading = !currentProfile && loading;
const profileLoading = !currentAccount && loading;

if (profileLoading || !isMounted) {
return <FullPageLoader />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import type { CollectModuleType } from "@hey/types/hey";
import { Input, Select } from "@hey/ui";
import type { FC } from "react";
import { useCollectModuleStore } from "src/store/non-persisted/post/useCollectModuleStore";
import { useAccountStore } from "src/store/persisted/useAccountStore";
import { useAllowedTokensStore } from "src/store/persisted/useAllowedTokensStore";
import { useProfileStore } from "src/store/persisted/useProfileStore";

interface AmountConfigProps {
setCollectType: (data: CollectModuleType) => void;
}

const AmountConfig: FC<AmountConfigProps> = ({ setCollectType }) => {
const { currentProfile } = useProfileStore();
const { currentAccount } = useAccountStore();
const { collectModule } = useCollectModuleStore((state) => state);
const { allowedTokens } = useAllowedTokensStore();

Expand All @@ -34,7 +34,7 @@ const AmountConfig: FC<AmountConfigProps> = ({ setCollectType }) => {
: { currency: DEFAULT_COLLECT_TOKEN, value: "1" },
recipients: enabled
? []
: [{ recipient: currentProfile?.ownedBy.address, split: 100 }],
: [{ recipient: currentAccount?.ownedBy.address, split: 100 }],
type: enabled
? CollectOpenActionModuleType.SimpleCollectOpenActionModule
: CollectOpenActionModuleType.MultirecipientFeeCollectOpenActionModule
Expand Down
Loading

1 comment on commit 26fa63d

@vercel
Copy link

@vercel vercel bot commented on 26fa63d Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

web – ./

heyxyz.vercel.app
hey.xyz
web-heyxyz.vercel.app
web-git-main-heyxyz.vercel.app

Please sign in to comment.