Add enable Digest button
This commit is contained in:
@ -80,7 +80,6 @@ export function useGetUserPersonalization(): UserPersonalizationResult {
|
||||
response.getUserPersonalization?.userPersonalization.digestConfig
|
||||
)
|
||||
) {
|
||||
console.log('invalid digest config')
|
||||
return {
|
||||
mutate,
|
||||
isLoading: false,
|
||||
|
||||
@ -34,6 +34,7 @@ import {
|
||||
} from '../../lib/networking/queries/useGetUserPersonalization'
|
||||
import { updateDigestConfigMutation } from '../../lib/networking/mutations/updateDigestConfigMutation'
|
||||
import { scheduleDigest } from '../../lib/networking/mutations/scheduleDigest'
|
||||
import { optInFeature } from '../../lib/networking/mutations/optIntoFeatureMutation'
|
||||
|
||||
const ACCOUNT_LIMIT = 50_000
|
||||
|
||||
@ -524,6 +525,7 @@ const BetaFeaturesSection = (): JSX.Element => {
|
||||
}
|
||||
|
||||
const DigestSection = (): JSX.Element => {
|
||||
const { viewerData, isLoading, mutate } = useGetViewerQuery()
|
||||
const [channelState, setChannelState] = useState({
|
||||
push: false,
|
||||
email: false,
|
||||
@ -532,7 +534,7 @@ const DigestSection = (): JSX.Element => {
|
||||
const {
|
||||
userPersonalization,
|
||||
isLoading: isDigestConfigLoading,
|
||||
mutate,
|
||||
mutate: mutatePersonalization,
|
||||
} = useGetUserPersonalization()
|
||||
|
||||
useEffect(() => {
|
||||
@ -545,6 +547,10 @@ const DigestSection = (): JSX.Element => {
|
||||
setChannelState({ ...initialState })
|
||||
}, [userPersonalization])
|
||||
|
||||
const hasDigest = useMemo(() => {
|
||||
return viewerData?.me?.featureList?.some((f) => f.name === 'ai-digest')
|
||||
}, [viewerData])
|
||||
|
||||
const handleDigestCheckboxChange = useCallback(
|
||||
(name: DigestChannel, checked: boolean) => {
|
||||
;(async () => {
|
||||
@ -588,11 +594,23 @@ const DigestSection = (): JSX.Element => {
|
||||
console.log('deleting daily digest job')
|
||||
}
|
||||
|
||||
mutate()
|
||||
mutatePersonalization()
|
||||
})()
|
||||
},
|
||||
[channelState]
|
||||
)
|
||||
|
||||
const requestDigestAccess = useCallback(() => {
|
||||
;(async () => {
|
||||
const result = await optInFeature({ name: 'ai-digest' })
|
||||
if (!result) {
|
||||
showErrorToast('Error enabling digest')
|
||||
return
|
||||
}
|
||||
mutate()
|
||||
})()
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<VStack
|
||||
css={{
|
||||
@ -616,13 +634,23 @@ const DigestSection = (): JSX.Element => {
|
||||
>
|
||||
Omnivore Digest is a free daily digest of some of your best recent
|
||||
library items. Omnivore filters and ranks all the items recently added
|
||||
them to your library, uses AI to summarize them, and creates a short
|
||||
email for you to review, or a daily podcast you can listen to in our iOS
|
||||
app. Note that if you sign up for Digest, your recent library items will
|
||||
be processed by an AI service (Anthropic, or OpenAI). Your highlights,
|
||||
to your library, uses AI to summarize them, and creates a short library
|
||||
item, email, or a daily podcast you can listen to in our iOS app.
|
||||
</StyledText>
|
||||
<StyledText
|
||||
style="footnote"
|
||||
css={{
|
||||
display: 'flex',
|
||||
gap: '5px',
|
||||
lineHeight: '22px',
|
||||
mt: '0px',
|
||||
}}
|
||||
>
|
||||
Note that if you sign up for Digest, your recent library items will be
|
||||
processed by an AI service (Anthropic, or OpenAI). Your highlights,
|
||||
notes, and labels will not be sent to the AI service
|
||||
</StyledText>
|
||||
{!isDigestConfigLoading && (
|
||||
{hasDigest && (
|
||||
<>
|
||||
<StyledText
|
||||
style="footnote"
|
||||
@ -668,6 +696,17 @@ const DigestSection = (): JSX.Element => {
|
||||
</StyledText>
|
||||
</>
|
||||
)}
|
||||
{!hasDigest && (
|
||||
<Button
|
||||
style="ctaDarkYellow"
|
||||
onClick={(event) => {
|
||||
requestDigestAccess()
|
||||
event.preventDefault()
|
||||
}}
|
||||
>
|
||||
Enable Digest
|
||||
</Button>
|
||||
)}
|
||||
</VStack>
|
||||
)
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ const StyledLabel = styled('label', {
|
||||
marginBottom: '5px',
|
||||
})
|
||||
|
||||
export default function Account(): JSX.Element {
|
||||
export default function BetaFeatures(): JSX.Element {
|
||||
const { viewerData, isLoading, mutate } = useGetViewerQuery()
|
||||
const [pageLoading, setPageLoading] = useState(false)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user