Skip to content

Commit

Permalink
chore: move enums to global file (heyxyz#2114)
Browse files Browse the repository at this point in the history
  • Loading branch information
bigint authored Mar 20, 2023
1 parent 43a3ba3 commit 3fab7b4
Show file tree
Hide file tree
Showing 24 changed files with 66 additions and 53 deletions.
5 changes: 3 additions & 2 deletions apps/web/src/components/Comment/Feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { CommentOrderingTypes, CommentRankingFilter, CustomFiltersTypes, useComm
import type { FC } from 'react';
import { useState } from 'react';
import { useInView } from 'react-cool-inview';
import { OptmisticPublicationType } from 'src/enums';
import { useAppStore } from 'src/store/app';
import { useTransactionPersistStore } from 'src/store/transaction';

Expand Down Expand Up @@ -46,7 +47,7 @@ const Feed: FC<FeedProps> = ({ publication }) => {
const comments = data?.publications?.items ?? [];
const pageInfo = data?.publications?.pageInfo;

const queuedCount = txnQueue.filter((o) => o.type === 'NEW_COMMENT').length;
const queuedCount = txnQueue.filter((o) => o.type === OptmisticPublicationType.NewComment).length;
const totalComments = comments?.length + queuedCount;
const canComment = publication?.canComment?.result;

Expand Down Expand Up @@ -79,7 +80,7 @@ const Feed: FC<FeedProps> = ({ publication }) => {
<Card className="divide-y-[1px] dark:divide-gray-700" dataTestId="comments-feed">
{txnQueue.map(
(txn) =>
txn?.type === 'NEW_COMMENT' &&
txn?.type === OptmisticPublicationType.NewComment &&
txn?.parent === publication?.id && (
<div key={txn.id}>
<QueuedPublication txn={txn} />
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/components/Composer/NewPublication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import dynamic from 'next/dynamic';
import type { FC } from 'react';
import { useEffect, useState } from 'react';
import toast from 'react-hot-toast';
import { OptmisticPublicationType } from 'src/enums';
import { useAccessSettingsStore } from 'src/store/access-settings';
import { useAppStore } from 'src/store/app';
import { useCollectModuleStore } from 'src/store/collect-module';
Expand Down Expand Up @@ -179,7 +180,7 @@ const NewPublication: FC<NewPublicationProps> = ({ publication }) => {
return {
id: uuid(),
...(isComment && { parent: publication.id }),
type: isComment ? 'NEW_COMMENT' : 'NEW_POST',
type: isComment ? OptmisticPublicationType.NewComment : OptmisticPublicationType.NewPost,
txHash,
txId,
content: publicationContent,
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/components/Home/Highlights.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useFeedHighlightsQuery } from 'lens';
import type { FC } from 'react';
import { useState } from 'react';
import { useInView } from 'react-cool-inview';
import { OptmisticPublicationType } from 'src/enums';
import { useAppStore } from 'src/store/app';
import { useTransactionPersistStore } from 'src/store/transaction';

Expand Down Expand Up @@ -61,7 +62,7 @@ const Highlights: FC = () => {
<Card className="divide-y-[1px] dark:divide-gray-700">
{txnQueue.map(
(txn) =>
txn?.type === 'NEW_POST' && (
txn?.type === OptmisticPublicationType.NewPost && (
<div key={txn.id}>
<QueuedPublication txn={txn} />
</div>
Expand Down
3 changes: 1 addition & 2 deletions apps/web/src/components/Home/RecommendedProfiles.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { FollowSource } from '@components/Shared/Follow';
import UserProfileShimmer from '@components/Shared/Shimmer/UserProfileShimmer';
import UserProfile from '@components/Shared/UserProfile';
import { Card } from '@components/UI/Card';
Expand All @@ -13,7 +12,7 @@ import type { Profile } from 'lens';
import { useRecommendedProfilesQuery } from 'lens';
import type { FC } from 'react';
import { useState } from 'react';
import { MISCELLANEOUS } from 'src/tracking';
import { FollowSource, MISCELLANEOUS } from 'src/tracking';

import Suggested from './Suggested';

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Home/Suggested.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { FollowSource } from '@components/Shared/Follow';
import Loader from '@components/Shared/Loader';
import UserProfile from '@components/Shared/UserProfile';
import { EmptyState } from '@components/UI/EmptyState';
Expand All @@ -8,6 +7,7 @@ import { t } from '@lingui/macro';
import type { Profile } from 'lens';
import { useRecommendedProfilesQuery } from 'lens';
import type { FC } from 'react';
import { FollowSource } from 'src/tracking';

const Suggested: FC = () => {
const { data, loading, error } = useRecommendedProfilesQuery();
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/components/Home/Timeline/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { FeedEventItemType, useTimelineQuery } from 'lens';
import type { FC } from 'react';
import { useState } from 'react';
import { useInView } from 'react-cool-inview';
import { OptmisticPublicationType } from 'src/enums';
import { useAppStore } from 'src/store/app';
import { useTimelinePersistStore, useTimelineStore } from 'src/store/timeline';
import { useTransactionPersistStore } from 'src/store/transaction';
Expand Down Expand Up @@ -81,7 +82,7 @@ const Timeline: FC = () => {
<Card className="divide-y-[1px] dark:divide-gray-700">
{txnQueue.map(
(txn) =>
txn?.type === 'NEW_POST' && (
txn?.type === OptmisticPublicationType.NewPost && (
<div key={txn.id}>
<QueuedPublication txn={txn} />
</div>
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/components/Messages/MessageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import type { Profile } from 'lens';
import { useRouter } from 'next/router';
import type { FC } from 'react';
import { useEffect, useState } from 'react';
import { FollowSource } from 'src/tracking';

import Follow, { FollowSource } from '../Shared/Follow';
import Follow from '../Shared/Follow';

interface MessageHeaderProps {
profile?: Profile;
Expand Down
3 changes: 1 addition & 2 deletions apps/web/src/components/Notification/FeedType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import {
import { Mixpanel } from '@lib/mixpanel';
import { t } from '@lingui/macro';
import type { Dispatch, FC } from 'react';
import { NotificationType } from 'src/enums';
import { NOTIFICATION } from 'src/tracking';

import { NotificationType } from './List';

interface FeedTypeProps {
setFeedType: Dispatch<string>;
feedType: string;
Expand Down
9 changes: 1 addition & 8 deletions apps/web/src/components/Notification/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { CustomFiltersTypes, NotificationTypes, useNotificationsQuery } from 'le
import type { FC } from 'react';
import { useState } from 'react';
import { useInView } from 'react-cool-inview';
import { NotificationType } from 'src/enums';
import { useAppStore } from 'src/store/app';

import NotificationShimmer from './Shimmer';
Expand All @@ -26,14 +27,6 @@ import LikeNotification from './Type/LikeNotification';
import MentionNotification from './Type/MentionNotification';
import MirrorNotification from './Type/MirrorNotification';

export enum NotificationType {
All = 'ALL',
Mentions = 'MENTIONS',
Comments = 'COMMENTS',
Likes = 'LIKES',
Collects = 'COLLECTS'
}

interface ListProps {
feedType: string;
}
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/components/Profile/Details.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Message from '@components/Profile/Message';
import Follow, { FollowSource } from '@components/Shared/Follow';
import Follow from '@components/Shared/Follow';
import Markup from '@components/Shared/Markup';
import Slug from '@components/Shared/Slug';
import SuperFollow from '@components/Shared/SuperFollow';
Expand All @@ -25,6 +25,7 @@ import type { Dispatch, FC, ReactElement } from 'react';
import { useState } from 'react';
import { useAppStore } from 'src/store/app';
import { useMessageStore } from 'src/store/message';
import { FollowSource } from 'src/tracking';
import formatAddress from 'utils/formatAddress';
import formatHandle from 'utils/formatHandle';
import getAvatar from 'utils/getAvatar';
Expand Down
9 changes: 1 addition & 8 deletions apps/web/src/components/Profile/Feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,11 @@ import { PublicationMainFocus, PublicationTypes, useProfileFeedQuery } from 'len
import type { FC } from 'react';
import { useState } from 'react';
import { useInView } from 'react-cool-inview';
import { ProfileFeedType } from 'src/enums';
import { useAppStore } from 'src/store/app';
import { useProfileFeedStore } from 'src/store/profile-feed';
import formatHandle from 'utils/formatHandle';

export enum ProfileFeedType {
Feed = 'FEED',
Replies = 'REPLIES',
Media = 'MEDIA',
Collects = 'COLLECTS',
Nft = 'NFT'
}

interface FeedProps {
profile: Profile;
type: ProfileFeedType.Feed | ProfileFeedType.Replies | ProfileFeedType.Media | ProfileFeedType.Collects;
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Profile/FeedType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
import { Mixpanel } from '@lib/mixpanel';
import { t } from '@lingui/macro';
import type { Dispatch, FC } from 'react';
import { ProfileFeedType } from 'src/enums';
import { PROFILE } from 'src/tracking';

import { ProfileFeedType } from './Feed';
import MediaFilter from './Filters/MediaFilter';

interface FeedTypeProps {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Profile/Followers.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { FollowSource } from '@components/Shared/Follow';
import Loader from '@components/Shared/Loader';
import UserProfile from '@components/Shared/UserProfile';
import WalletProfile from '@components/Shared/WalletProfile';
Expand All @@ -11,6 +10,7 @@ import { useFollowersQuery } from 'lens';
import type { FC } from 'react';
import { useState } from 'react';
import { useInView } from 'react-cool-inview';
import { FollowSource } from 'src/tracking';
import formatHandle from 'utils/formatHandle';

interface FollowersProps {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Profile/Following.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { FollowSource } from '@components/Shared/Follow';
import Loader from '@components/Shared/Loader';
import UserProfile from '@components/Shared/UserProfile';
import { EmptyState } from '@components/UI/EmptyState';
Expand All @@ -10,6 +9,7 @@ import { useFollowingQuery } from 'lens';
import type { FC } from 'react';
import { useState } from 'react';
import { useInView } from 'react-cool-inview';
import { FollowSource } from 'src/tracking';
import formatHandle from 'utils/formatHandle';

interface FollowingProps {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Profile/MutualFollowers/List.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { FollowSource } from '@components/Shared/Follow';
import Loader from '@components/Shared/Loader';
import UserProfile from '@components/Shared/UserProfile';
import { ErrorMessage } from '@components/UI/ErrorMessage';
Expand All @@ -9,6 +8,7 @@ import type { FC } from 'react';
import { useState } from 'react';
import { useInView } from 'react-cool-inview';
import { useAppStore } from 'src/store/app';
import { FollowSource } from 'src/tracking';

interface MutualFollowersListProps {
profileId: string;
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/components/Profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useProfileQuery } from 'lens';
import type { NextPage } from 'next';
import { useRouter } from 'next/router';
import { useEffect, useState } from 'react';
import { ProfileFeedType } from 'src/enums';
import Custom404 from 'src/pages/404';
import Custom500 from 'src/pages/500';
import { useAppStore } from 'src/store/app';
Expand All @@ -19,7 +20,7 @@ import isFeatureEnabled from 'utils/isFeatureEnabled';

import Cover from './Cover';
import Details from './Details';
import Feed, { ProfileFeedType } from './Feed';
import Feed from './Feed';
import FeedType from './FeedType';
import FollowDialog from './FollowDialog';
import NftGallery from './NftGallery';
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Publication/RelevantPeople.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { FollowSource } from '@components/Shared/Follow';
import UserProfileShimmer from '@components/Shared/Shimmer/UserProfileShimmer';
import UserProfile from '@components/Shared/UserProfile';
import { Card } from '@components/UI/Card';
Expand All @@ -8,6 +7,7 @@ import { ALL_HANDLES_REGEX, HANDLE_SANITIZE_REGEX } from 'data/constants';
import type { Profile, Publication } from 'lens';
import { useRelevantPeopleQuery } from 'lens';
import type { FC } from 'react';
import { FollowSource } from 'src/tracking';
import formatHandle from 'utils/formatHandle';

interface RelevantPeopleProps {
Expand Down
15 changes: 0 additions & 15 deletions apps/web/src/components/Shared/Follow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,6 @@ import { PROFILE } from 'src/tracking';
import getSignature from 'utils/getSignature';
import { useAccount, useContractWrite, useSignTypedData } from 'wagmi';

export enum FollowSource {
WHO_TO_FOLLOW = 'who_to_follow',
WHO_TO_FOLLOW_MODAL = 'who_to_follow_modal',
LIKES_MODAL = 'likes_modal',
MIRRORS_MODAL = 'mirrors_modal',
COLLECTORS_MODAL = 'collectors_modal',
FOLLOWERS_MODAL = 'followers_modal',
FOLLOWING_MODAL = 'following_modal',
MUTUAL_FOLLOWERS_MODAL = 'mutual_followers_modal',
PUBLICATION_RELEVANT_PROFILES = 'publication_relevant_profiles',
DIRECT_MESSAGE_HEADER = 'direct_message_header',
PROFILE_PAGE = 'profile_page',
PROFILE_POPOVER = 'profile_popover'
}

interface FollowProps {
profile: Profile;
setFollowing: Dispatch<boolean>;
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Shared/Modal/Collectors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { useCollectorsQuery } from 'lens';
import type { FC } from 'react';
import { useState } from 'react';
import { useInView } from 'react-cool-inview';
import { FollowSource } from 'src/tracking';

import { FollowSource } from '../Follow';
import Loader from '../Loader';

interface CollectorsProps {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Shared/Modal/Likes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { useLikesQuery } from 'lens';
import type { FC } from 'react';
import { useState } from 'react';
import { useInView } from 'react-cool-inview';
import { FollowSource } from 'src/tracking';

import { FollowSource } from '../Follow';
import Loader from '../Loader';

interface LikesProps {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Shared/Modal/Mirrors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { useMirrorsQuery } from 'lens';
import type { FC } from 'react';
import { useState } from 'react';
import { useInView } from 'react-cool-inview';
import { FollowSource } from 'src/tracking';

import { FollowSource } from '../Follow';
import Loader from '../Loader';

interface MirrorsProps {
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/components/Shared/UserPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import type { Profile } from 'lens';
import { useProfileLazyQuery } from 'lens';
import type { FC, ReactNode } from 'react';
import { useState } from 'react';
import { FollowSource } from 'src/tracking';
import formatHandle from 'utils/formatHandle';
import getAvatar from 'utils/getAvatar';
import isVerified from 'utils/isVerified';
import nFormatter from 'utils/nFormatter';

import Follow, { FollowSource } from './Follow';
import Follow from './Follow';
import Markup from './Markup';
import Slug from './Slug';
import SuperFollow from './SuperFollow';
Expand Down
20 changes: 20 additions & 0 deletions apps/web/src/enums.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export enum OptmisticPublicationType {
NewPost = 'NEW_POST',
NewComment = 'NEW_COMMENT'
}

export enum NotificationType {
All = 'ALL',
Mentions = 'MENTIONS',
Comments = 'COMMENTS',
Likes = 'LIKES',
Collects = 'COLLECTS'
}

export enum ProfileFeedType {
Feed = 'FEED',
Replies = 'REPLIES',
Media = 'MEDIA',
Collects = 'COLLECTS',
Nft = 'NFT'
}
16 changes: 16 additions & 0 deletions apps/web/src/tracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,19 @@ export const ONBOARDING = {
NAVIGATE_UPDATE_PROFILE: 'Navigate to update profile from onboarding',
NAVIGATE_UPDATE_PROFILE_INTERESTS: 'Navigate to update profile interests from onboarding'
};

// enums
export enum FollowSource {
WHO_TO_FOLLOW = 'who_to_follow',
WHO_TO_FOLLOW_MODAL = 'who_to_follow_modal',
LIKES_MODAL = 'likes_modal',
MIRRORS_MODAL = 'mirrors_modal',
COLLECTORS_MODAL = 'collectors_modal',
FOLLOWERS_MODAL = 'followers_modal',
FOLLOWING_MODAL = 'following_modal',
MUTUAL_FOLLOWERS_MODAL = 'mutual_followers_modal',
PUBLICATION_RELEVANT_PROFILES = 'publication_relevant_profiles',
DIRECT_MESSAGE_HEADER = 'direct_message_header',
PROFILE_PAGE = 'profile_page',
PROFILE_POPOVER = 'profile_popover'
}

0 comments on commit 3fab7b4

Please sign in to comment.