don't log user out when network isnt connected
This commit is contained in:
@@ -12,6 +12,8 @@ import {emitSessionDropped} from '../events'
|
|||||||
import {useLoggedOutViewControls} from '#/state/shell/logged-out'
|
import {useLoggedOutViewControls} from '#/state/shell/logged-out'
|
||||||
import {useCloseAllActiveElements} from '#/state/util'
|
import {useCloseAllActiveElements} from '#/state/util'
|
||||||
import {track} from '#/lib/analytics/analytics'
|
import {track} from '#/lib/analytics/analytics'
|
||||||
|
import {fetch as fetchNetworkState} from '@react-native-community/netinfo'
|
||||||
|
import * as Toast from 'view/com/util/Toast'
|
||||||
|
|
||||||
let __globalAgent: BskyAgent = PUBLIC_BSKY_AGENT
|
let __globalAgent: BskyAgent = PUBLIC_BSKY_AGENT
|
||||||
|
|
||||||
@@ -141,6 +143,9 @@ function createPersistSessionHandler(
|
|||||||
* to persist this data and wipe their tokens, effectively logging them
|
* to persist this data and wipe their tokens, effectively logging them
|
||||||
* out.
|
* out.
|
||||||
*/
|
*/
|
||||||
|
// if creation failed, but it is a network error, we want to persist the
|
||||||
|
// data so that the user can try again
|
||||||
|
|
||||||
persistSessionCallback({
|
persistSessionCallback({
|
||||||
expired,
|
expired,
|
||||||
refreshedAccount,
|
refreshedAccount,
|
||||||
@@ -444,6 +449,12 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
|||||||
async account => {
|
async account => {
|
||||||
try {
|
try {
|
||||||
if (account) {
|
if (account) {
|
||||||
|
const currentNetworkState = await fetchNetworkState()
|
||||||
|
if (!currentNetworkState.isConnected) {
|
||||||
|
logger.info(`session: no internet connection, cannot reuse session`)
|
||||||
|
Toast.show('No internet connection. Please try again.')
|
||||||
|
return
|
||||||
|
}
|
||||||
await initSession(account)
|
await initSession(account)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user