show unread threads in title, bug fix
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.8 KiB |
+14
-13
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Tinode example: chat web application in react.js</title>
|
<title>Tinode</title>
|
||||||
<link rel="manifest" href="manifest.json">
|
<link rel="manifest" href="manifest.json">
|
||||||
<link id="shortcut-icon" rel="shortcut icon" href="img/logo32x32.png" />
|
<link id="shortcut-icon" rel="shortcut icon" href="img/logo32x32.png" />
|
||||||
<link rel="apple-touch-icon" sizes="192x192" href="img/logo192.png" type="image/png" />
|
<link rel="apple-touch-icon" sizes="192x192" href="img/logo192.png" type="image/png" />
|
||||||
@@ -231,8 +231,8 @@
|
|||||||
reader.readAsDataURL(file);
|
reader.readAsDataURL(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make shortcut icon appear with a green dot.
|
// Make shortcut icon appear with a green dot + show unread count in title.
|
||||||
function updateFavicon(on) {
|
function updateFavicon(count) {
|
||||||
var oldIcon = document.getElementById("shortcut-icon");
|
var oldIcon = document.getElementById("shortcut-icon");
|
||||||
if (oldIcon) {
|
if (oldIcon) {
|
||||||
var head = document.head || document.getElementsByTagName('head')[0];
|
var head = document.head || document.getElementsByTagName('head')[0];
|
||||||
@@ -240,10 +240,11 @@
|
|||||||
newIcon.type = "image/png";
|
newIcon.type = "image/png";
|
||||||
newIcon.id = "shortcut-icon";
|
newIcon.id = "shortcut-icon";
|
||||||
newIcon.rel = "shortcut icon";
|
newIcon.rel = "shortcut icon";
|
||||||
newIcon.href = "img/logo32x32" + (on ? 'a' : '') + ".png";
|
newIcon.href = "img/logo32x32" + (count > 0 ? 'a' : '') + ".png";
|
||||||
head.removeChild(oldIcon);
|
head.removeChild(oldIcon);
|
||||||
head.appendChild(newIcon);
|
head.appendChild(newIcon);
|
||||||
}
|
}
|
||||||
|
document.title = (count > 0 ? '('+count+') ' : '') + "Tinode";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get 32 bit integer hash value for a string. Ideally it should produce the same value
|
// Get 32 bit integer hash value for a string. Ideally it should produce the same value
|
||||||
@@ -1957,13 +1958,13 @@
|
|||||||
prepareContactList: function() {
|
prepareContactList: function() {
|
||||||
var instance = this;
|
var instance = this;
|
||||||
var contacts = [];
|
var contacts = [];
|
||||||
var totalUnread = 0;
|
var unreadThreads = 0;
|
||||||
Tinode.getMeTopic().contacts(function(c) {
|
Tinode.getMeTopic().contacts(function(c) {
|
||||||
// Force to integers;
|
// Force to integers;
|
||||||
c.seq = ~~c.seq;
|
c.seq = ~~c.seq;
|
||||||
c.read = ~~c.read;
|
c.read = ~~c.read;
|
||||||
c.unread = c.seq - c.read;
|
c.unread = c.seq - c.read;
|
||||||
totalUnread += c.unread;
|
unreadThreads += c.unread > 0 ? 1 : 0;
|
||||||
contacts.push(c);
|
contacts.push(c);
|
||||||
if (instance.props.topicSelected == c.topic) {
|
if (instance.props.topicSelected == c.topic) {
|
||||||
instance.props.onOnlineChange(c.online);
|
instance.props.onOnlineChange(c.online);
|
||||||
@@ -1973,7 +1974,7 @@
|
|||||||
contacts.sort(function(a,b){
|
contacts.sort(function(a,b){
|
||||||
return b.touched - a.touched;
|
return b.touched - a.touched;
|
||||||
});
|
});
|
||||||
updateFavicon(totalUnread > 0);
|
updateFavicon(unreadThreads);
|
||||||
return contacts;
|
return contacts;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -2776,12 +2777,11 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleShowAddMembers: function() {
|
handleShowAddMembers: function() {
|
||||||
// this.props.onAddMember(this.props.topic);
|
this.props.onInitFind();
|
||||||
this.setState({showMemberPanel: true});
|
this.setState({showMemberPanel: true});
|
||||||
},
|
},
|
||||||
|
|
||||||
handleHideAddMembers: function() {
|
handleHideAddMembers: function() {
|
||||||
// this.props.onAddMember(this.props.topic);
|
|
||||||
this.setState({showMemberPanel: false});
|
this.setState({showMemberPanel: false});
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -3308,6 +3308,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Get older messages
|
||||||
fetchMoreMessages: function(event) {
|
fetchMoreMessages: function(event) {
|
||||||
var instance = this;
|
var instance = this;
|
||||||
if (event.target.scrollTop <= 0) {
|
if (event.target.scrollTop <= 0) {
|
||||||
@@ -3316,7 +3317,7 @@
|
|||||||
this.setState(function(prevState, props) {
|
this.setState(function(prevState, props) {
|
||||||
if (!prevState.fetchingMessages) {
|
if (!prevState.fetchingMessages) {
|
||||||
var topic = Tinode.getTopic(instance.state.topic);
|
var topic = Tinode.getTopic(instance.state.topic);
|
||||||
if (topic && topic.isSubscribed() && topic.msgHasMore()) {
|
if (topic && topic.isSubscribed() && topic.msgHasMoreMessages()) {
|
||||||
newState.fetchingMessages = true;
|
newState.fetchingMessages = true;
|
||||||
topic.getMessagesPage(MESSAGES_PAGE).then(function() {
|
topic.getMessagesPage(MESSAGES_PAGE).then(function() {
|
||||||
instance.setState({fetchingMessages: false});
|
instance.setState({fetchingMessages: false});
|
||||||
@@ -4050,13 +4051,13 @@
|
|||||||
/* Fnd topic: find contacts by tokens */
|
/* Fnd topic: find contacts by tokens */
|
||||||
tnInitFind: function() {
|
tnInitFind: function() {
|
||||||
var fnd = Tinode.getFndTopic();
|
var fnd = Tinode.getFndTopic();
|
||||||
fnd.onSubsUpdated = this.tnFndSubsUpdated;
|
|
||||||
fnd.onMetaDesc = this.tnFndMetaDesc;
|
|
||||||
var instance = this;
|
|
||||||
if (fnd.isSubscribed()) {
|
if (fnd.isSubscribed()) {
|
||||||
this.setState({contactsSearchQuery: fnd.private ? fnd.private.toString() : ''});
|
this.setState({contactsSearchQuery: fnd.private ? fnd.private.toString() : ''});
|
||||||
this.tnFndSubsUpdated();
|
this.tnFndSubsUpdated();
|
||||||
} else {
|
} else {
|
||||||
|
fnd.onSubsUpdated = this.tnFndSubsUpdated;
|
||||||
|
fnd.onMetaDesc = this.tnFndMetaDesc;
|
||||||
|
var instance = this;
|
||||||
fnd.subscribe(fnd.startMetaQuery().withSub().withLaterDesc().withTags().build()).catch(function(err){
|
fnd.subscribe(fnd.startMetaQuery().withSub().withLaterDesc().withTags().build()).catch(function(err){
|
||||||
instance.handleError(err.message, "err");
|
instance.handleError(err.message, "err");
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user