mirror of
https://github.com/moparisthebest/kaiwa
synced 2024-11-29 12:42:16 -05:00
Make notifications smarter with page focus test
This commit is contained in:
parent
6e93404215
commit
4a0cb10197
@ -24,6 +24,14 @@ module.exports = {
|
|||||||
window.location = '/login';
|
window.location = '/login';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.hasFocus = false;
|
||||||
|
$(window).blur(function () {
|
||||||
|
me.hasFocus = false;
|
||||||
|
});
|
||||||
|
$(window).focus(function () {
|
||||||
|
me.hasFocus = true;
|
||||||
|
});
|
||||||
|
|
||||||
config = JSON.parse(config);
|
config = JSON.parse(config);
|
||||||
|
|
||||||
_.extend(this, Backbone.Events);
|
_.extend(this, Backbone.Events);
|
||||||
|
@ -159,7 +159,7 @@ module.exports = HumanModel.define({
|
|||||||
addMessage: function (message, notify) {
|
addMessage: function (message, notify) {
|
||||||
message.owner = me.jid.bare;
|
message.owner = me.jid.bare;
|
||||||
|
|
||||||
if (notify && !this.activeContact && message.from.bare === this.jid) {
|
if (notify && (!this.activeContact || (this.activeContact && !app.hasFocus)) && message.from.bare === this.jid) {
|
||||||
this.unreadCount++;
|
this.unreadCount++;
|
||||||
app.notifier.show({
|
app.notifier.show({
|
||||||
title: this.displayName,
|
title: this.displayName,
|
||||||
|
@ -10,6 +10,9 @@ var uuid = require('node-uuid');
|
|||||||
module.exports = HumanModel.define({
|
module.exports = HumanModel.define({
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
this.bind('change:jid', this.loadContacts, this);
|
this.bind('change:jid', this.loadContacts, this);
|
||||||
|
this.bind('change:hasFocus', function () {
|
||||||
|
this.setActiveContact(this._activeContact);
|
||||||
|
}, this);
|
||||||
},
|
},
|
||||||
session: {
|
session: {
|
||||||
jid: ['object', true],
|
jid: ['object', true],
|
||||||
@ -17,6 +20,7 @@ module.exports = HumanModel.define({
|
|||||||
avatar: ['string', true, ''],
|
avatar: ['string', true, ''],
|
||||||
connected: ['bool', true, false],
|
connected: ['bool', true, false],
|
||||||
shouldAskForAlertsPermission: ['bool', true, false],
|
shouldAskForAlertsPermission: ['bool', true, false],
|
||||||
|
hasFocus: ['bool', true, false],
|
||||||
_activeContact: ['string', true, '']
|
_activeContact: ['string', true, '']
|
||||||
},
|
},
|
||||||
collections: {
|
collections: {
|
||||||
|
@ -303,7 +303,7 @@ nav.main a {
|
|||||||
#chatInput {
|
#chatInput {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 0px;
|
bottom: 0px;
|
||||||
left: 176px;
|
left: 156px;
|
||||||
right: 0px;
|
right: 0px;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
background: #ecf0f2;
|
background: #ecf0f2;
|
||||||
|
Loading…
Reference in New Issue
Block a user