Identify purchases user in session reducer

This commit is contained in:
Eric Bailey
2024-10-28 14:26:45 -05:00
parent 5ac8c3d653
commit 009e238c30
3 changed files with 15 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
import Purchases from 'react-native-purchases'
import {SessionAccount} from '#/state/session/types'
export function identifyUser(account: SessionAccount) {
Purchases.logIn(account.did)
// TODO is this ever not defined?
if (account.email) {
Purchases.setEmail(account.email)
}
}
@@ -0,0 +1,2 @@
// no-op on web
export function identifyUser() {}
+2
View File
@@ -1,5 +1,6 @@
import {AtpSessionEvent} from '@atproto/api'
import {identifyUser as identifyPurchasesUser} from '#/state/purchases/identifyUser'
import {createPublicAgent} from './agent'
import {wrapSessionReducerForLogging} from './logging'
import {SessionAccount} from './types'
@@ -118,6 +119,7 @@ let reducer = (state: State, action: Action): State => {
}
case 'switched-to-account': {
const {newAccount, newAgent} = action
identifyPurchasesUser(newAccount)
return {
accounts: [
newAccount,