mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 04:58:01 +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
|
||||
).catch (err) ->
|
||||
console.log 'SW register failed', err
|
||||
notifications.serviceWorkerSupported = false
|
||||
|
||||
$scope.menuToggle = () ->
|
||||
$rootScope.$broadcast('sidebarToggled')
|
||||
|
|
|
@ -48,19 +48,22 @@ module.exports = angular.module('ponyfm').directive 'pfmNotificationList', () ->
|
|||
|
||||
|
||||
checkSubscription = () ->
|
||||
$scope.disabled = true
|
||||
notifications.checkSubscription().done (subStatus) ->
|
||||
switch subStatus
|
||||
when 0
|
||||
$scope.subscribed = false
|
||||
$scope.switchDisabled = false
|
||||
when 1
|
||||
$scope.subscribed = true
|
||||
$scope.switchDisabled = false
|
||||
else
|
||||
$scope.subscribed = false
|
||||
$scope.switchDisabled = true
|
||||
$scope.hidden = true
|
||||
if 'serviceWorker' of navigator && notifications.serviceWorkerSupported
|
||||
$scope.disabled = true
|
||||
notifications.checkSubscription().done (subStatus) ->
|
||||
switch subStatus
|
||||
when 0
|
||||
$scope.subscribed = false
|
||||
$scope.switchDisabled = false
|
||||
when 1
|
||||
$scope.subscribed = true
|
||||
$scope.switchDisabled = false
|
||||
else
|
||||
$scope.subscribed = false
|
||||
$scope.switchDisabled = true
|
||||
$scope.hidden = true
|
||||
else
|
||||
$scope.switchHidden = true
|
||||
|
||||
refreshNotifications = () ->
|
||||
notifications.getNotifications().done (result) ->
|
||||
|
|
|
@ -19,6 +19,7 @@ module.exports = angular.module('ponyfm').factory('notifications', [
|
|||
($rootScope, $http) ->
|
||||
self =
|
||||
notificationList: []
|
||||
serviceWorkerSupported: true
|
||||
|
||||
getNotifications: () ->
|
||||
def = new $.Deferred()
|
||||
|
|
Loading…
Reference in a new issue