Skip to content

Commit fb07a50

Browse files
committed
chore: some changes
1 parent 689174e commit fb07a50

File tree

3 files changed

+66
-212
lines changed

3 files changed

+66
-212
lines changed

app/index.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Client, Account, AppwriteException, OAuthProvider } from "appwrite";
1+
import { Client, Account, AppwriteException, OAuthProvider } from "react-native-appwrite";
22
import { useEffect, useState } from "react";
33
import {
44
View,
@@ -12,6 +12,7 @@ import {
1212
StatusBar,
1313
KeyboardAvoidingView,
1414
ScrollView,
15+
AppState,
1516
} from "react-native";
1617
import * as WebBrowser from "expo-web-browser";
1718
import * as Linking from "expo-linking";
@@ -58,7 +59,7 @@ export default function AuthScreen() {
5859
try {
5960
const deepLink = Linking.createURL("/");
6061

61-
const response = await account.createOAuth2Session(
62+
const response = await account.createOAuth2Token(
6263
OAuthProvider.Google,
6364
deepLink,
6465
deepLink
@@ -101,6 +102,23 @@ export default function AuthScreen() {
101102
fetchUser();
102103
}, []);
103104

105+
useEffect(() => {
106+
const subscription = AppState.addEventListener("change", async (nextAppState) => {
107+
if (nextAppState === "active") {
108+
try {
109+
const user = await account.get();
110+
setUser(user);
111+
} catch (err) {
112+
setUser(null);
113+
}
114+
}
115+
});
116+
117+
return () => {
118+
subscription.remove();
119+
};
120+
}, []);
121+
104122
if (checkingUser) {
105123
return null;
106124
}

0 commit comments

Comments
 (0)