add polyfills

This commit is contained in:
Hailey
2025-07-18 01:28:37 -07:00
parent c9e3c5bf7d
commit 5336e4f2ef
8 changed files with 53 additions and 17 deletions
+2
View File
@@ -119,6 +119,7 @@
"@types/lodash.throttle": "^4.1.9",
"@types/node": "^20.14.3",
"@zxing/text-encoding": "^0.9.0",
"abortcontroller-polyfill": "^1.7.8",
"array.prototype.findlast": "^1.2.3",
"await-lock": "^2.2.2",
"babel-plugin-transform-remove-console": "^6.9.4",
@@ -130,6 +131,7 @@
"email-validator": "^2.0.4",
"emoji-mart": "^5.5.2",
"emoji-regex": "^10.4.0",
"event-target-polyfill": "^0.0.4",
"eventemitter3": "^5.0.1",
"expo": "53.0.11",
"expo-application": "~6.1.4",
+7 -3
View File
@@ -93,7 +93,7 @@ beginResolveGeolocation()
function InnerApp() {
const [isReady, setIsReady] = React.useState(false)
const {currentAccount} = useSession()
const {resumeSession} = useSessionApi()
const {resumeSession, resumeSessionOauth} = useSessionApi()
const theme = useColorModeTheme()
const {_} = useLingui()
const hasCheckedReferrer = useStarterPackEntry()
@@ -103,7 +103,11 @@ function InnerApp() {
async function onLaunch(account?: SessionAccount) {
try {
if (account) {
await resumeSession(account)
if (true) {
await resumeSessionOauth(account)
} else {
await resumeSession(account)
}
} else {
await tryFetchGates(undefined, 'prefer-fresh-gates')
}
@@ -115,7 +119,7 @@ function InnerApp() {
}
const account = readLastActiveAccount()
onLaunch(account)
}, [resumeSession])
}, [resumeSession, resumeSessionOauth])
useEffect(() => {
return listenSessionDropped(() => {
+7 -3
View File
@@ -72,7 +72,7 @@ beginResolveGeolocation()
function InnerApp() {
const [isReady, setIsReady] = React.useState(false)
const {currentAccount} = useSession()
const {resumeSession} = useSessionApi()
const {resumeSession, resumeSessionOauth} = useSessionApi()
const theme = useColorModeTheme()
const {_} = useLingui()
const hasCheckedReferrer = useStarterPackEntry()
@@ -82,7 +82,11 @@ function InnerApp() {
async function onLaunch(account?: SessionAccount) {
try {
if (account) {
await resumeSession(account)
if (true) {
await resumeSessionOauth(account)
} else {
await resumeSession(account)
}
}
} catch (e) {
logger.error(`session: resumeSession failed`, {message: e})
@@ -92,7 +96,7 @@ function InnerApp() {
}
const account = readLastActiveAccount()
onLaunch(account)
}, [resumeSession])
}, [resumeSession, resumeSessionOauth])
useEffect(() => {
return listenSessionDropped(() => {
+9 -5
View File
@@ -4,16 +4,16 @@ import {useLingui} from '@lingui/react'
import {logger} from '#/logger'
import {isWeb} from '#/platform/detection'
import {SessionAccount, useSessionApi} from '#/state/session'
import {type SessionAccount, useSessionApi} from '#/state/session'
import {useLoggedOutViewControls} from '#/state/shell/logged-out'
import * as Toast from '#/view/com/util/Toast'
import {logEvent} from '../statsig/statsig'
import {LogEvents} from '../statsig/statsig'
import {type LogEvents} from '../statsig/statsig'
export function useAccountSwitcher() {
const [pendingDid, setPendingDid] = useState<string | null>(null)
const {_} = useLingui()
const {resumeSession} = useSessionApi()
const {resumeSession, resumeSessionOauth} = useSessionApi()
const {requestSwitchToAccount} = useLoggedOutViewControls()
const onPressSwitchAccount = useCallback(
@@ -36,7 +36,11 @@ export function useAccountSwitcher() {
// So we change the URL ourselves. The navigator will pick it up on remount.
history.pushState(null, '', '/')
}
await resumeSession(account)
if (true) {
await resumeSessionOauth(account)
} else {
await resumeSession(account)
}
logEvent('account:loggedIn', {logContext, withPassword: false})
Toast.show(_(msg`Signed in as @${account.handle}`))
} else {
@@ -59,7 +63,7 @@ export function useAccountSwitcher() {
setPendingDid(null)
}
},
[_, resumeSession, requestSwitchToAccount, pendingDid],
[_, resumeSession, resumeSessionOauth, requestSwitchToAccount, pendingDid],
)
return {onPressSwitchAccount, pendingDid}
+2
View File
@@ -1,5 +1,7 @@
import 'react-native-url-polyfill/auto'
import 'fast-text-encoding'
import 'abortcontroller-polyfill/dist/polyfill-patch-fetch'
import 'event-target-polyfill'
export {}
/**
+8 -3
View File
@@ -5,7 +5,7 @@ import {useLingui} from '@lingui/react'
import {logEvent} from '#/lib/statsig/statsig'
import {logger} from '#/logger'
import {SessionAccount, useSession, useSessionApi} from '#/state/session'
import {type SessionAccount, useSession, useSessionApi} from '#/state/session'
import {useLoggedOutViewControls} from '#/state/shell/logged-out'
import * as Toast from '#/view/com/util/Toast'
import {atoms as a} from '#/alf'
@@ -24,7 +24,7 @@ export const ChooseAccountForm = ({
const [pendingDid, setPendingDid] = React.useState<string | null>(null)
const {_} = useLingui()
const {currentAccount} = useSession()
const {resumeSession} = useSessionApi()
const {resumeSession, resumeSessionOauth} = useSessionApi()
const {setShowLoggedOut} = useLoggedOutViewControls()
const onSelect = React.useCallback(
@@ -45,7 +45,11 @@ export const ChooseAccountForm = ({
}
try {
setPendingDid(account.did)
await resumeSession(account)
if (true) {
resumeSessionOauth(account)
} else {
await resumeSession(account)
}
logEvent('account:loggedIn', {
logContext: 'ChooseAccountForm',
withPassword: false,
@@ -64,6 +68,7 @@ export const ChooseAccountForm = ({
[
currentAccount,
resumeSession,
resumeSessionOauth,
pendingDid,
onSelectAccount,
setShowLoggedOut,
+8 -3
View File
@@ -272,7 +272,11 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
)
if (syncedAccount && syncedAccount.refreshJwt) {
if (syncedAccount.did !== state.currentAgentState.did) {
resumeSession(syncedAccount)
if (true) {
resumeSessionOauth(syncedAccount)
} else {
resumeSession(syncedAccount)
}
} else {
const agent = state.currentAgentState.agent as BskyAgent
const prevSession = agent.session
@@ -286,7 +290,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
}
}
})
}, [state, resumeSession])
}, [state, resumeSession, resumeSessionOauth])
const stateContext = React.useMemo(
() => ({
@@ -335,7 +339,8 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
addSessionDebugLog({type: 'agent:switch', prevAgent, nextAgent: agent})
// We never reuse agents so let's fully neutralize the previous one.
// This ensures it won't try to consume any refresh tokens.
prevAgent.dispose()
// TODO: this is a hack!
prevAgent.dispose?.()
}
}, [agent])
+10
View File
@@ -8070,6 +8070,11 @@ abort-controller@^3.0.0:
dependencies:
event-target-shim "^5.0.0"
abortcontroller-polyfill@^1.7.8:
version "1.7.8"
resolved "https://registry.yarnpkg.com/abortcontroller-polyfill/-/abortcontroller-polyfill-1.7.8.tgz#fe8d4370403f02e2aa37e3d2b0b178bae9d83f49"
integrity sha512-9f1iZ2uWh92VcrU9Y8x+LdM4DLj75VE0MJB8zuF1iUnroEptStw+DQ8EQPMUdfe5k+PkB1uUfDQfWbhstH8LrQ==
accepts@^1.3.7, accepts@^1.3.8, accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.8:
version "1.3.8"
resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e"
@@ -11153,6 +11158,11 @@ etcd3@^1.1.2:
bignumber.js "^9.1.1"
cockatiel "^3.1.1"
event-target-polyfill@^0.0.4:
version "0.0.4"
resolved "https://registry.yarnpkg.com/event-target-polyfill/-/event-target-polyfill-0.0.4.tgz#060ee66e85aaedc76b6fa66079782dcc11cba496"
integrity sha512-Gs6RLjzlLRdT8X9ZipJdIZI/Y6/HhRLyq9RdDlCsnpxr/+Nn6bU2EFGuC94GjxqhM+Nmij2Vcq98yoHrU8uNFQ==
event-target-shim@^5.0.0, event-target-shim@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789"