fix purity errors
This commit is contained in:
@@ -140,6 +140,11 @@ function sortSeenPosts(postA: SeenPost, postB: SeenPost): 0 | 1 | -1 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const random1 = Math.random()
|
||||||
|
const random2 = Math.random()
|
||||||
|
const random3 = Math.random()
|
||||||
|
const random4 = Math.random()
|
||||||
|
|
||||||
function useExperimentalSuggestedUsersQuery() {
|
function useExperimentalSuggestedUsersQuery() {
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const userActionSnapshot = userActionHistory.useActionHistorySnapshot()
|
const userActionSnapshot = userActionHistory.useActionHistorySnapshot()
|
||||||
@@ -153,10 +158,10 @@ function useExperimentalSuggestedUsersQuery() {
|
|||||||
if (followSuggestions.length > 0) {
|
if (followSuggestions.length > 0) {
|
||||||
suggestedDids = [
|
suggestedDids = [
|
||||||
// It's ok if these will pick the same item (weighed by its frequency)
|
// It's ok if these will pick the same item (weighed by its frequency)
|
||||||
followSuggestions[Math.floor(Math.random() * followSuggestions.length)],
|
followSuggestions[Math.floor(random1 * followSuggestions.length)],
|
||||||
followSuggestions[Math.floor(Math.random() * followSuggestions.length)],
|
followSuggestions[Math.floor(random2 * followSuggestions.length)],
|
||||||
followSuggestions[Math.floor(Math.random() * followSuggestions.length)],
|
followSuggestions[Math.floor(random3 * followSuggestions.length)],
|
||||||
followSuggestions[Math.floor(Math.random() * followSuggestions.length)],
|
followSuggestions[Math.floor(random4 * followSuggestions.length)],
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
const seenDids = seen
|
const seenDids = seen
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import {useInitAgeAssurance} from '#/state/ageAssurance/useInitAgeAssurance'
|
|||||||
import {logger} from '#/state/ageAssurance/util'
|
import {logger} from '#/state/ageAssurance/util'
|
||||||
import {useLanguagePrefs} from '#/state/preferences'
|
import {useLanguagePrefs} from '#/state/preferences'
|
||||||
import {useSession} from '#/state/session'
|
import {useSession} from '#/state/session'
|
||||||
|
import {useTickEveryMinute} from '#/state/shell'
|
||||||
import {atoms as a, useTheme, web} from '#/alf'
|
import {atoms as a, useTheme, web} from '#/alf'
|
||||||
import {Admonition} from '#/components/Admonition'
|
import {Admonition} from '#/components/Admonition'
|
||||||
import {AgeAssuranceBadge} from '#/components/ageAssurance/AgeAssuranceBadge'
|
import {AgeAssuranceBadge} from '#/components/ageAssurance/AgeAssuranceBadge'
|
||||||
@@ -73,10 +74,11 @@ function Inner() {
|
|||||||
const getTimeAgo = useGetTimeAgo()
|
const getTimeAgo = useGetTimeAgo()
|
||||||
const tlds = useTLDs()
|
const tlds = useTLDs()
|
||||||
const createSupportLink = useCreateSupportLink()
|
const createSupportLink = useCreateSupportLink()
|
||||||
|
const tick = useTickEveryMinute()
|
||||||
|
|
||||||
const wasRecentlyInitiated =
|
const wasRecentlyInitiated =
|
||||||
lastInitiatedAt &&
|
lastInitiatedAt &&
|
||||||
new Date(lastInitiatedAt).getTime() > Date.now() - 5 * 60 * 1000 // 5 minutes
|
new Date(lastInitiatedAt).getTime() > tick - 5 * 60 * 1000 // 5 minutes
|
||||||
|
|
||||||
const [success, setSuccess] = useState(false)
|
const [success, setSuccess] = useState(false)
|
||||||
const [email, setEmail] = useState(currentAccount?.email || '')
|
const [email, setEmail] = useState(currentAccount?.email || '')
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {sanitizeHandle} from '#/lib/strings/handles'
|
|||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {isAndroid} from '#/platform/detection'
|
import {isAndroid} from '#/platform/detection'
|
||||||
import {useAgent, useSession} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
|
import {useTickEveryMinute} from '#/state/shell'
|
||||||
import * as Toast from '#/view/com/util/Toast'
|
import * as Toast from '#/view/com/util/Toast'
|
||||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||||
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||||
@@ -126,6 +127,7 @@ function Label({
|
|||||||
? sanitizeHandle(labeler.creator.handle, '@')
|
? sanitizeHandle(labeler.creator.handle, '@')
|
||||||
: label.src
|
: label.src
|
||||||
const timeDiff = useGetTimeAgo({future: true})
|
const timeDiff = useGetTimeAgo({future: true})
|
||||||
|
const tick = useTickEveryMinute()
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
@@ -198,7 +200,7 @@ function Label({
|
|||||||
a.italic,
|
a.italic,
|
||||||
t.atoms.text_contrast_medium,
|
t.atoms.text_contrast_medium,
|
||||||
]}>
|
]}>
|
||||||
<Trans>Expires in {timeDiff(Date.now(), label.exp)}</Trans>
|
<Trans>Expires in {timeDiff(tick, label.exp)}</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ const OrderedForms = [
|
|||||||
export const Login = ({onPressBack}: {onPressBack: () => void}) => {
|
export const Login = ({onPressBack}: {onPressBack: () => void}) => {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const failedAttemptCountRef = useRef(0)
|
const failedAttemptCountRef = useRef(0)
|
||||||
const startTimeRef = useRef(Date.now())
|
const [startTime] = useState(() => Date.now())
|
||||||
|
|
||||||
const {accounts} = useSession()
|
const {accounts} = useSession()
|
||||||
const {requestedAccountSwitchTo} = useLoggedOutView()
|
const {requestedAccountSwitchTo} = useLoggedOutView()
|
||||||
@@ -118,7 +118,7 @@ export const Login = ({onPressBack}: {onPressBack: () => void}) => {
|
|||||||
const onAttemptSuccess = () => {
|
const onAttemptSuccess = () => {
|
||||||
logEvent('signin:success', {
|
logEvent('signin:success', {
|
||||||
isUsingCustomProvider: serviceUrl !== DEFAULT_SERVICE,
|
isUsingCustomProvider: serviceUrl !== DEFAULT_SERVICE,
|
||||||
timeTakenSeconds: Math.round((Date.now() - startTimeRef.current) / 1000),
|
timeTakenSeconds: Math.round((Date.now() - startTime) / 1000),
|
||||||
failedAttemptsCount: failedAttemptCountRef.current,
|
failedAttemptsCount: failedAttemptCountRef.current,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {useEffect, useMemo, useRef} from 'react'
|
import {useEffect, useMemo, useRef, useState} from 'react'
|
||||||
import {WebView, type WebViewNavigation} from 'react-native-webview'
|
import {WebView, type WebViewNavigation} from 'react-native-webview'
|
||||||
import {type ShouldStartLoadRequest} from 'react-native-webview/lib/WebViewTypes'
|
import {type ShouldStartLoadRequest} from 'react-native-webview/lib/WebViewTypes'
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ export function CaptchaWebView({
|
|||||||
onSuccess: (code: string) => void
|
onSuccess: (code: string) => void
|
||||||
onError: (error: unknown) => void
|
onError: (error: unknown) => void
|
||||||
}) {
|
}) {
|
||||||
const startedAt = useRef(Date.now())
|
const [startedAt] = useState(() => Date.now())
|
||||||
const successTo = useRef<NodeJS.Timeout>(undefined)
|
const successTo = useRef<NodeJS.Timeout>(undefined)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -72,7 +72,7 @@ export function CaptchaWebView({
|
|||||||
// We want to delay the completion of this screen ever so slightly so that it doesn't appear to be a glitch if it completes too fast
|
// We want to delay the completion of this screen ever so slightly so that it doesn't appear to be a glitch if it completes too fast
|
||||||
wasSuccessful.current = true
|
wasSuccessful.current = true
|
||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
const timeTaken = now - startedAt.current
|
const timeTaken = now - startedAt
|
||||||
if (timeTaken < MIN_DELAY) {
|
if (timeTaken < MIN_DELAY) {
|
||||||
successTo.current = setTimeout(() => {
|
successTo.current = setTimeout(() => {
|
||||||
onSuccess(code)
|
onSuccess(code)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const stateContext = React.createContext<StateContext>(0)
|
|||||||
stateContext.displayName = 'TickEveryMinuteContext'
|
stateContext.displayName = 'TickEveryMinuteContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const [tick, setTick] = React.useState(Date.now())
|
const [tick, setTick] = React.useState(() => Date.now())
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const i = setInterval(() => {
|
const i = setInterval(() => {
|
||||||
setTick(Date.now())
|
setTick(Date.now())
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {useMemo} from 'react'
|
import {useState} from 'react'
|
||||||
import {
|
import {
|
||||||
type DimensionValue,
|
type DimensionValue,
|
||||||
type StyleProp,
|
type StyleProp,
|
||||||
@@ -283,7 +283,7 @@ export function ChatListItemLoadingPlaceholder({
|
|||||||
style?: StyleProp<ViewStyle>
|
style?: StyleProp<ViewStyle>
|
||||||
}) {
|
}) {
|
||||||
const t = useTheme_NEW()
|
const t = useTheme_NEW()
|
||||||
const random = useMemo(() => Math.random(), [])
|
const [random] = useState(() => Math.random())
|
||||||
return (
|
return (
|
||||||
<View style={[a.flex_row, a.gap_md, a.px_lg, a.mt_lg, t.atoms.bg, style]}>
|
<View style={[a.flex_row, a.gap_md, a.px_lg, a.mt_lg, t.atoms.bg, style]}>
|
||||||
<LoadingPlaceholder width={52} height={52} style={a.rounded_full} />
|
<LoadingPlaceholder width={52} height={52} style={a.rounded_full} />
|
||||||
|
|||||||
Reference in New Issue
Block a user