making avatar cropping work
This commit is contained in:
@@ -68,7 +68,6 @@ export default class AccGeneralView extends React.Component {
|
|||||||
|
|
||||||
handleImageChanged(img) {
|
handleImageChanged(img) {
|
||||||
this.setState({avatar: img});
|
this.setState({avatar: img});
|
||||||
this.props.onBasicNavigate('crop');
|
|
||||||
// this.props.onUpdateAccount(undefined, theCard(null, img || Tinode.DEL_CHAR));
|
// this.props.onUpdateAccount(undefined, theCard(null, img || Tinode.DEL_CHAR));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,6 +150,7 @@ export default class AccGeneralView extends React.Component {
|
|||||||
avatar={this.state.avatar}
|
avatar={this.state.avatar}
|
||||||
uid={this.props.myUserId}
|
uid={this.props.myUserId}
|
||||||
title={this.state.fullName}
|
title={this.state.fullName}
|
||||||
|
onImageReceived={this.props.onImageReceived}
|
||||||
onImageChanged={this.handleImageChanged}
|
onImageChanged={this.handleImageChanged}
|
||||||
onError={this.props.onError} />
|
onError={this.props.onError} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export default class AvatarCropView extends React.PureComponent {
|
|||||||
return (
|
return (
|
||||||
<div className="panel-form">
|
<div className="panel-form">
|
||||||
<div className="panel-form-row">
|
<div className="panel-form-row">
|
||||||
<Cropper source="/img/logo192.png" />
|
<Cropper source={this.props.avatar} />
|
||||||
</div>
|
</div>
|
||||||
<div className="dialog-buttons">
|
<div className="dialog-buttons">
|
||||||
<button className="primary" onClick={this.handleSubmit}>
|
<button className="primary" onClick={this.handleSubmit}>
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ class SidepanelView extends React.Component {
|
|||||||
onCredAdd={this.props.onCredAdd}
|
onCredAdd={this.props.onCredAdd}
|
||||||
onCredDelete={this.props.onCredDelete}
|
onCredDelete={this.props.onCredDelete}
|
||||||
onCredConfirm={this.props.onCredConfirm}
|
onCredConfirm={this.props.onCredConfirm}
|
||||||
onBasicNavigate={this.props.onBasicNavigate}
|
onImageReceived={this.props.onImageReceived}
|
||||||
onError={this.props.onError} /> :
|
onError={this.props.onError} /> :
|
||||||
|
|
||||||
view === 'notif' ?
|
view === 'notif' ?
|
||||||
@@ -248,6 +248,7 @@ class SidepanelView extends React.Component {
|
|||||||
|
|
||||||
view === 'crop' ?
|
view === 'crop' ?
|
||||||
<AvatarCropView
|
<AvatarCropView
|
||||||
|
avatar={this.props.newAvatar}
|
||||||
onSubmit={this.props.onAvatarCropped}
|
onSubmit={this.props.onAvatarCropped}
|
||||||
onCancel={this.props.onCancel} /> :
|
onCancel={this.props.onCancel} /> :
|
||||||
|
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ class TinodeWeb extends React.Component {
|
|||||||
this.handleCredAdd = this.handleCredAdd.bind(this);
|
this.handleCredAdd = this.handleCredAdd.bind(this);
|
||||||
this.handleCredDelete = this.handleCredDelete.bind(this);
|
this.handleCredDelete = this.handleCredDelete.bind(this);
|
||||||
this.handleCredConfirm = this.handleCredConfirm.bind(this);
|
this.handleCredConfirm = this.handleCredConfirm.bind(this);
|
||||||
|
this.handleImageReceived = this.handleImageReceived.bind(this);
|
||||||
this.initFCMessaging = this.initFCMessaging.bind(this);
|
this.initFCMessaging = this.initFCMessaging.bind(this);
|
||||||
this.togglePushToken = this.togglePushToken.bind(this);
|
this.togglePushToken = this.togglePushToken.bind(this);
|
||||||
this.requestPushToken = this.requestPushToken.bind(this);
|
this.requestPushToken = this.requestPushToken.bind(this);
|
||||||
@@ -1148,6 +1149,13 @@ class TinodeWeb extends React.Component {
|
|||||||
this.handleCredentialsRequest({cred: [method]});
|
this.handleCredentialsRequest({cred: [method]});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleImageReceived(url) {
|
||||||
|
this.setState({newAvatar: url});
|
||||||
|
if (url) {
|
||||||
|
this.basicNavigator('crop');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// User clicked Cancel button in Setting or Sign Up panel.
|
// User clicked Cancel button in Setting or Sign Up panel.
|
||||||
handleSidepanelCancel() {
|
handleSidepanelCancel() {
|
||||||
const parsed = HashNavigation.parseUrlHash(window.location.hash);
|
const parsed = HashNavigation.parseUrlHash(window.location.hash);
|
||||||
@@ -1552,6 +1560,7 @@ class TinodeWeb extends React.Component {
|
|||||||
myUserId={this.state.myUserId}
|
myUserId={this.state.myUserId}
|
||||||
loginDisabled={this.state.loginDisabled}
|
loginDisabled={this.state.loginDisabled}
|
||||||
loadSpinnerVisible={this.state.loadSpinnerVisible}
|
loadSpinnerVisible={this.state.loadSpinnerVisible}
|
||||||
|
newAvatar={this.state.newAvatar}
|
||||||
|
|
||||||
errorText={this.state.errorText}
|
errorText={this.state.errorText}
|
||||||
errorLevel={this.state.errorLevel}
|
errorLevel={this.state.errorLevel}
|
||||||
@@ -1586,6 +1595,7 @@ class TinodeWeb extends React.Component {
|
|||||||
onCredAdd={this.handleCredAdd}
|
onCredAdd={this.handleCredAdd}
|
||||||
onCredDelete={this.handleCredDelete}
|
onCredDelete={this.handleCredDelete}
|
||||||
onCredConfirm={this.handleCredConfirm}
|
onCredConfirm={this.handleCredConfirm}
|
||||||
|
onImageReceived={this.handleImageReceived}
|
||||||
onTopicSelected={this.handleTopicSelected}
|
onTopicSelected={this.handleTopicSelected}
|
||||||
onCreateTopic={this.handleStartTopicRequest}
|
onCreateTopic={this.handleStartTopicRequest}
|
||||||
onLogout={this.handleLogout}
|
onLogout={this.handleLogout}
|
||||||
|
|||||||
@@ -27,6 +27,11 @@ export default class AvatarUpload extends React.Component {
|
|||||||
|
|
||||||
handleFileUpload(e) {
|
handleFileUpload(e) {
|
||||||
const image = e.target.files[0];
|
const image = e.target.files[0];
|
||||||
|
if (this.props.onImageReceived) {
|
||||||
|
this.props.onFileReceived(URL.createObjectURL(image));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (image.size > MAX_AVATAR_BYTES) {
|
if (image.size > MAX_AVATAR_BYTES) {
|
||||||
// Too large to send inband - uploading out of band and sending as a link.
|
// Too large to send inband - uploading out of band and sending as a link.
|
||||||
const uploader = this.props.tinode.getLargeFileHelper();
|
const uploader = this.props.tinode.getLargeFileHelper();
|
||||||
|
|||||||
+23
-4
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user