Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 29 additions & 15 deletions src/components/accountScreen/accountScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import HeaderNav from '../headerNav/headerNav';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';

import FlatButton from 'material-ui/FlatButton/FlatButton';

import {
getUser,
getUsers,
changeUser,
getCurrentUser,
registerUser,
Expand Down Expand Up @@ -42,11 +44,14 @@ const getShort = str => {
};

const getShortTime = str => {
var value = str.getMinutes().toString();
if (value.length === 1) {
value += '0';
try {
var fullTime = str.split('T')[1];
var hour = fullTime.split(':')[0];
var minute = fullTime.split(':')[1];
return hour + ':' + minute;
} catch (ex) {
return '-----';
}
return str.getHours() + ':' + value;
};

const cardHeaderStyle = {
Expand Down Expand Up @@ -155,7 +160,13 @@ const NewText = function(props) {
props.currentUser.userID,
props.receiver.userID
);
props.getUserChats();

e.target.value = '';
setTimeout(function() {
var objDiv = document.getElementById('theChat');
objDiv.scrollTop = objDiv.scrollHeight;
}, 1);
}
}}
style={{
Expand Down Expand Up @@ -189,17 +200,22 @@ class AccountScreen extends Component {
super(props);
try {
props.getCurrentUser();
var id = props.currentUser.userID;
} catch (exc) {
window.location.href = '/';
}

props.getUserChats(this.props.allMsgs);
props.getUsers();
props.getMsgs(props.currentUser.userID, props.receiver.userID);

this.filterList = this.filterList.bind(this);
//this.state = { initialItems: initialItems, items: initialItems };
}

componentWillReceiveProps(newProps) {
console.log(newProps);
}

filterList = function(text) {
var updatedList = this.props.currentUserChats;
updatedList = updatedList.filter(function(item) {
Expand Down Expand Up @@ -231,13 +247,12 @@ class AccountScreen extends Component {

render() {
return (
<div className="auto">
<div>
<HeaderNav
pic={this.props.currentUser.userImg}
surname={this.props.currentUser.userSurname}
name={this.props.currentUser.userName}
/>

<div className="leftPanelContainer">
<div className="searchContainer">
<SearchBar
Expand All @@ -246,7 +261,6 @@ class AccountScreen extends Component {
onChange={text => this.filterList(text)}
/>
</div>

<ul className="defaultList">
{this.props.filteredChats.map(chat => (
<li
Expand All @@ -265,11 +279,11 @@ class AccountScreen extends Component {
</ul>
</div>

<div className="mainBubbleContainer">
<div id="theChat" className="mainBubbleContainer">
{this.props.msgs.map(chat => {
if (
chat.senderID === this.props.currentUser.userID &&
chat.receiverID === this.props.receiver.userID
chat.senderId === this.props.currentUser.userID &&
chat.receiverId === this.props.receiver.userID
) {
return (
<div className="bubbleContainer">
Expand All @@ -278,8 +292,8 @@ class AccountScreen extends Component {
</div>
);
} else if (
chat.senderID === this.props.receiver.userID &&
chat.receiverID === this.props.currentUser.userID
chat.senderId === this.props.receiver.userID &&
chat.receiverId === this.props.currentUser.userID
) {
return (
<div className="bubbleContainer">
Expand Down Expand Up @@ -316,7 +330,7 @@ const mapStateToProps = state => {
const mapDispatchToProps = dispatch =>
bindActionCreators(
{
getUser,
getUsers,
getCurrentUser,
changeUser,
addMsg,
Expand Down
Loading