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) { constructor(props) {
super(props); super(props);
let me = Tinode.getMeTopic();
let defacs = me.getDefaultAccess();
let fnd = Tinode.getFndTopic();
this.state = { this.state = {
address: null, fullName: me.public ? me.public.fn : undefined,
fullName: undefined, avatar: makeImageUrl(me.public ? me.public.photo : null),
avatar: null, address: Tinode.getCurrentUserID(),
login: undefined, auth: defacs.auth,
password: undefined, anon: defacs.anon,
previousOnTags: undefined, tags: fnd.tags(),
tags: [] previousOnTags: fnd.onTagsUpdated
}; };
this.tnNewTags = this.tnNewTags.bind(this); this.tnNewTags = this.tnNewTags.bind(this);
@@ -1677,24 +1680,12 @@ class EditAccountView extends React.Component {
this.handleTagsUpdated = this.handleTagsUpdated.bind(this); this.handleTagsUpdated = this.handleTagsUpdated.bind(this);
} }
componentWillMount() { componentDidMount() {
var me = Tinode.getMeTopic(); let fnd = Tinode.getFndTopic();
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
});
fnd.onTagsUpdated = this.tnNewTags; fnd.onTagsUpdated = this.tnNewTags;
if (!fnd.isSubscribed()) { if (!fnd.isSubscribed()) {
var instance = this; fnd.subscribe(fnd.startMetaQuery().withLaterDesc().withTags().build()).catch((err) => {
fnd.subscribe(fnd.startMetaQuery().withLaterDesc().withTags().build()).catch(function(err){ this.props.onError(err.message, "err");
instance.props.onError(err.message, "err");
}); });
} }
} }
@@ -3820,7 +3811,7 @@ class MessagesView extends React.Component {
this.forceUpdate(); this.forceUpdate();
break; break;
default: default:
console.log("Other change in topic: " + info.what); console.log("Other change in topic: ", info.what);
} }
} }