Bluesky app fork with some witchin' additions 馃挮
at readme-update 54 lines 1.7 kB view raw
1import {type AppBskyActorDefs} from '@atproto/api' 2 3import {type UsePreferencesQueryResponse} from '#/state/queries/preferences' 4import {type SessionAccount} from '#/state/session' 5import {type AnalyticsContextType} from '#/analytics' 6import {type Geolocation} from '#/geolocation' 7 8export type EnabledCheckProps = { 9 features: AnalyticsContextType['features'] 10 currentAccount: SessionAccount 11 currentProfile: AppBskyActorDefs.ProfileViewDetailed 12 preferences: UsePreferencesQueryResponse 13 geolocation: Geolocation 14} 15 16export function createIsEnabledCheck( 17 cb: (props: EnabledCheckProps) => boolean, 18) { 19 return cb 20} 21 22const ONE_DAY = 1000 * 60 * 60 * 24 23 24export function isDaysOld(days: number, createdAt?: string) { 25 /* 26 * Should never happen because we gate NUXs to only accounts with a valid 27 * profile and a `createdAt` (see `nuxs/index.tsx`). But if it ever did, the 28 * account is either old enough to be pre-onboarding, or some failure happened 29 * during account creation. Fail closed. - esb 30 */ 31 if (!createdAt) return false 32 33 const now = Date.now() 34 const then = new Date(createdAt).getTime() 35 const isOldEnough = then + ONE_DAY * days < now 36 37 if (isOldEnough) return true 38 return false 39} 40 41export function isExistingUserAsOf(date: string, createdAt?: string) { 42 /* 43 * Should never happen because we gate NUXs to only accounts with a valid 44 * profile and a `createdAt` (see `nuxs/index.tsx`). But if it ever did, the 45 * account is either old enough to be pre-onboarding, or some failure happened 46 * during account creation. Fail closed. - esb 47 */ 48 if (!createdAt) return false 49 50 const threshold = Date.parse(date) 51 const then = new Date(createdAt).getTime() 52 53 return then < threshold 54}