diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..fb60f00 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,22 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "chrome", + "request": "launch", + "name": "Launch Chrome", + "url": "http://localhost:3000", + "webRoot": "${workspaceFolder}" + }, + { + "type": "chrome", + "request": "launch", + "name": "Launch Chrome against localhost", + "url": "http://localhost:8080", + "webRoot": "${workspaceFolder}" + } + ] +} diff --git a/src/components/App.js b/src/components/App.js index 8165305..40e8e5f 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -9,7 +9,8 @@ class App extends Component { constructor(props) { super(props); this.state = { - chatId: "" + chatId: "", + email: "" }; } @@ -23,22 +24,34 @@ class App extends Component { this.setState({ chatId: `allChat/chat${id}` }); }; + getUserEmail = data => { + this.setState({ email: data }); + }; render() { return (

Chat Room

+ +

+ Client: {this.state.email} +

+
- +
diff --git a/src/components/Chat.js b/src/components/Chat.js index efccc36..704a3ba 100644 --- a/src/components/Chat.js +++ b/src/components/Chat.js @@ -4,7 +4,6 @@ import React, { Component } from "react"; import ChatInput from "./ChatInput"; import Messages from "./Messages"; import fire from "./Firebase.js"; -import firebase from "firebase"; const database = fire.database(); const avocat = { @@ -36,6 +35,11 @@ export default class Chat extends Component { database .ref(`${this.props.path}`) .on("child_added", x => this.updateState(x.val())); + database.ref(`${this.props.path}`).once("value", result => { + let email = result.val()[Object.keys(result.val())[0]].user.email; + console.log(email); + this.props.getUserEmail(email); + }); } updateState = data => {