#25: Hide toggle if service worker fails to register

This commit is contained in:
Josef Citrine 2016-06-12 01:07:14 +01:00
parent 61520815de
commit 88aa2950b3
3 changed files with 18 additions and 13 deletions

View file

@ -33,6 +33,7 @@ module.exports = angular.module('ponyfm').controller "application", [
console.log 'SW registered', reg console.log 'SW registered', reg
).catch (err) -> ).catch (err) ->
console.log 'SW register failed', err console.log 'SW register failed', err
notifications.serviceWorkerSupported = false
$scope.menuToggle = () -> $scope.menuToggle = () ->
$rootScope.$broadcast('sidebarToggled') $rootScope.$broadcast('sidebarToggled')

View file

@ -48,6 +48,7 @@ module.exports = angular.module('ponyfm').directive 'pfmNotificationList', () ->
checkSubscription = () -> checkSubscription = () ->
if 'serviceWorker' of navigator && notifications.serviceWorkerSupported
$scope.disabled = true $scope.disabled = true
notifications.checkSubscription().done (subStatus) -> notifications.checkSubscription().done (subStatus) ->
switch subStatus switch subStatus
@ -61,6 +62,8 @@ module.exports = angular.module('ponyfm').directive 'pfmNotificationList', () ->
$scope.subscribed = false $scope.subscribed = false
$scope.switchDisabled = true $scope.switchDisabled = true
$scope.hidden = true $scope.hidden = true
else
$scope.switchHidden = true
refreshNotifications = () -> refreshNotifications = () ->
notifications.getNotifications().done (result) -> notifications.getNotifications().done (result) ->

View file

@ -19,6 +19,7 @@ module.exports = angular.module('ponyfm').factory('notifications', [
($rootScope, $http) -> ($rootScope, $http) ->
self = self =
notificationList: [] notificationList: []
serviceWorkerSupported: true
getNotifications: () -> getNotifications: () ->
def = new $.Deferred() def = new $.Deferred()