Minimally functional app after expo upgrade.
This commit is contained in:
@@ -1,15 +1,26 @@
|
||||
import firebase from "firebase/app";
|
||||
import "firebase/auth";
|
||||
import { initializeApp } from "firebase/app";
|
||||
import { getAuth, onAuthStateChanged } from "firebase/auth";
|
||||
import env from "../env";
|
||||
import { store } from "../redux/store";
|
||||
import { signInSuccess, unauthorizedUser } from "../redux/user/user.actions";
|
||||
|
||||
if (!firebase.apps.length) {
|
||||
firebase.initializeApp(env.firebase);
|
||||
}
|
||||
initializeApp(env.firebase);
|
||||
|
||||
export const auth = firebase.auth();
|
||||
//export const analytics = firebase.analytics();
|
||||
export const auth = getAuth();
|
||||
|
||||
export default firebase;
|
||||
export const unsubscribe = onAuthStateChanged(auth, (user) => {
|
||||
store.dispatch(
|
||||
user
|
||||
? signInSuccess({
|
||||
uid: user.uid,
|
||||
email: user.email,
|
||||
displayName: user.displayName,
|
||||
photoURL: user.photoURL,
|
||||
authorized: true,
|
||||
})
|
||||
: unauthorizedUser()
|
||||
);
|
||||
});
|
||||
|
||||
export const getCurrentUser = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -19,14 +30,3 @@ export const getCurrentUser = () => {
|
||||
}, reject);
|
||||
});
|
||||
};
|
||||
|
||||
export const updateCurrentUser = (userDetails) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const unsubscribe = auth.onAuthStateChanged((userAuth) => {
|
||||
userAuth.updateProfile(userDetails).then((r) => {
|
||||
unsubscribe();
|
||||
resolve(userAuth);
|
||||
});
|
||||
}, reject);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user