mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Add function for checking user flags
This commit is contained in:
parent
2a7087deab
commit
e4fb01785b
3 changed files with 24 additions and 10 deletions
|
|
@ -20,6 +20,7 @@ import { Recommendation } from '../../../lib/networking/queries/useGetLibraryIte
|
|||
import { Avatar } from '../../elements/Avatar'
|
||||
import { UserBasicData } from '../../../lib/networking/queries/useGetViewerQuery'
|
||||
import { AISummary } from './AISummary'
|
||||
import { userHasFeature } from '../../../lib/featureFlag'
|
||||
|
||||
type ArticleContainerProps = {
|
||||
viewer: UserBasicData
|
||||
|
|
@ -445,14 +446,16 @@ export function ArticleContainer(props: ArticleContainerProps): JSX.Element {
|
|||
recommendationsWithNotes={recommendationsWithNotes}
|
||||
/>
|
||||
)}
|
||||
<AISummary
|
||||
libraryItemId={props.article.id}
|
||||
idx="latest"
|
||||
fontFamily={styles.fontFamily}
|
||||
fontSize={styles.fontSize}
|
||||
lineHeight={styles.lineHeight}
|
||||
readerFontColor={styles.readerFontColor}
|
||||
/>
|
||||
{userHasFeature(props.viewer, 'ai-summaries') && (
|
||||
<AISummary
|
||||
libraryItemId={props.article.id}
|
||||
idx="latest"
|
||||
fontFamily={styles.fontFamily}
|
||||
fontSize={styles.fontSize}
|
||||
lineHeight={styles.lineHeight}
|
||||
readerFontColor={styles.readerFontColor}
|
||||
/>
|
||||
)}
|
||||
</VStack>
|
||||
<Article
|
||||
articleId={props.article.id}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import { HeaderToggleGridIcon } from '../../elements/icons/HeaderToggleGridIcon'
|
|||
import { HeaderToggleListIcon } from '../../elements/icons/HeaderToggleListIcon'
|
||||
import { HeaderToggleTLDRIcon } from '../../elements/icons/HeaderToggleTLDRIcon'
|
||||
import { UserBasicData } from '../../../lib/networking/queries/useGetViewerQuery'
|
||||
import { userHasFeature } from '../../../lib/featureFlag'
|
||||
|
||||
export type MultiSelectMode = 'off' | 'none' | 'some' | 'visible' | 'search'
|
||||
|
||||
|
|
@ -183,7 +184,7 @@ const HeaderControls = (props: LibraryHeaderProps): JSX.Element => {
|
|||
<SearchBox {...props} />
|
||||
|
||||
<SpanBox css={{ display: 'flex', ml: 'auto', gap: '10px' }}>
|
||||
{props.viewer?.features.includes('ai-summaries') && (
|
||||
{userHasFeature(props.viewer, 'ai-summaries') && (
|
||||
<Button
|
||||
title="TLDR Summaries"
|
||||
style="plainIcon"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,17 @@
|
|||
import { UserBasicData } from "./networking/queries/useGetViewerQuery"
|
||||
import { UserBasicData } from './networking/queries/useGetViewerQuery'
|
||||
|
||||
const VIP_USERS = ['jacksonh', 'satindar', 'hongbo', 'nat']
|
||||
|
||||
export const isVipUser = (user: UserBasicData): boolean => {
|
||||
return VIP_USERS.includes(user.profile.username)
|
||||
}
|
||||
|
||||
export const userHasFeature = (
|
||||
user: UserBasicData | undefined,
|
||||
feature: string
|
||||
): boolean => {
|
||||
if (!user) {
|
||||
return false
|
||||
}
|
||||
return user.features.includes(feature)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue