Give feedback of error messages via Desktop notifications
This commit is contained in:
parent
6a02070a3b
commit
6b3fbc9998
@ -406,6 +406,7 @@
|
|||||||
$el.removeClass('error');
|
$el.removeClass('error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
converse.emit('feedback', {'message': message, 'klass': klass});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.rejectPresenceSubscription = function (jid, message) {
|
this.rejectPresenceSubscription = function (jid, message) {
|
||||||
|
@ -180,6 +180,15 @@
|
|||||||
setTimeout(n.close.bind(n), 5000);
|
setTimeout(n.close.bind(n), 5000);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
converse.showErrorNotification = function (data) {
|
||||||
|
var n = new Notification(__('An error has occured'), {
|
||||||
|
body: data.message,
|
||||||
|
lang: converse.i18n.locale_data.converse[""].lang,
|
||||||
|
icon: 'logo/conversejs.png'
|
||||||
|
});
|
||||||
|
setTimeout(n.close.bind(n), 5000);
|
||||||
|
};
|
||||||
|
|
||||||
converse.handleChatStateNotification = function (evt, contact) {
|
converse.handleChatStateNotification = function (evt, contact) {
|
||||||
/* Event handler for on('contactStatusChanged').
|
/* Event handler for on('contactStatusChanged').
|
||||||
* Will show an HTML5 notification to indicate that the chat
|
* Will show an HTML5 notification to indicate that the chat
|
||||||
@ -210,6 +219,12 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
converse.handleFeedback = function (evt, data) {
|
||||||
|
if (data.klass === 'error' && converse.areDesktopNotificationsEnabled(true)) {
|
||||||
|
converse.showErrorNotification(data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
converse.requestPermission = function (evt) {
|
converse.requestPermission = function (evt) {
|
||||||
if (supports_html5_notification &&
|
if (supports_html5_notification &&
|
||||||
! _.contains(['denied', 'granted'], Notification.permission)) {
|
! _.contains(['denied', 'granted'], Notification.permission)) {
|
||||||
@ -221,6 +236,7 @@
|
|||||||
converse.on('contactRequest', converse.handleContactRequestNotification);
|
converse.on('contactRequest', converse.handleContactRequestNotification);
|
||||||
converse.on('contactStatusChanged', converse.handleChatStateNotification);
|
converse.on('contactStatusChanged', converse.handleChatStateNotification);
|
||||||
converse.on('message', converse.handleMessageNotification);
|
converse.on('message', converse.handleMessageNotification);
|
||||||
|
converse.on('feedback', converse.handleFeedback);
|
||||||
converse.on('connected', converse.requestPermission);
|
converse.on('connected', converse.requestPermission);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user