Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 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.

16 changes: 15 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default {
backgroundFetching: false,
shutdown: false,
notifications: [],
lastETag: null,

/** @type {number} */
pollInterval: 30000, // milliseconds
Expand Down Expand Up @@ -184,13 +185,23 @@ export default {
* Performs the AJAX request to retrieve the notifications
*/
_fetch: function() {
let requestConfig = {}
if (this.lastETag) {
requestConfig = {
headers: {
'If-None-Match': this.lastETag,
},
}
}

axios
.get(OC.linkToOCS('apps/notifications/api/v2', 2) + 'notifications')
.get(OC.linkToOCS('apps/notifications/api/v2', 2) + 'notifications', requestConfig)
.then(response => {
if (response.status === 204) {
// 204 No Content - Intercept when no notifiers are there.
this._shutDownNotifications()
} else if (response.data !== undefined && response.data.ocs !== undefined && response.data.ocs.data !== undefined && Array.isArray(response.data.ocs.data)) {
this.lastETag = response.headers.etag
this.notifications = response.data.ocs.data
} else {
console.info('data.ocs.data is undefined or not an array')
Expand All @@ -200,6 +211,9 @@ export default {
if (!err.response) {
console.info('No response received, retrying')
return
} else if (err.response.status === 304) {
// 304 - Not modified
return
} else if (err.response.status === 503) {
// 503 - Maintenance mode
console.info('Shutting down notifications: instance is in maintenance mode.')
Expand Down