mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Pre-fetch realistic voice only if user is opted in
This commit is contained in:
parent
b0938ee96c
commit
d58fb63c87
1 changed files with 2 additions and 32 deletions
|
|
@ -1,12 +1,8 @@
|
|||
import { searchPages } from '../elastic/pages'
|
||||
import { Page, PageType } from '../elastic/types'
|
||||
import { SortBy, SortOrder } from '../utils/search'
|
||||
import { FeatureName, isOptedIn } from './features'
|
||||
|
||||
/*
|
||||
* We should not synthesize the page when:
|
||||
** 1. User has no recent listens the last 30 days
|
||||
** 2. User has a recent listen but the page was saved after the listen
|
||||
* We should synthesize the page when user is opted in to the feature
|
||||
*/
|
||||
export const shouldSynthesize = async (
|
||||
userId: string,
|
||||
|
|
@ -17,31 +13,5 @@ export const shouldSynthesize = async (
|
|||
return false
|
||||
}
|
||||
|
||||
if (await isOptedIn(FeatureName.UltraRealisticVoice, userId)) {
|
||||
return true
|
||||
}
|
||||
|
||||
const [recentListenedPage, count] = (await searchPages(
|
||||
{
|
||||
dateFilters: [
|
||||
{
|
||||
field: 'listenedAt',
|
||||
startDate: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000),
|
||||
},
|
||||
],
|
||||
sort: {
|
||||
by: SortBy.LISTENED,
|
||||
order: SortOrder.DESCENDING,
|
||||
},
|
||||
size: 1,
|
||||
},
|
||||
userId
|
||||
)) || [[], 0]
|
||||
if (count === 0) {
|
||||
return false
|
||||
}
|
||||
return (
|
||||
!!recentListenedPage[0].listenedAt &&
|
||||
page.savedAt < recentListenedPage[0].listenedAt
|
||||
)
|
||||
return isOptedIn(FeatureName.UltraRealisticVoice, userId)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue