Skip to content

Commit

Permalink
User Image implementation after changes issue #44
Browse files Browse the repository at this point in the history
  • Loading branch information
Syed Asher Ahmed committed Mar 30, 2017
1 parent f47733d commit 85318c9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
23 changes: 12 additions & 11 deletions imports/ui/components/AppLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ import { Meteor } from 'meteor/meteor'
import theme from './theme';

// App component - represents the whole app
export default class AppLayout extends Component {
class AppLayout extends Component {

constructor(props) {
super(props);

this.state = {
sidebarPinned: false,
drawerActive: false,
avatar: Meteor.user().profile.avatar
drawerActive: false
};

}
Expand All @@ -33,11 +32,6 @@ export default class AppLayout extends Component {
sidebarPinned: stopToggle
});
}
handler(imgUrl){
this.setState({
avatar: imgUrl
});
}

name(){
let user = Meteor.user();
Expand All @@ -64,18 +58,19 @@ export default class AppLayout extends Component {
rating: 'pg'
});
}
let profileImage = this.props.user.profile.avatar || gravatar || "/assets/images/HQ3YU7n.gif";
return (
<Layout>
<LeftMenu {...props}/>
<Panel>
<AppBarExtended>
<IconButton icon='menu' accent inverse={ true } onClick={ this.toggleDrawerActive.bind(this) }/>
<div className={theme.headerGreeting}>
<span>Welcome <b>{this.name()}</b> <img src = {this.state.avatar || gravatar || "/assets/images/HQ3YU7n.gif" } width="45" height="45" /><i className="material-icons" onClick={this.logout.bind(this)}>&#xE8AC;</i></span>
<span>Welcome <b>{this.name()}</b> <img src = { profileImage } width="45" height="45" /><i className="material-icons" onClick={this.logout.bind(this)}>&#xE8AC;</i></span>
</div>
</AppBarExtended>
<div className="page-content-wrapper" style={{ flex: 1, display: 'flex' }}>
{React.cloneElement(this.props.content, {toggleSidebar: this.toggleSidebar.bind(this), handler: this.handler.bind(this)})}
{React.cloneElement(this.props.content, {toggleSidebar: this.toggleSidebar.bind(this)})}
</div>
</Panel>
<Sidebar pinned={this.state.sidebarPinned} width={ 6 }>
Expand All @@ -89,4 +84,10 @@ export default class AppLayout extends Component {
</Layout>
);
}
}
}

export default createContainer(() => {
return {
user: Meteor.user()
};
}, AppLayout);
1 change: 0 additions & 1 deletion imports/ui/components/settings/Settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ class SettingsPage extends Component {
alert (error); // you may want to fancy this up when you're ready instead of a popup.
}
else {
this.props.handler(downloadUrl);
// we use $set because the user can change their avatar so it overwrites the url :)
Meteor.users.update(Meteor.userId(), {$set: {"profile.avatar": downloadUrl}});
console.log(downloadUrl);
Expand Down

0 comments on commit 85318c9

Please sign in to comment.