Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove contest feature flag #9534

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ const CommunityNotFoundPage = lazy(
);

const CommonDomainRoutes = ({
contestEnabled,
weightedTopicsEnabled,
tokenizedCommunityEnabled,
}: RouteFeatureFlags) => [
Expand Down Expand Up @@ -420,45 +419,41 @@ const CommonDomainRoutes = ({
scoped: true,
})}
/>,
...(contestEnabled
? [
<Route
key="/:scope/manage/contests"
path="/:scope/manage/contests"
element={withLayout(AdminContestsPage, {
scoped: true,
})}
/>,
<Route
key="/:scope/manage/contests/launch"
path="/:scope/manage/contests/launch"
element={withLayout(ManageContest, {
scoped: true,
})}
/>,
<Route
key="/:scope/manage/contests/:contestAddress"
path="/:scope/manage/contests/:contestAddress"
element={withLayout(ManageContest, {
scoped: true,
})}
/>,
<Route
key="/:scope/contests"
path="/:scope/contests"
element={withLayout(Contests, {
scoped: true,
})}
/>,
<Route
key="/:scope/contests/:contestAddress"
path="/:scope/contests/:contestAddress"
element={withLayout(ContestPage, {
scoped: true,
})}
/>,
]
: []),
<Route
key="/:scope/manage/contests"
path="/:scope/manage/contests"
element={withLayout(AdminContestsPage, {
scoped: true,
})}
/>,
<Route
key="/:scope/manage/contests/launch"
path="/:scope/manage/contests/launch"
element={withLayout(ManageContest, {
scoped: true,
})}
/>,
<Route
key="/:scope/manage/contests/:contestAddress"
path="/:scope/manage/contests/:contestAddress"
element={withLayout(ManageContest, {
scoped: true,
})}
/>,
<Route
key="/:scope/contests"
path="/:scope/contests"
element={withLayout(Contests, {
scoped: true,
})}
/>,
<Route
key="/:scope/contests/:contestAddress"
path="/:scope/contests/:contestAddress"
element={withLayout(ContestPage, {
scoped: true,
})}
/>,
<Route
key="/:scope/analytics"
path="/:scope/analytics"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ const EditNewProfilePage = lazy(() => import('views/pages/edit_new_profile'));
const ProfilePageRedirect = lazy(() => import('views/pages/profile_redirect'));

const CustomDomainRoutes = ({
contestEnabled,
weightedTopicsEnabled,
tokenizedCommunityEnabled,
}: RouteFeatureFlags) => {
Expand Down Expand Up @@ -320,45 +319,41 @@ const CustomDomainRoutes = ({
scoped: true,
})}
/>,
...(contestEnabled
? [
<Route
key="/manage/contests"
path="/manage/contests"
element={withLayout(AdminContestsPage, {
scoped: true,
})}
/>,
<Route
key="/manage/contests/launch"
path="/manage/contests/launch"
element={withLayout(ManageContest, {
scoped: true,
})}
/>,
<Route
key="/manage/contests/:contestAddress"
path="/manage/contests/:contestAddress"
element={withLayout(ManageContest, {
scoped: true,
})}
/>,
<Route
key="/contests"
path="/contests"
element={withLayout(Contests, {
scoped: true,
})}
/>,
<Route
key="/:scope/contests/:contestAddress"
path="/:scope/contests/:contestAddress"
element={withLayout(ContestPage, {
scoped: true,
})}
/>,
]
: []),
<Route
key="/manage/contests"
path="/manage/contests"
element={withLayout(AdminContestsPage, {
scoped: true,
})}
/>,
<Route
key="/manage/contests/launch"
path="/manage/contests/launch"
element={withLayout(ManageContest, {
scoped: true,
})}
/>,
<Route
key="/manage/contests/:contestAddress"
path="/manage/contests/:contestAddress"
element={withLayout(ManageContest, {
scoped: true,
})}
/>,
<Route
key="/contests"
path="/contests"
element={withLayout(Contests, {
scoped: true,
})}
/>,
<Route
key="/:scope/contests/:contestAddress"
path="/:scope/contests/:contestAddress"
element={withLayout(ContestPage, {
scoped: true,
})}
/>,
<Route
key="/discord-callback"
path="/discord-callback"
Expand Down
3 changes: 0 additions & 3 deletions packages/commonwealth/client/scripts/navigation/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ import CommonDomainRoutes from './CommonDomainRoutes';
import GeneralRoutes from './GeneralRoutes';

