add green dot to shortcut icon to indicate unread messages
This commit is contained in:
@@ -6,7 +6,7 @@ and [icons](https://google.github.io/material-design-icons/#icon-font-for-the-we
|
|||||||
|
|
||||||
This is work in progress. Bugs are expected. The app was tested in the latest Chrome & Firefox only.
|
This is work in progress. Bugs are expected. The app was tested in the latest Chrome & Firefox only.
|
||||||
|
|
||||||
Try it (possibly newer or older version) live at https://api.tinode.co/x/example-react-js/. Login as one of `alice`, `bob`, `carol`, `dave`, `frank`. Password is `<login>123`, e.g. password for `alice` is `alice123`. You can discover other users by email or phone by prefixing them with `email:` or `tel:` respectively. Emails are `<login>@example.com`, e.g. `alice@example.com`, phones are `17025550001` through `17025550009`. The demo is reset every night at 2:15 am Pacific time.
|
Try possibly newer or older version live at https://api.tinode.co/x/example-react-js/. Login as one of `alice`, `bob`, `carol`, `dave`, `frank`. Password is `<login>123`, e.g. password for `alice` is `alice123`. You can discover other users by email or phone by prefixing them with `email:` or `tel:` respectively. Emails are `<login>@example.com`, e.g. `alice@example.com`, phones are `17025550001` through `17025550009`. The demo is reset every night at 2:15am Pacific time.
|
||||||
|
|
||||||
License: [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
License: [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ Background pattern from http://subtlepatterns.com/, commercial and non-commercia
|
|||||||
* Cannot delete messages.
|
* Cannot delete messages.
|
||||||
* No indication of chat status (muted, blocked, etc.).
|
* No indication of chat status (muted, blocked, etc.).
|
||||||
* Browser push notifications are missing.
|
* Browser push notifications are missing.
|
||||||
* No encryption.
|
* No end-to-end encryption.
|
||||||
* Editing chat permissions is incomplete.
|
* Editing chat permissions is incomplete.
|
||||||
|
|
||||||
## Responsive design
|
## Responsive design
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 2.0 KiB |
+19
-4
@@ -4,7 +4,7 @@
|
|||||||
<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 example: chat web application in react.js</title>
|
||||||
<link rel="shortcut icon" href="img/logo32x32.png" />
|
<link id="shortcut-icon" rel="shortcut icon" href="img/logo32x32.png" />
|
||||||
<!-- Browser styling for Chrome, FF, Opera -->
|
<!-- Browser styling for Chrome, FF, Opera -->
|
||||||
<meta name="theme-color" content="#3949AB">
|
<meta name="theme-color" content="#3949AB">
|
||||||
<!-- Google's Roboto font -->
|
<!-- Google's Roboto font -->
|
||||||
@@ -75,6 +75,20 @@
|
|||||||
'data:image/' + photo.type + ';base64,' + photo.data : null;
|
'data:image/' + photo.type + ';base64,' + photo.data : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make shortcut icon appear with a green dot.
|
||||||
|
function updateFavicon(on) {
|
||||||
|
var oldIcon = document.getElementById("shortcut-icon");
|
||||||
|
if (oldIcon) {
|
||||||
|
var head = document.head || document.getElementsByTagName('head')[0];
|
||||||
|
var newIcon = document.createElement('link');
|
||||||
|
newIcon.type = "image/png";
|
||||||
|
newIcon.id = "shortcut-icon";
|
||||||
|
newIcon.rel = "shortcut icon";
|
||||||
|
newIcon.href = "img/logo32x32" + (on ? 'a' : '') + ".png";
|
||||||
|
head.removeChild(oldIcon);
|
||||||
|
head.appendChild(newIcon);
|
||||||
|
}
|
||||||
|
}
|
||||||
// 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
|
||||||
// as Java's String#hash().
|
// as Java's String#hash().
|
||||||
function stringHash(value) {
|
function stringHash(value) {
|
||||||
@@ -1067,7 +1081,6 @@
|
|||||||
|
|
||||||
this.props.state === 'contacts' ?
|
this.props.state === 'contacts' ?
|
||||||
<ContactsView
|
<ContactsView
|
||||||
data={this.props.subscriptions}
|
|
||||||
topicSelected={this.props.topicSelected}
|
topicSelected={this.props.topicSelected}
|
||||||
showContextMenu={this.props.showContextMenu}
|
showContextMenu={this.props.showContextMenu}
|
||||||
onTopicSelected={this.props.onTopicSelected} /> :
|
onTopicSelected={this.props.onTopicSelected} /> :
|
||||||
@@ -1355,11 +1368,15 @@
|
|||||||
|
|
||||||
prepareContactList: function() {
|
prepareContactList: function() {
|
||||||
var contacts = [];
|
var contacts = [];
|
||||||
|
var totalUnread = 0;
|
||||||
Tinode.getMeTopic().contacts(function(c) {
|
Tinode.getMeTopic().contacts(function(c) {
|
||||||
c.unread = c.seq - (c.read > 0 ? c.read : 0);
|
c.unread = c.seq - (c.read > 0 ? c.read : 0);
|
||||||
|
totalUnread += c.unread;
|
||||||
contacts.push(c);
|
contacts.push(c);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
updateFavicon(totalUnread > 0);
|
||||||
|
|
||||||
return contacts;
|
return contacts;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -2800,7 +2817,6 @@
|
|||||||
liveConnection: navigator.onLine,
|
liveConnection: navigator.onLine,
|
||||||
topicSelected: '',
|
topicSelected: '',
|
||||||
loginDisabled: false,
|
loginDisabled: false,
|
||||||
subscriptions: {},
|
|
||||||
displayMobile: (window.innerWidth <= MEDIA_BREAKPOINT),
|
displayMobile: (window.innerWidth <= MEDIA_BREAKPOINT),
|
||||||
showInfoPanel: false,
|
showInfoPanel: false,
|
||||||
infoPanelShowMembers: false,
|
infoPanelShowMembers: false,
|
||||||
@@ -3272,7 +3288,6 @@
|
|||||||
state={this.state.sidePanelSelected}
|
state={this.state.sidePanelSelected}
|
||||||
title={this.state.sidePanelTitle}
|
title={this.state.sidePanelTitle}
|
||||||
avatar={this.state.sidePanelAvatar}
|
avatar={this.state.sidePanelAvatar}
|
||||||
subscriptions={this.state.subscriptions}
|
|
||||||
login={this.state.login}
|
login={this.state.login}
|
||||||
myUserId={this.state.myUserId}
|
myUserId={this.state.myUserId}
|
||||||
loginDisabled={this.state.loginDisabled}
|
loginDisabled={this.state.loginDisabled}
|
||||||
|
|||||||
Reference in New Issue
Block a user