diff --git a/packages/commonwealth/client/scripts/helpers/feature-flags.ts b/packages/commonwealth/client/scripts/helpers/feature-flags.ts index 0e3d0900634..48c8a18d281 100644 --- a/packages/commonwealth/client/scripts/helpers/feature-flags.ts +++ b/packages/commonwealth/client/scripts/helpers/feature-flags.ts @@ -21,7 +21,6 @@ const buildFlag = (env: string | undefined) => { // WARN: for frontend work you MUST define these feature flags in // vite.config.ts (locally) or in Unleash (remote apps) or they won't be passed to the frontend. const featureFlags = { - contest: buildFlag(process.env.FLAG_CONTEST), contestDev: buildFlag(process.env.FLAG_CONTEST_DEV), weightedTopics: buildFlag(process.env.FLAG_WEIGHTED_TOPICS), knockPushNotifications: buildFlag( diff --git a/packages/commonwealth/client/scripts/navigation/CommonDomainRoutes.tsx b/packages/commonwealth/client/scripts/navigation/CommonDomainRoutes.tsx index 3e218fa3a19..25f4c48a5eb 100644 --- a/packages/commonwealth/client/scripts/navigation/CommonDomainRoutes.tsx +++ b/packages/commonwealth/client/scripts/navigation/CommonDomainRoutes.tsx @@ -117,7 +117,6 @@ const CommunityNotFoundPage = lazy( ); const CommonDomainRoutes = ({ - contestEnabled, weightedTopicsEnabled, tokenizedCommunityEnabled, }: RouteFeatureFlags) => [ @@ -420,45 +419,41 @@ const CommonDomainRoutes = ({ scoped: true, })} />, - ...(contestEnabled - ? [ - , - , - , - , - , - ] - : []), + , + , + , + , + , import('views/pages/edit_new_profile')); const ProfilePageRedirect = lazy(() => import('views/pages/profile_redirect')); const CustomDomainRoutes = ({ - contestEnabled, weightedTopicsEnabled, tokenizedCommunityEnabled, }: RouteFeatureFlags) => { @@ -320,45 +319,41 @@ const CustomDomainRoutes = ({ scoped: true, })} />, - ...(contestEnabled - ? [ - , - , - , - , - , - ] - : []), + , + , + , + , + , { const client = OpenFeature.getClient(); - const contestEnabled = client.getBooleanValue('contest', false); const weightedTopicsEnabled = client.getBooleanValue('weightedTopics', false); @@ -30,7 +28,6 @@ const Router = () => { ); const flags = { - contestEnabled, weightedTopicsEnabled, tokenizedCommunityEnabled, }; diff --git a/packages/commonwealth/client/scripts/state/api/contests/getContests.ts b/packages/commonwealth/client/scripts/state/api/contests/getContests.ts index ed43005ca3a..eeaa6dd9d2d 100644 --- a/packages/commonwealth/client/scripts/state/api/contests/getContests.ts +++ b/packages/commonwealth/client/scripts/state/api/contests/getContests.ts @@ -3,9 +3,7 @@ import { z } from 'zod'; import { GetAllContests } from '@hicommonwealth/schemas'; import { trpc } from 'utils/trpcClient'; -type UseGetContestsQueryProps = z.infer & { - enabled: boolean; -}; +type UseGetContestsQueryProps = z.infer; const CONTESTS_STALE_TIME = 10 * 1_000; // 10 s @@ -13,7 +11,6 @@ const useGetContestsQuery = ({ contest_id, community_id, running, - enabled, }: UseGetContestsQueryProps) => { return trpc.contest.getAllContests.useQuery( { @@ -21,7 +18,7 @@ const useGetContestsQuery = ({ community_id, running, }, - { enabled: enabled && !!community_id, staleTime: CONTESTS_STALE_TIME }, + { enabled: !!community_id, staleTime: CONTESTS_STALE_TIME }, ); }; diff --git a/packages/commonwealth/client/scripts/views/components/AdminOnboardingSlider/AdminOnboardingSlider.tsx b/packages/commonwealth/client/scripts/views/components/AdminOnboardingSlider/AdminOnboardingSlider.tsx index 23c8f95d967..1e07a92f7cf 100644 --- a/packages/commonwealth/client/scripts/views/components/AdminOnboardingSlider/AdminOnboardingSlider.tsx +++ b/packages/commonwealth/client/scripts/views/components/AdminOnboardingSlider/AdminOnboardingSlider.tsx @@ -4,7 +4,6 @@ import shape3Url from 'assets/img/shapes/shape3.svg'; import shape4Url from 'assets/img/shapes/shape4.svg'; import shape5Url from 'assets/img/shapes/shape5.svg'; import shape6Url from 'assets/img/shapes/shape6.svg'; -import { useFlag } from 'hooks/useFlag'; import { useCommonNavigate } from 'navigation/helpers'; import React, { useEffect, useState } from 'react'; import app from 'state'; @@ -53,7 +52,6 @@ const CARD_TYPES = { export const AdminOnboardingSlider = () => { const [isModalVisible, setIsModalVisible] = useState(false); - const contestEnabled = useFlag('contest'); const navigate = useCommonNavigate(); @@ -127,7 +125,7 @@ export const AdminOnboardingSlider = () => { commonProtocol.ValidChains.SepoliaBase, ].includes(community?.ChainNode?.eth_chain_id); const isContestActionCompleted = - contestEnabled && isCommunitySupported && contestsData?.length > 0; + isCommunitySupported && contestsData?.length > 0; const isSliderHidden = !communityId || @@ -163,7 +161,7 @@ export const AdminOnboardingSlider = () => { headerText="Finish setting up your community" onDismiss={() => setIsModalVisible(true)} > - {contestEnabled && isCommunitySupported && ( + {isCommunitySupported && ( { const navigate = useCommonNavigate(); const location = useLocation(); - const contestsEnabled = useFlag('contest'); const [submitEntryChecked, setSubmitEntryChecked] = useState(false); @@ -58,7 +56,7 @@ export const NewThreadForm = () => { const communityId = app.activeChainId() || ''; const { data: topics = [], refetch: refreshTopics } = useFetchTopicsQuery({ communityId, - includeContestData: contestsEnabled, + includeContestData: true, apiEnabled: !!communityId, }); @@ -234,12 +232,12 @@ export const NewThreadForm = () => { }); const contestThreadBannerVisible = - contestsEnabled && isContestAvailable && hasTopicOngoingContest; + isContestAvailable && hasTopicOngoingContest; const isDisabledBecauseOfContestsConsent = contestThreadBannerVisible && !submitEntryChecked; const contestTopicAffordanceVisible = - contestsEnabled && isContestAvailable && hasTopicOngoingContest; + isContestAvailable && hasTopicOngoingContest; const walletBalanceError = isContestAvailable && diff --git a/packages/commonwealth/client/scripts/views/components/NewThreadFormModern/NewThreadForm.tsx b/packages/commonwealth/client/scripts/views/components/NewThreadFormModern/NewThreadForm.tsx index a49282fa545..a267d27cec0 100644 --- a/packages/commonwealth/client/scripts/views/components/NewThreadFormModern/NewThreadForm.tsx +++ b/packages/commonwealth/client/scripts/views/components/NewThreadFormModern/NewThreadForm.tsx @@ -4,7 +4,6 @@ import { notifyError } from 'controllers/app/notifications'; import { SessionKeyError } from 'controllers/server/sessions'; import { parseCustomStages } from 'helpers'; import { detectURL, getThreadActionTooltipText } from 'helpers/threads'; -import { useFlag } from 'hooks/useFlag'; import useJoinCommunityBanner from 'hooks/useJoinCommunityBanner'; import { useCommonNavigate } from 'navigation/helpers'; import React, { useEffect, useRef, useState } from 'react'; @@ -45,7 +44,6 @@ const MIN_ETH_FOR_CONTEST_THREAD = 0.0005; export const NewThreadForm = () => { const navigate = useCommonNavigate(); const location = useLocation(); - const contestsEnabled = useFlag('contest'); const markdownEditorMethodsRef = useRef(null); @@ -56,7 +54,7 @@ export const NewThreadForm = () => { const communityId = app.activeChainId() || ''; const { data: topics = [], refetch: refreshTopics } = useFetchTopicsQuery({ communityId, - includeContestData: contestsEnabled, + includeContestData: true, apiEnabled: !!communityId, }); @@ -218,12 +216,12 @@ export const NewThreadForm = () => { }); const contestThreadBannerVisible = - contestsEnabled && isContestAvailable && hasTopicOngoingContest; + isContestAvailable && hasTopicOngoingContest; const isDisabledBecauseOfContestsConsent = contestThreadBannerVisible && !submitEntryChecked; const contestTopicAffordanceVisible = - contestsEnabled && isContestAvailable && hasTopicOngoingContest; + isContestAvailable && hasTopicOngoingContest; const walletBalanceError = isContestAvailable && diff --git a/packages/commonwealth/client/scripts/views/components/ThreadContestTag/ThreadContestTagContainer.tsx b/packages/commonwealth/client/scripts/views/components/ThreadContestTag/ThreadContestTagContainer.tsx index 6a40078aa56..2a198d02338 100644 --- a/packages/commonwealth/client/scripts/views/components/ThreadContestTag/ThreadContestTagContainer.tsx +++ b/packages/commonwealth/client/scripts/views/components/ThreadContestTag/ThreadContestTagContainer.tsx @@ -1,6 +1,5 @@ import React from 'react'; -import { useFlag } from 'hooks/useFlag'; import { AssociatedContest } from 'models/Thread'; import ThreadContestTag from './ThreadContestTag'; @@ -13,11 +12,9 @@ interface ThreadContestTagContainerProps { const ThreadContestTagContainer = ({ associatedContests, }: ThreadContestTagContainerProps) => { - const contestsEnabled = useFlag('contest'); - const contestWinners = getWinnersFromAssociatedContests(associatedContests); - const showContestWinnerTag = contestsEnabled && contestWinners.length > 0; + const showContestWinnerTag = contestWinners.length > 0; return ( <> diff --git a/packages/commonwealth/client/scripts/views/components/sidebar/AdminSection/AdminSection.tsx b/packages/commonwealth/client/scripts/views/components/sidebar/AdminSection/AdminSection.tsx index 49f993fc8e0..389c54fdffb 100644 --- a/packages/commonwealth/client/scripts/views/components/sidebar/AdminSection/AdminSection.tsx +++ b/packages/commonwealth/client/scripts/views/components/sidebar/AdminSection/AdminSection.tsx @@ -4,13 +4,11 @@ import { handleRedirectClicks } from 'helpers'; import { useCommonNavigate } from 'navigation/helpers'; import { matchRoutes, useLocation } from 'react-router-dom'; import app from 'state'; -import { useFlag } from '../../../../hooks/useFlag'; import { SidebarSectionGroup } from '../sidebar_section'; import type { SectionGroupAttrs, SidebarSectionAttrs } from '../types'; import { useSidebarTreeToggle } from '../useSidebarTreeToggle'; const AdminSection = () => { - const contestsEnabled = useFlag('contest'); const communityId = app.activeChainId() || ''; const navigate = useCommonNavigate(); @@ -149,32 +147,28 @@ const AdminSection = () => { }); }, }, - ...(contestsEnabled - ? [ - { - title: 'Contests', - containsChildren: false, - displayData: null, - hasDefaultToggle: false, - isActive: !!matchesContestsRoute, - isVisible: true, - isUpdated: false, - onClick: (e, toggle: boolean) => { - e.preventDefault(); - resetSidebarState(); - handleRedirectClicks( - navigate, - e, - `/manage/contests`, - communityId, - () => { - setToggleTree(`children.contests.toggledState`, toggle); - }, - ); - }, + { + title: 'Contests', + containsChildren: false, + displayData: null, + hasDefaultToggle: false, + isActive: !!matchesContestsRoute, + isVisible: true, + isUpdated: false, + onClick: (e, toggle: boolean) => { + e.preventDefault(); + resetSidebarState(); + handleRedirectClicks( + navigate, + e, + `/manage/contests`, + communityId, + () => { + setToggleTree(`children.contests.toggledState`, toggle); }, - ] - : []), + ); + }, + }, { title: 'Analytics', containsChildren: false, diff --git a/packages/commonwealth/client/scripts/views/components/sidebar/discussion_section.tsx b/packages/commonwealth/client/scripts/views/components/sidebar/discussion_section.tsx index 2f7959af947..b45be22ffed 100644 --- a/packages/commonwealth/client/scripts/views/components/sidebar/discussion_section.tsx +++ b/packages/commonwealth/client/scripts/views/components/sidebar/discussion_section.tsx @@ -1,7 +1,6 @@ import React from 'react'; import 'components/sidebar/index.scss'; -import { useFlag } from 'hooks/useFlag'; import { useCommonNavigate } from 'navigation/helpers'; import { matchRoutes, useLocation } from 'react-router-dom'; import app from 'state'; @@ -56,8 +55,6 @@ export const DiscussionSection = ({ const navigate = useCommonNavigate(); const location = useLocation(); - const contestsEnabled = useFlag('contest'); - const matchesDiscussionsRoute = matchRoutes( [{ path: '/discussions' }, { path: ':scope/discussions' }], location, @@ -145,7 +142,7 @@ export const DiscussionSection = ({ }, displayData: null, }, - ...(contestsEnabled && isContestAvailable + ...(isContestAvailable ? [ { title: 'Contests', @@ -195,9 +192,7 @@ export const DiscussionSection = ({ for (const topic of topics) { if (topic.featuredInSidebar) { const topicInvolvedInActiveContest = - contestsEnabled && - topic?.id && - topicIdsIncludedInContest.includes(topic.id); + topic?.id && topicIdsIncludedInContest.includes(topic.id); const discussionSectionGroup: SectionGroupAttrs = { title: topic.name, diff --git a/packages/commonwealth/client/scripts/views/pages/CommunityManagement/Contests/useCommunityContests.ts b/packages/commonwealth/client/scripts/views/pages/CommunityManagement/Contests/useCommunityContests.ts index 4dbb0b54f71..84d9eb1acc9 100644 --- a/packages/commonwealth/client/scripts/views/pages/CommunityManagement/Contests/useCommunityContests.ts +++ b/packages/commonwealth/client/scripts/views/pages/CommunityManagement/Contests/useCommunityContests.ts @@ -2,14 +2,14 @@ import app from 'state'; import { useGetContestsQuery } from 'state/api/contests'; import { useCommunityStake } from 'views/components/CommunityStake'; import { Contest } from 'views/pages/CommunityManagement/Contests/ContestsList'; -import { useFlag } from '../../../../hooks/useFlag'; const useCommunityContests = () => { - const enabled = useFlag('contest'); const { stakeEnabled } = useCommunityStake(); const { data: contestsData, isLoading: isContestDataLoading } = - useGetContestsQuery({ community_id: app.activeChainId() || '', enabled }); + useGetContestsQuery({ + community_id: app.activeChainId() || '', + }); // @ts-expect-error StrictNullChecks const isContestAvailable = !isContestDataLoading && contestsData?.length > 0; @@ -24,7 +24,7 @@ const useCommunityContests = () => { stakeEnabled, isContestAvailable, contestsData: contestsData as unknown as Contest[], - isContestDataLoading: isContestDataLoading && enabled, + isContestDataLoading: isContestDataLoading, getContestByAddress, }; }; diff --git a/packages/commonwealth/client/scripts/views/pages/discussions/HeaderWithFilters/HeaderWithFilters.tsx b/packages/commonwealth/client/scripts/views/pages/discussions/HeaderWithFilters/HeaderWithFilters.tsx index 39259c7f73c..7dd9ce51fe3 100644 --- a/packages/commonwealth/client/scripts/views/pages/discussions/HeaderWithFilters/HeaderWithFilters.tsx +++ b/packages/commonwealth/client/scripts/views/pages/discussions/HeaderWithFilters/HeaderWithFilters.tsx @@ -22,7 +22,6 @@ import { EditTopicModal } from 'views/modals/edit_topic_modal'; import { Contest } from 'views/pages/CommunityManagement/Contests/ContestsList'; import ContestCard from 'views/pages/CommunityManagement/Contests/ContestsList/ContestCard'; import useCommunityContests from 'views/pages/CommunityManagement/Contests/useCommunityContests'; -import { useFlag } from '../../../../hooks/useFlag'; import type Topic from '../../../../models/Topic'; import { ThreadFeaturedFilterTypes, @@ -58,7 +57,6 @@ export const HeaderWithFilters = ({ isOnArchivePage, activeContests, }: HeaderWithFiltersProps) => { - const contestsEnabled = useFlag('contest'); const navigate = useCommonNavigate(); const location = useLocation(); const [topicSelectedToEdit, setTopicSelectedToEdit] = useState< @@ -210,8 +208,6 @@ export const HeaderWithFilters = ({ } }; - const contestFiltersVisible = contestsEnabled && isContestAvailable; - return (
@@ -341,7 +337,7 @@ export const HeaderWithFilters = ({ onFilterSelect({ pickedTopic: item.value }); }} options={[ - ...(contestFiltersVisible + ...(isContestAvailable ? [{ type: 'header', label: 'Topics' }] : []), { @@ -354,7 +350,7 @@ export const HeaderWithFilters = ({ value: t.name, label: t.name, })), - ...(contestFiltersVisible + ...(isContestAvailable ? [ { type: 'header-divider', label: 'Contests' }, ...contestNameOptions, diff --git a/packages/commonwealth/client/vite.config.ts b/packages/commonwealth/client/vite.config.ts index 46846c4e3f4..70ec66e8376 100644 --- a/packages/commonwealth/client/vite.config.ts +++ b/packages/commonwealth/client/vite.config.ts @@ -33,7 +33,6 @@ export default defineConfig(({ mode }) => { // WARN: only used locally never in remote (Heroku) apps const featureFlags = { 'process.env.FLAG_NEW_EDITOR': JSON.stringify(env.FLAG_NEW_EDITOR), - 'process.env.FLAG_CONTEST': JSON.stringify(env.FLAG_CONTEST), 'process.env.FLAG_CONTEST_DEV': JSON.stringify(env.FLAG_CONTEST_DEV), 'process.env.FLAG_WEIGHTED_TOPICS': JSON.stringify( env.FLAG_WEIGHTED_TOPICS,