diff --git a/react-native/ChatApp/components/ListScreen.js b/react-native/ChatApp/components/ListScreen.js index 4645b43322d05bf39426b78f7ae56d4b66c166db..3f4089442e075f80c90ed9d055906a190d131f3e 100644 --- a/react-native/ChatApp/components/ListScreen.js +++ b/react-native/ChatApp/components/ListScreen.js @@ -18,7 +18,8 @@ class ListScreen extends React.Component { } - async componentDidMount() { + async getRooms() { + let status = null; //get rooms from API @@ -72,6 +73,19 @@ class ListScreen extends React.Component { } } + componentDidMount() { + + this.getRooms(); + + const { navigation } = this.props; + + this.focusListener = navigation.addListener("focus", async () => { + + this.getRooms(); + + }); + } + keyExtractor = (item, index) => index.toString(); render() { diff --git a/react-native/ChatApp/components/MessagesScreen.js b/react-native/ChatApp/components/MessagesScreen.js index b71dac0a2818a4590c3a7c90199a4c79b430f4c3..c5d80126476e109673c26fa7dd0b67f2cfe3e9f3 100644 --- a/react-native/ChatApp/components/MessagesScreen.js +++ b/react-native/ChatApp/components/MessagesScreen.js @@ -22,8 +22,7 @@ class MessagesScreen extends React.Component { this.onSend = this.onSend.bind(this); } - async componentDidMount() { - + async getMessages() { let status = null; //get user from asyncStorage @@ -109,6 +108,19 @@ class MessagesScreen extends React.Component { this.setState({ isLoading: false }) } + componentDidMount() { + + this.getMessages(); + + const { navigation } = this.props; + + this.focusListener = navigation.addListener("focus", async () => { + + this.getMessages(); + + }); + } + async onSend(messages = []) { let status = null;