Skip to content

Commit

Permalink
Fix bug for livereloading avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
gocreating committed Oct 31, 2016
1 parent a68ddc2 commit 4e773ca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
7 changes: 3 additions & 4 deletions src/common/components/forms/user/AvatarForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Field, reduxForm } from 'redux-form';
import Button from 'react-bootstrap/lib/Button';
import Image from 'react-bootstrap/lib/Image';
import FormNames from '../../../constants/FormNames';
import configs from '../../../../../configs/project/client';
import firebaseAPI from '../../../api/firebase';
import userAPI from '../../../api/user';
import { pushErrors } from '../../../actions/errorActions';
import { setCookies } from '../../../actions/cookieActions';
import { Form, FormField, FormFooter } from '../../utils/BsForm';
import RefreshImage from '../../utils/RefreshImage';
import toRefreshURL from '../../../utils/toRefreshURL';

const initialValues = {
Expand Down Expand Up @@ -187,17 +187,16 @@ class AvatarForm extends Component {

render() {
const {
user,
user: { avatarURL },
handleSubmit,
pristine,
submitting,
invalid,
} = this.props;
let avatarURL = this.state.avatarURL || user.avatarURL;

return (
<Form onSubmit={handleSubmit(this.handleSubmit)}>
{avatarURL && <RefreshImage thumbnail src={avatarURL} />}
{avatarURL && <Image thumbnail src={avatarURL} />}
<Field
name="avatar"
component={FormField}
Expand Down
6 changes: 4 additions & 2 deletions src/common/components/pages/user/ShowPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import Modal from 'react-bootstrap/lib/Modal';
import Row from 'react-bootstrap/lib/Row';
import Col from 'react-bootstrap/lib/Col';
import Button from 'react-bootstrap/lib/Button';
import Image from 'react-bootstrap/lib/Image';
import userAPI from '../../../api/user';
import { pushErrors } from '../../../actions/errorActions';
import Head from '../../widgets/Head';
import PageLayout from '../../layouts/PageLayout';
import Time from '../../widgets/Time';
import RefreshImage from '../../utils/RefreshImage';
import VerifyEmailForm from '../../forms/user/VerifyEmailForm';
import toRefreshURL from '../../../utils/toRefreshURL';

class ShowPage extends Component {
constructor(props) {
Expand All @@ -35,6 +36,7 @@ class ShowPage extends Component {
throw err;
})
.then((json) => {
json.user.avatarURL = toRefreshURL(json.user.avatarURL);
this.setState({
user: json.user,
});
Expand Down Expand Up @@ -94,7 +96,7 @@ class ShowPage extends Component {
<dd>{user._id}</dd>
<dt>avatar</dt>
<dd>
{user.avatarURL && <RefreshImage thumbnail src={user.avatarURL} />}
{user.avatarURL && <Image thumbnail src={user.avatarURL} />}
</dd>
<dt>name</dt>
<dd>{user.name}</dd>
Expand Down
9 changes: 0 additions & 9 deletions src/common/components/utils/RefreshImage.js

This file was deleted.

0 comments on commit 4e773ca

Please sign in to comment.