refactoring of {sub} {get} and {set} for clarity
This commit is contained in:
+17
-19
@@ -21,18 +21,18 @@
|
|||||||
<!-- Some scripts to make bootstrap more dynamic -->
|
<!-- Some scripts to make bootstrap more dynamic -->
|
||||||
<!--script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script-->
|
<!--script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script-->
|
||||||
<!--script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script-->
|
<!--script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script-->
|
||||||
<script src="tinode-0.5.1.js"></script>
|
<script src="tinode.js"></script>
|
||||||
</head>
|
</head>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="mountPoint"></div>
|
<div id="mountPoint"></div>
|
||||||
<script type="text/babel">
|
<script type="text/babel">
|
||||||
// Name of this application, used in the User-Agent
|
// Name of this application, used in the User-Agent
|
||||||
var APP_NAME = "TinodeReact/1.0";
|
var APP_NAME = "TinodeReact/0.6";
|
||||||
|
|
||||||
// Host name and posrt to connect to
|
// Host name and port to connect to
|
||||||
var HOST = "api.tinode.co";
|
// var HOST = "api.tinode.co";
|
||||||
// var HOST = "localhost:6060";
|
var HOST = "localhost:6060";
|
||||||
|
|
||||||
// API key. Use https://github.com/tinode/chat/tree/master/keygen to generate your own
|
// API key. Use https://github.com/tinode/chat/tree/master/keygen to generate your own
|
||||||
var API_KEY = "AQEAAAABAAD_rAp4DJh05a1HAwFT3A6K";
|
var API_KEY = "AQEAAAABAAD_rAp4DJh05a1HAwFT3A6K";
|
||||||
@@ -668,24 +668,24 @@
|
|||||||
// Bind the new topic to component.
|
// Bind the new topic to component.
|
||||||
topic.onData = this.handleNewMessage;
|
topic.onData = this.handleNewMessage;
|
||||||
topic.onInfo = this.handleInfoReceipt;
|
topic.onInfo = this.handleInfoReceipt;
|
||||||
topic.onMetaInfo = this.handleInfoChange;
|
topic.onMetaDesc = this.handleDescChange;
|
||||||
topic.onSubsUpdated = this.handleSubsUpdated;
|
topic.onSubsUpdated = this.handleSubsUpdated;
|
||||||
// Unbind the previous topic from this component.
|
// Unbind the previous topic from this component.
|
||||||
if (this.state.topic) {
|
if (this.state.topic) {
|
||||||
var oldTopic = Tinode.getTopic(this.state.topic);
|
var oldTopic = Tinode.getTopic(this.state.topic);
|
||||||
oldTopic.onData = undefined;
|
oldTopic.onData = undefined;
|
||||||
oldTopic.onInfo = undefined;
|
oldTopic.onInfo = undefined;
|
||||||
oldTopic.onMetaInfo = undefined;
|
oldTopic.onMetaDesc = undefined;
|
||||||
oldTopic.onSubsUpdated = undefined;
|
oldTopic.onSubsUpdated = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (topic.isSubscribed()) {
|
if (topic.isSubscribed()) {
|
||||||
this.handleInfoChange(topic);
|
this.handleDescChange(topic);
|
||||||
topic.messages(function(msg) {
|
topic.messages(function(msg) {
|
||||||
msgs = msgs.concat(msg);
|
msgs = msgs.concat(msg);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
topic.subscribe({get: "info sub data"});
|
topic.subscribe({get: {desc: {}, sub: {}, data: {}}});
|
||||||
}
|
}
|
||||||
|
|
||||||
// The user switched to the new topic before the timer for
|
// The user switched to the new topic before the timer for
|
||||||
@@ -695,8 +695,8 @@
|
|||||||
this.setState({messages: msgs, topic: props.topicSelected});
|
this.setState({messages: msgs, topic: props.topicSelected});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleInfoChange: function(info) {
|
handleDescChange: function(desc) {
|
||||||
this.setState({title: info.public.vcard.fn});
|
this.setState({title: desc.public.vcard.fn});
|
||||||
},
|
},
|
||||||
handleSubsUpdated: function(uids) {
|
handleSubsUpdated: function(uids) {
|
||||||
|
|
||||||
@@ -940,8 +940,6 @@
|
|||||||
if (this.state.displayMobile != mobile) {
|
if (this.state.displayMobile != mobile) {
|
||||||
this.setState({displayMobile: mobile});
|
this.setState({displayMobile: mobile});
|
||||||
}
|
}
|
||||||
console.log("viewport (mob=" + mobile + "): " + document.documentElement.clientWidth +
|
|
||||||
"x" + document.documentElement.clientHeight);
|
|
||||||
},
|
},
|
||||||
handleDisconnect: function() {
|
handleDisconnect: function() {
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -967,19 +965,19 @@
|
|||||||
}).then(function() {
|
}).then(function() {
|
||||||
// Logged in fine, subscribe to 'me' attaching callbacks from the contacts view.
|
// Logged in fine, subscribe to 'me' attaching callbacks from the contacts view.
|
||||||
var me = Tinode.getMeTopic();
|
var me = Tinode.getMeTopic();
|
||||||
me.onMetaInfo = instance.tnMeMetaInfo;
|
me.onMetaDesc = instance.tnMeMetaDesc;
|
||||||
instance.setState({sidePanelSelected: "contacts", loggedIn: true});
|
instance.setState({sidePanelSelected: "contacts", loggedIn: true});
|
||||||
// Subscribe, fetch topic info and the list of subscriptions.
|
// Subscribe, fetch topic desc, the list of subscriptions, and messages (invites).
|
||||||
me.subscribe({get: "info sub data"});
|
me.subscribe({get: {desc: {}, sub: {}, data: {}}});
|
||||||
}).catch(function(err) {
|
}).catch(function(err) {
|
||||||
// Login failed, report error
|
// Login failed, report error
|
||||||
instance.setState({loginDisabled: false, errorText: err.message});
|
instance.setState({loginDisabled: false, errorText: err.message});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
tnMeMetaInfo: function(info) {
|
tnMeMetaDesc: function(desc) {
|
||||||
this.setState({
|
this.setState({
|
||||||
sidePanelTitle: info.public.vcard.fn,
|
sidePanelTitle: desc.public.vcard.fn,
|
||||||
sidePanelAvatar: makeImageUrl(info.public.vcard.photo)
|
sidePanelAvatar: makeImageUrl(desc.public.vcard.photo)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// Sending "received" notifications
|
// Sending "received" notifications
|
||||||
|
|||||||
Reference in New Issue
Block a user