Skip to content

Commit

Permalink
Also pause the notifcations when we are going offline
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Apr 23, 2020
1 parent ba9041f commit a155a3b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
8 changes: 4 additions & 4 deletions js/notifications.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/notifications.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"dependencies": {
"@nextcloud/axios": "^1.3.2",
"@nextcloud/event-bus": "^1.1.4",
"@nextcloud/moment": "^1.1.1",
"core-js": "^3.6.5",
"escape-html": "^1.0.3",
Expand Down
22 changes: 16 additions & 6 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<script>
import Notification from './Components/Notification'
import axios from '@nextcloud/axios'
import { subscribe } from '@nextcloud/event-bus'
export default {
name: 'App',
Expand Down Expand Up @@ -111,6 +112,14 @@ export default {
// Setup the background checker
this.setupBackgroundFetcher()
subscribe('networkOffline', () => {
this._shutDownNotifications(true)
})
subscribe('networkOnline', () => {
this._fetch()
this.setupBackgroundFetcher()
})
},
updated: function() {
Expand Down Expand Up @@ -213,7 +222,7 @@ export default {
} else if (err.response.status === 404) {
// 404 - App disabled
console.info('Shutting down notifications: app is disabled.')
this._shutDownNotifications()
this._shutDownNotifications(false)
return
} else {
console.info('Slowing down notifications: [' + err.response.status + '] ' + err.response.statusText)
Expand Down Expand Up @@ -243,15 +252,16 @@ export default {
},
/**
* The app was disabled or has no notifiers, so we can stop polling
* And hide the UI as well
*/
_shutDownNotifications: function() {
* The app was disabled or has no notifiers, so we can stop polling
* And hide the UI as well
* @param {Boolean} temporary If false, the notification bell will be hidden
*/
_shutDownNotifications: function(temporary) {
if (this.interval) {
window.clearInterval(this.interval)
this.interval = null
}
this.shutdown = true
this.shutdown = !temporary
},
/**
Expand Down

0 comments on commit a155a3b

Please sign in to comment.