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

bfix: update firebase version from v8 to v9 #188

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cache:
- node_modules

before_install:
- mv config/config.example.js config/config.js
- mv config/config.js config/config.js

install:
- npm install
Expand Down
4 changes: 2 additions & 2 deletions android/.settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
arguments=--init-script C\:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\redhat.java\\1.15.0\\config_win\\org.eclipse.osgi\\54\\0\\.cp\\gradle\\init\\init.gradle --init-script C\:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\redhat.java\\1.15.0\\config_win\\org.eclipse.osgi\\54\\0\\.cp\\gradle\\protobuf\\init.gradle
arguments=--init-script C\:\\Users\\naran\\AppData\\Roaming\\Code\\User\\globalStorage\\redhat.java\\1.15.0\\config_win\\org.eclipse.osgi\\54\\0\\.cp\\gradle\\init\\init.gradle --init-script C\:\\Users\\naran\\AppData\\Roaming\\Code\\User\\globalStorage\\redhat.java\\1.15.0\\config_win\\org.eclipse.osgi\\54\\0\\.cp\\gradle\\protobuf\\init.gradle
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=C\:/Program Files/Java/jdk-17.0.5
java.home=C\:/Program Files/Eclipse Adoptium/jdk-17.0.4.101-hotspot
jvm.arguments=
offline.mode=false
override.workspace.settings=true
Expand Down
136 changes: 70 additions & 66 deletions app/screens/ChatListScreen/chatListScreen.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
// done

import React, { Component } from "react";
import { View, Text, Button, StatusBar, Image, ScrollView } from "react-native";
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 { ref, onValue, child } from "firebase/database";
import { onAuthStateChanged } from "firebase/auth";