export type RouteFeatureFlags = {
contestEnabled: boolean;
weightedTopicsEnabled: boolean;
tokenizedCommunityEnabled: boolean;
};

const Router = () => {
const client = OpenFeature.getClient();
const contestEnabled = client.getBooleanValue('contest', false);

const weightedTopicsEnabled = client.getBooleanValue('weightedTopics', false);

Expand All @@ -30,7 +28,6 @@ const Router = () => {
);

const flags = {
contestEnabled,
weightedTopicsEnabled,
tokenizedCommunityEnabled,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,22 @@ import { z } from 'zod';
import { GetAllContests } from '@hicommonwealth/schemas';
import { trpc } from 'utils/trpcClient';

type UseGetContestsQueryProps = z.infer<typeof GetAllContests.input> & {
enabled: boolean;
};
type UseGetContestsQueryProps = z.infer<typeof GetAllContests.input>;

const CONTESTS_STALE_TIME = 10 * 1_000; // 10 s

const useGetContestsQuery = ({
contest_id,
community_id,
running,
enabled,
}: UseGetContestsQueryProps) => {
return trpc.contest.getAllContests.useQuery(
{
contest_id,
community_id,
running,
},
{ enabled: enabled && !!community_id, staleTime: CONTESTS_STALE_TIME },
{ enabled: !!community_id, staleTime: CONTESTS_STALE_TIME },
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -53,7 +52,6 @@ const CARD_TYPES = {

export const AdminOnboardingSlider = () => {
const [isModalVisible, setIsModalVisible] = useState(false);
const contestEnabled = useFlag('contest');

const navigate = useCommonNavigate();

Expand Down Expand Up @@ -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 ||
Expand Down Expand Up @@ -163,7 +161,7 @@ export const AdminOnboardingSlider = () => {
headerText="Finish setting up your community"
onDismiss={() => setIsModalVisible(true)}
>
{contestEnabled && isCommunitySupported && (
{isCommunitySupported && (
<ActionCard
ctaText={CARD_TYPES['launch-contest'].ctaText}
title={CARD_TYPES['launch-contest'].title}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, useMemo, useState } from 'react';
Expand Down Expand Up @@ -49,7 +48,6 @@ const MIN_ETH_FOR_CONTEST_THREAD = 0.0005;
export const NewThreadForm = () => {
const navigate = useCommonNavigate();
const location = useLocation();
const contestsEnabled = useFlag('contest');

const [submitEntryChecked, setSubmitEntryChecked] = useState(false);

Expand All @@ -58,7 +56,7 @@ export const NewThreadForm = () => {
const communityId = app.activeChainId() || '';
const { data: topics = [], refetch: refreshTopics } = useFetchTopicsQuery({
communityId,
includeContestData: contestsEnabled,
includeContestData: true,
apiEnabled: !!communityId,
});

Expand Down Expand Up @@ -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 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<MarkdownEditorMethods | null>(null);

Expand All @@ -56,7 +54,7 @@ export const NewThreadForm = () => {
const communityId = app.activeChainId() || '';
const { data: topics = [], refetch: refreshTopics } = useFetchTopicsQuery({
communityId,
includeContestData: contestsEnabled,
includeContestData: true,
apiEnabled: !!communityId,
});

Expand Down Expand Up @@ -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 &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';

import { useFlag } from 'hooks/useFlag';
import { AssociatedContest } from 'models/Thread';

import ThreadContestTag from './ThreadContestTag';
Expand All @@ -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 (
<>
Expand Down
Loading
Loading