Commit b337396f authored by Benoit Lavenier's avatar Benoit Lavenier

[fix] Fix Android build

[fix] Android: Avoid error in the Cesium+ settings page, because of HTML5 Notifications
parent 7d3f3f57
......@@ -6,9 +6,7 @@
// 'starter.controllers' is found in controllers.js
angular.module('cesium', ['ionic', 'ionic-material', 'ngMessages', 'pascalprecht.translate',
'ngApi', 'angular-cache', 'angular.screenmatch', 'angular.bind.notifier', 'ImageCropper', 'ion-digit-keyboard',
// removeIf(device)
'FBAngular', // angulmar-fullscreen
// endRemoveIf(device)
'FBAngular', // = angular-fullscreen
// removeIf(no-device)
'ngCordova',
// endRemoveIf(no-device)
......
......@@ -52,6 +52,7 @@ function ESPluginSettingsController ($scope, $window, $q, $translate, $ionicPop
UIUtils, Modals, csHttp, csConfig, csSettings, esHttp, esSettings) {
'ngInject';
$scope.hasWindowNotification = !!("Notification" in window);
$scope.formData = {};
$scope.popupData = {}; // need for the node popup
$scope.loading = true;
......@@ -223,8 +224,9 @@ function ESPluginSettingsController ($scope, $window, $q, $translate, $ionicPop
$scope.onFormChanged = function() {
if ($scope.loading) return;
if ($scope.formData.notifications.emitHtml5 !== (!!("Notification" in window) && Notification.permission === "granted")){
Notification.requestPermission(function (permission) {
if ($scope.hasWindowNotification &&
$scope.formData.notifications.emitHtml5 !== (window.Notification.permission === "granted")){
window.Notification.requestPermission(function (permission) {
// If the user accepts, let's create a notification
$scope.formData.notifications.emitHtml5 = (permission === "granted"); // revert to false if permission not granted
$scope.onFormChanged(); // Loop
......@@ -241,8 +243,6 @@ function ESPluginSettingsController ($scope, $window, $q, $translate, $ionicPop
// Fix old settings (unused)
delete csSettings.data.plugins.es.newNode;
csSettings.store()
.then(function() {
$scope.loading = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment