Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Firebase compat to modular #187

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions app/screens/ChatListScreen/chatListScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import styles from "./style";
import ConversationBanner from "../../components/ConversationBanner/conversationBanner";
import SuggestCardView from "../../components/SuggestionsCardView/suggestionsCardView";
import HeaderNavigationBar from "../../components/HeaderNavigationBar/HeaderNavigationBar";
import { f, auth, storage, database } from "../../../config/config.js";
import { auth, database } from "../../../config/config.js";
import { onAuthStateChanged } from "firebase/auth";
import { onValue, ref } from "firebase/database";
export default class ChatListScreen extends Component {
constructor(props) {
super(props);
Expand All @@ -19,11 +21,10 @@ export default class ChatListScreen extends Component {
fetchUsers = () => {
var that = this;
var userId = auth.currentUser.uid;
database.ref("users").once(
"value",
onValue(ref(database, 'users'),
function (snapshot) {
const exsist = snapshot.val() != null;
if (exsist) {
const exist = snapshot.val() != null;
if (exist) {
let data = snapshot.val();
var userList = that.state.userList;
for (var user in data) {
Expand Down Expand Up @@ -66,12 +67,7 @@ export default class ChatListScreen extends Component {
if (this.state.loggedin == true) {
var that = this;
var userId = auth.currentUser.uid;
database
.ref("users")
.child(userId)
.child("userChats")
.on(
"value",
onValue(ref(database, `users/${userId}/userChats`),
function (snapshot) {
const exist = snapshot.exists();
that.setState({
Expand Down Expand Up @@ -175,7 +171,7 @@ export default class ChatListScreen extends Component {
};
componentDidMount = () => {
var that = this;
auth.onAuthStateChanged(function (user) {
onAuthStateChanged(auth, function (user) {
if (user) {
that.setState({
loggedin: true,
Expand Down
20 changes: 8 additions & 12 deletions app/screens/LoginScreen/loginScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import {
ScrollView,
} from "react-native";
import { AccessToken, LoginManager } from "react-native-fbsdk";
import { f, auth } from "../../../config/config.js";
import { auth, database } from "../../../config/config.js";
import * as EmailValidator from "email-validator";
import styles from "./style";
import { SocialIcon } from "react-native-elements";
import { onAuthStateChanged, signInWithEmailAndPassword } from "firebase/auth";
import { ref, update } from "firebase/database";
export default class LoginScreen extends Component {
constructor(props) {
super(props);
Expand All @@ -25,8 +27,7 @@ export default class LoginScreen extends Component {

componentDidMount() {
var that = this;

auth.onAuthStateChanged(function (user) {
onAuthStateChanged(auth, function (user) {
if (user) {
that.redirectUser();
}
Expand All @@ -38,14 +39,12 @@ export default class LoginScreen extends Component {
let password = this.state.Password;

let { navigate } = this.props.navigation;

auth
.signInWithEmailAndPassword(email, password)
.then(function (data) {
signInWithEmailAndPassword(auth, email, password).then(
function (data) {
navigate("App");
})
.catch(function (error) {
var errorMessage = error.message;
const errorMessage = error.message;
alert(errorMessage.toString());
});
}
Expand Down Expand Up @@ -118,10 +117,7 @@ export default class LoginScreen extends Component {
dp,
ageRange: [20, 30],
};
f.database()
.ref("users")
.child(uid)
.update({ ...userData, ...defaults });
update(ref(database, "users/" + uid), { ...userData, ...defaults });
};

_signInAsync = async () => {
Expand Down
Loading