Identify purchases user in session reducer
This commit is contained in:
@@ -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() {}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import {AtpSessionEvent} from '@atproto/api'
|
import {AtpSessionEvent} from '@atproto/api'
|
||||||
|
|
||||||
|
import {identifyUser as identifyPurchasesUser} from '#/state/purchases/identifyUser'
|
||||||
import {createPublicAgent} from './agent'
|
import {createPublicAgent} from './agent'
|
||||||
import {wrapSessionReducerForLogging} from './logging'
|
import {wrapSessionReducerForLogging} from './logging'
|
||||||
import {SessionAccount} from './types'
|
import {SessionAccount} from './types'
|
||||||
@@ -118,6 +119,7 @@ let reducer = (state: State, action: Action): State => {
|
|||||||
}
|
}
|
||||||
case 'switched-to-account': {
|
case 'switched-to-account': {
|
||||||
const {newAccount, newAgent} = action
|
const {newAccount, newAgent} = action
|
||||||
|
identifyPurchasesUser(newAccount)
|
||||||
return {
|
return {
|
||||||
accounts: [
|
accounts: [
|
||||||
newAccount,
|
newAccount,
|
||||||
|
|||||||
Reference in New Issue
Block a user