From bf77b676eb8bdcbc226f5f3daa4ef2047734f83b Mon Sep 17 00:00:00 2001 From: "Claudio Maggioni (maggicl)" Date: Mon, 4 May 2020 18:22:21 +0200 Subject: [PATCH] Removed current user from list of possible guests in guest modal --- smart-hut/src/components/HostModal.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/smart-hut/src/components/HostModal.js b/smart-hut/src/components/HostModal.js index 789c484..e262e3f 100644 --- a/smart-hut/src/components/HostModal.js +++ b/smart-hut/src/components/HostModal.js @@ -11,7 +11,6 @@ import { import { connect } from "react-redux"; import { RemoteService, Forms } from "../remote"; import { appActions } from "../storeActions"; -//import { update } from "immutability-helper"; class HostModal extends Component { constructor(props) { @@ -23,7 +22,8 @@ class HostModal extends Component { .then(() => { this.setState({ ...this.state, - guests: this.props.guests.map((u) => u.id), + guests: this.props.guests + .map((u) => u.id), }); }) .catch(console.error); @@ -32,7 +32,7 @@ class HostModal extends Component { .then((users) => this.setState({ ...this.state, - users: users.map((u) => ({ + users: users.filter(u => u.id !== this.props.currentUserId).map((u) => ({ key: u.id, text: `@${u.username} (${u.name})`, value: u.id, @@ -127,6 +127,7 @@ const setActiveHost = (activeHost) => { const mapStateToProps = (state) => ({ guests: state.guests, + currentUserId: state.userInfo.id }); const HostModalContainer = connect( mapStateToProps,