Add sound and tray notification support

Add conversejs locale support based on navigator.language
This commit is contained in:
Nick Denry 2019-04-25 17:21:20 +03:00
parent 557a65ad97
commit 8b75816a22
2 changed files with 15 additions and 1 deletions

View File

@ -6,19 +6,28 @@ const keytar = require('keytar');
const angular = require('angular');
const settings = require('electron-settings');
var remote = require('electron').remote;
var angApp = angular.module('app', []);
angApp.controller('AppController', function ($scope) {
$scope.loginExist = false;
$scope.login = settings.get('login');
$scope.playAudio = function() {
var audio = new Audio('sounds/graceful.ogg');
audio.play();
};
if ($scope.login) {
var showEnvelope = remote.require('./main').showEnvelope;
$scope.loginExist = true;
$scope.boshService = settings.get('bosh');
var xmppService = $scope.login.split('@').pop();
var password = keytar.getPassword(xmppService, $scope.login);
password.then((result) => {
$scope.password = result;
converse.plugins.add('chimeVerse', {
initialize: function() {
var _converse = this._converse;
@ -28,12 +37,16 @@ angApp.controller('AppController', function ($scope) {
]).then(function() {
_converse.on('message', function (data) {
//_converse.api.archive.query({'with': 'admin2@localhost'});
$scope.playAudio();
showEnvelope();
console.log(data);
});
});
}
});
var lang = navigator.language;
converse.initialize({
bosh_service_url: $scope.boshService,
view_mode: 'fullscreen',
@ -41,6 +54,7 @@ angApp.controller('AppController', function ($scope) {
password: $scope.password,
auto_login: true,
whitelisted_plugins: ['chimeVerse'],
i18n: lang
});
});
}

BIN
sounds/graceful.ogg Normal file

Binary file not shown.