Skip to content

Commit

Permalink
Allow talk to yourself
Browse files Browse the repository at this point in the history
refs #58
  • Loading branch information
rickmak committed Apr 20, 2017
1 parent cd5a75d commit 7b8bf9c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
7 changes: 3 additions & 4 deletions src/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,14 @@ export default class App extends React.Component {
<div style={Styles.conversationContainer}>
{
conversationList
.filter(c => c.participant_count >= 2)
.map(c =>
<ConversationPreview
.map((c) => {
return <ConversationPreview
key={'ConversationPreview-' + c.id + c.updatedAt}
selected={
c.id === (currentConversation && currentConversation.id)}
conversation={c}
onClick={() => this.setState({currentConversation: c})}/>
)
})
}
</div>
</div>
Expand Down
10 changes: 8 additions & 2 deletions src/components/ConversationPreview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,24 @@ export default class ConversationPreview extends React.Component {
// fetch users
Promise.all(
participant_ids
.filter(id => id !== skygear.currentUser.id)
.map(userID => UserLoader.get(userID))
).then(users => {
if (users.length > 1) {
users = users.filter(u => u._id !== skygear.currentUser.id)
}
let names = users
.map(u => u.displayName)
.join(', ');
if (names.length > 30) {
names = names.substring(0, 27) + '...';
}
let avatar = 'img/avatar.svg';
if (users[0]) {
avatar = users[0].avatar ? users[0].avatar.url : 'img/avatar.svg';
}
this.setState({
title: title || names,
imageURL: users[0].avatar ? users[0].avatar.url : 'img/avatar.svg'
imageURL: avatar
});
});
}
Expand Down
6 changes: 0 additions & 6 deletions src/components/CreateChatModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ export default class CreateChatModal extends React.Component {
};
}
discoverUserAndCreateChat(username) {
if (username === skygear.currentUser.username) {
this.setState({
errorMessage: 'Error: cannot create conversation with yourself'
});
return;
}
this.setState({loading: true});
skygear.discoverUserByUsernames(
username
Expand Down
6 changes: 0 additions & 6 deletions src/components/CreateGroupModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ export default class CreateGroupModal extends React.Component {
};
}
discoverUser(username) {
if (username === skygear.currentUser.username) {
this.setState({
errorMessage: 'Error: cannot create conversation with yourself'
});
return;
}
this.setState({loading: true});
skygear.discoverUserByUsernames(
username
Expand Down

0 comments on commit 7b8bf9c

Please sign in to comment.