Skip to content

Commit

Permalink
chore: add isFeatureEnabled (#739)
Browse files Browse the repository at this point in the history
  • Loading branch information
bigint authored Oct 5, 2022
1 parent 7329b45 commit de22a8d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/components/Composer/Post/New.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
VideoCameraIcon
} from '@heroicons/react/outline';
import getAvatar from '@lib/getAvatar';
import getFeatureEnabled from '@lib/getFeatureEnabled';
import isFeatureEnabled from '@lib/isFeatureEnabled';
import { FC, ReactNode, useState } from 'react';
import { useAppStore } from 'src/store/app';
import { usePublicationStore } from 'src/store/publication';
Expand Down Expand Up @@ -58,7 +58,7 @@ const NewPost: FC = () => {
<PencilAltIcon className="h-5 w-5" />
<span>What's happening?</span>
</button>
{getFeatureEnabled('composer-v2', currentProfile?.id) && (
{isFeatureEnabled('composer-v2', currentProfile?.id) && (
<div className="flex items-center space-x-5">
<Action
icon={<PhotographIcon className="h-5 w-5" />}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Messages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GridItemEight, GridItemFour, GridLayout } from '@components/UI/GridLayout';
import Seo from '@components/utils/Seo';
import getFeatureEnabled from '@lib/getFeatureEnabled';
import isFeatureEnabled from '@lib/isFeatureEnabled';
import { NextPage } from 'next';
import { APP_NAME } from 'src/constants';
import Custom404 from 'src/pages/404';
Expand All @@ -9,7 +9,7 @@ import { useAppStore } from 'src/store/app';
const Messages: NextPage = () => {
const currentProfile = useAppStore((state) => state.currentProfile);

if (!getFeatureEnabled('messages', currentProfile?.id)) {
if (!isFeatureEnabled('messages', currentProfile?.id)) {
return <Custom404 />;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/Shared/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import NotificationIcon from '@components/Notification/Icon';
import useStaffMode from '@components/utils/hooks/useStaffMode';
import { Disclosure } from '@headlessui/react';
import { MailIcon, MenuIcon, XIcon } from '@heroicons/react/outline';
import getFeatureEnabled from '@lib/getFeatureEnabled';
import hasPrideLogo from '@lib/hasPrideLogo';
import isFeatureEnabled from '@lib/isFeatureEnabled';
import clsx from 'clsx';
import Link from 'next/link';
import { useRouter } from 'next/router';
Expand Down Expand Up @@ -96,7 +96,7 @@ const Navbar: FC = () => {
<div className="flex gap-8 items-center">
{currentProfile ? (
<>
{getFeatureEnabled('messages', currentProfile?.id) && (
{isFeatureEnabled('messages', currentProfile?.id) && (
<Link href="/messages">
<MailIcon className="w-5 h-5 sm:w-6 sm:h-6" />
</Link>
Expand Down
4 changes: 2 additions & 2 deletions src/lib/getFeatureEnabled.ts → src/lib/isFeatureEnabled.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { featureFlags } from 'data/feature-flags';
import { IS_MAINNET } from 'src/constants';

const getFeatureEnabled = (featureKey: string, profileId: string): boolean => {
const isFeatureEnabled = (featureKey: string, profileId: string): boolean => {
const feature = featureFlags.find((feature) => feature.key === featureKey);

return IS_MAINNET ? feature?.enabledFor.includes(profileId) ?? false : true;
};

export default getFeatureEnabled;
export default isFeatureEnabled;

1 comment on commit de22a8d

@vercel
Copy link

@vercel vercel bot commented on de22a8d Oct 5, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.