mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-12-01 17:17:59 +01:00
#25: Hide toggle if service worker fails to register
This commit is contained in:
parent
61520815de
commit
88aa2950b3
3 changed files with 18 additions and 13 deletions
|
@ -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')
|
||||||
|
|
|
@ -48,19 +48,22 @@ module.exports = angular.module('ponyfm').directive 'pfmNotificationList', () ->
|
||||||
|
|
||||||
|
|
||||||
checkSubscription = () ->
|
checkSubscription = () ->
|
||||||
$scope.disabled = true
|
if 'serviceWorker' of navigator && notifications.serviceWorkerSupported
|
||||||
notifications.checkSubscription().done (subStatus) ->
|
$scope.disabled = true
|
||||||
switch subStatus
|
notifications.checkSubscription().done (subStatus) ->
|
||||||
when 0
|
switch subStatus
|
||||||
$scope.subscribed = false
|
when 0
|
||||||
$scope.switchDisabled = false
|
$scope.subscribed = false
|
||||||
when 1
|
$scope.switchDisabled = false
|
||||||
$scope.subscribed = true
|
when 1
|
||||||
$scope.switchDisabled = false
|
$scope.subscribed = true
|
||||||
else
|
$scope.switchDisabled = false
|
||||||
$scope.subscribed = false
|
else
|
||||||
$scope.switchDisabled = true
|
$scope.subscribed = false
|
||||||
$scope.hidden = true
|
$scope.switchDisabled = true
|
||||||
|
$scope.hidden = true
|
||||||
|
else
|
||||||
|
$scope.switchHidden = true
|
||||||
|
|
||||||
refreshNotifications = () ->
|
refreshNotifications = () ->
|
||||||
notifications.getNotifications().done (result) ->
|
notifications.getNotifications().done (result) ->
|
||||||
|
|
|
@ -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()
|
||||||
|
|
Loading…
Reference in a new issue