export default class ChatListScreen extends Component {
constructor(props) {
super(props);
Expand All @@ -19,33 +24,33 @@ export default class ChatListScreen extends Component {
fetchUsers = () => {
var that = this;
var userId = auth.currentUser.uid;
database.ref("users").once(
"value",
var userRef = ref(database,"users");
onValue(
userRef,
function (snapshot) {
const exsist = snapshot.val() != null;
if (exsist) {
let data = snapshot.val();
var userList = that.state.userList;
for (var user in data) {
let userObj = data[user];
let uId = user;
if (uId != userId) {
userList.push({
id: uId,
name: userObj.firstName,
avatar: userObj.avatar,
});
}
const exsist = snapshot.val() != null;
if (exsist) {
let data = snapshot.val();
var userList = that.state.userList;
for (var user in data) {
let userObj = data[user];
let uId = user;
if (uId != userId) {
userList.push({
id: uId,
name: userObj.firstName,
avatar: userObj.avatar,
});
}
that.setState({
userList: userList,
});
}
},
function (errorObject) {
console.log("The read failed: " + errorObject.code);
that.setState({
userList: userList,
});
}
);
},
function (errorObject) {
console.log("The read failed: " + errorObject.code);
})
};
renderUserList = () => {
if (this.state.loggedin == true) {
Expand All @@ -66,51 +71,50 @@ 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",
function (snapshot) {
const exist = snapshot.exists();
that.setState({
chatList: [],
});
if (exist) {
var data = snapshot.val();
const exsist = snapshot.exists();
if (exsist) {
data = snapshot.val();
var chatList = that.state.chatList;
Object.keys(data).forEach(key => {
var tempdata = data[key];
Object.keys(tempdata).forEach(key => {
chatList.push({
posted: tempdata[key].posted,
lastMessage: tempdata[key].lastMessage,
name: tempdata[key].name,
avatar: tempdata[key].avatar,
id: tempdata[key].friend,
});
var userRef = ref(database, "users");
var chatRef = child(child(userRef, userId),"userChats");

onValue(
chatRef,
function (snapshot) {
const exist = snapshot.exists();
that.setState({
chatList: [],
});
if (exist) {
var data = snapshot.val();
const exsist = snapshot.exists();
if (exsist) {
data = snapshot.val();
var chatList = that.state.chatList;
Object.keys(data).forEach(key => {
var tempdata = data[key];
Object.keys(tempdata).forEach(key => {
chatList.push({
posted: tempdata[key].posted,
lastMessage: tempdata[key].lastMessage,
name: tempdata[key].name,
avatar: tempdata[key].avatar,
id: tempdata[key].friend,
});
});
console.log(chatList);
that.setState({
loaded: true,
});
} else {
that.setState({
chatList: [],
loaded: true,
});
}
});
console.log(chatList);
that.setState({
loaded: true,
});
} else {
that.setState({
chatList: [],
loaded: true,
});
}
},
function (errorObject) {
console.log("The read failed: " + errorObject.code);
}
);
},
function (errorObject) {
console.log("The read failed: " + errorObject.code);
}
)
}
};
timePlural = s => {
Expand Down Expand Up @@ -175,7 +179,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
14 changes: 8 additions & 6 deletions app/screens/ForgotPasswordScreen/forgotPasswordScreen.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable prettier/prettier */
// done
import React, { Component } from "react";
import {
Platform,
Expand All @@ -17,8 +18,9 @@ import {
// import Btn from 'react-native-micro-animated-button';
import * as EmailValidator from "email-validator";
import styles from "./style";
import { f, auth } from "../../../config/config.js";
import { auth } from "../../../config/config.js";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { sendPasswordResetEmail } from "firebase/auth";
export default class ForgotPasswordScreen extends Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -61,18 +63,18 @@ export default class ForgotPasswordScreen extends Component {
resetPassword = () => {
if (EmailValidator.validate(this.state.email) === true) {
var that = this;
auth
.sendPasswordResetEmail(this.state.email)

sendPasswordResetEmail(auth, this.state.email)
.then(function () {
alert("Please Check Your Email To Reset Your Password");
Alert("Please Check Your Email To Reset Your Password");
let { navigate } = that.props.navigation;
navigate("Login");
})
.catch(function (error) {
alert(error);
Alert(error);
});
} else {
alert("Please enter A Valid Email");
Alert("Please enter A Valid Email");
}
};
}
42 changes: 22 additions & 20 deletions app/screens/LoginScreen/loginScreen.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// done
import React, { Component } from "react";
import {
View,
Expand All @@ -8,12 +9,16 @@ import {
TouchableOpacity,
KeyboardAvoidingView,
ScrollView,
Alert,
} 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 { signInWithEmailAndPassword, FacebookAuthProvider, signInWithCredential } from "firebase/auth";
import * as EmailValidator from "email-validator";
import styles from "./style";
import { SocialIcon } from "react-native-elements";
import { ref, child, update } from "firebase/database";
import { onAuthStateChanged } from "firebase/auth";
export default class LoginScreen extends Component {
constructor(props) {
super(props);
Expand All @@ -26,7 +31,8 @@ export default class LoginScreen extends Component {
componentDidMount() {
var that = this;

auth.onAuthStateChanged(function (user) {

onAuthStateChanged(auth, function (user) {
if (user) {
that.redirectUser();
}
Expand All @@ -39,14 +45,13 @@ export default class LoginScreen extends Component {

let { navigate } = this.props.navigation;

auth
.signInWithEmailAndPassword(email, password)
signInWithEmailAndPassword(auth, email, password)
.then(function (data) {
navigate("App");
})
.catch(function (error) {
var errorMessage = error.message;
alert(errorMessage.toString());
Alert(errorMessage.toString());
});
}

Expand All @@ -57,29 +62,29 @@ export default class LoginScreen extends Component {

_signInAsync = async () => {
if (EmailValidator.validate(this.state.email) === true) {
if (this.state.Pasword != "") {
if (this.state.Password != "") {
this.login();
} else {
alert("Enter the password");
Alert("Enter the password");
}
} else {
alert("Please enter A Valid Email");
Alert("Please enter A Valid Email");
}
};

onPressLogin() {
LoginManager.logInWithReadPermissions(["public_profile", "email"]).then(
result => this._handleCallBack(result),
function (error) {
alert("Login fail with error: " + error);
Alert("Login fail with error: " + error);
}
);
}

_handleCallBack(result) {
let _this = this;
if (result.isCancelled) {
alert("Login cancelled");
Alert("Login cancelled");
} else {
AccessToken.getCurrentAccessToken().then(data => {
const token = data.accessToken;
Expand All @@ -105,9 +110,8 @@ export default class LoginScreen extends Component {
}

authenticate = token => {
const provider = auth.FacebookAuthProvider;
const credential = provider.credential(token);
let ret = auth.signInWithCredential(credential);
const credential = FacebookAuthProvider.credential(token);
let ret = signInWithCredential(auth, credential);
return ret;
};

Expand All @@ -118,21 +122,19 @@ export default class LoginScreen extends Component {
dp,
ageRange: [20, 30],
};
f.database()
.ref("users")
.child(uid)
.update({ ...userData, ...defaults });
var updates = { ...userData, ...defaults }
update(child(ref(database, "users"), uid), updates)
};

_signInAsync = async () => {
if (EmailValidator.validate(this.state.email) === true) {
if (this.state.Pasword != "") {
if (this.state.Password != "") {
this.login();
} else {
alert("Enter the password");
Alert("Enter the password");
}
} else {
alert("Please enter A Valid Email");
Alert("Please enter A Valid Email");
}
};

Expand Down
Loading