starting to get rid of componentWillMount per React spec

This commit is contained in:
or-else
2018-08-19 11:22:43 +03:00
parent f782bc11cc
commit 4be41e47f4
+15 -24
View File
@@ -1660,14 +1660,17 @@ class EditAccountView extends React.Component {
constructor(props) {
super(props);
let me = Tinode.getMeTopic();
let defacs = me.getDefaultAccess();
let fnd = Tinode.getFndTopic();
this.state = {
address: null,
fullName: undefined,
avatar: null,
login: undefined,
password: undefined,
previousOnTags: undefined,
tags: []
fullName: me.public ? me.public.fn : undefined,
avatar: makeImageUrl(me.public ? me.public.photo : null),
address: Tinode.getCurrentUserID(),
auth: defacs.auth,
anon: defacs.anon,
tags: fnd.tags(),
previousOnTags: fnd.onTagsUpdated
};
this.tnNewTags = this.tnNewTags.bind(this);
@@ -1677,24 +1680,12 @@ class EditAccountView extends React.Component {
this.handleTagsUpdated = this.handleTagsUpdated.bind(this);
}
componentWillMount() {
var me = Tinode.getMeTopic();
var defacs = me.getDefaultAccess();
var fnd = Tinode.getFndTopic();
this.setState({
fullName: me.public ? me.public.fn : undefined,
avatar: makeImageUrl(me.public ? me.public.photo : null),
address: Tinode.getCurrentUserID(),
auth: defacs.auth,
anon: defacs.anon,
tags: fnd.tags(),
previousOnTags: fnd.onTagsUpdated
});
componentDidMount() {
let fnd = Tinode.getFndTopic();
fnd.onTagsUpdated = this.tnNewTags;
if (!fnd.isSubscribed()) {
var instance = this;
fnd.subscribe(fnd.startMetaQuery().withLaterDesc().withTags().build()).catch(function(err){
instance.props.onError(err.message, "err");
fnd.subscribe(fnd.startMetaQuery().withLaterDesc().withTags().build()).catch((err) => {
this.props.onError(err.message, "err");
});
}
}
@@ -3820,7 +3811,7 @@ class MessagesView extends React.Component {
this.forceUpdate();
break;
default:
console.log("Other change in topic: " + info.what);
console.log("Other change in topic: ", info.what);
}
}