mirror of
https://github.com/moparisthebest/kaiwa
synced 2024-11-26 03:02:25 -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';
|
||||
}
|
||||
|
||||
app.hasFocus = false;
|
||||
$(window).blur(function () {
|
||||
me.hasFocus = false;
|
||||
});
|
||||
$(window).focus(function () {
|
||||
me.hasFocus = true;
|
||||
});
|
||||
|
||||
config = JSON.parse(config);
|
||||
|
||||
_.extend(this, Backbone.Events);
|
||||
|
@ -159,7 +159,7 @@ module.exports = HumanModel.define({
|
||||
addMessage: function (message, notify) {
|
||||
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++;
|
||||
app.notifier.show({
|
||||
title: this.displayName,
|
||||
|
@ -10,6 +10,9 @@ var uuid = require('node-uuid');
|
||||
module.exports = HumanModel.define({
|
||||
initialize: function () {
|
||||
this.bind('change:jid', this.loadContacts, this);
|
||||
this.bind('change:hasFocus', function () {
|
||||
this.setActiveContact(this._activeContact);
|
||||
}, this);
|
||||
},
|
||||
session: {
|
||||
jid: ['object', true],
|
||||
@ -17,6 +20,7 @@ module.exports = HumanModel.define({
|
||||
avatar: ['string', true, ''],
|
||||
connected: ['bool', true, false],
|
||||
shouldAskForAlertsPermission: ['bool', true, false],
|
||||
hasFocus: ['bool', true, false],
|
||||
_activeContact: ['string', true, '']
|
||||
},
|
||||
collections: {
|
||||
|
@ -303,7 +303,7 @@ nav.main a {
|
||||
#chatInput {
|
||||
position: fixed;
|
||||
bottom: 0px;
|
||||
left: 176px;
|
||||
left: 156px;
|
||||
right: 0px;
|
||||
z-index: 100;
|
||||
background: #ecf0f2;
|
||||
|
Loading…
Reference in New Issue
Block a user