Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug missing notification bell #973

Merged
merged 1 commit into from
May 25, 2021
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
4 changes: 2 additions & 2 deletions js/notifications-main.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export default {
},

beforeMount() {
console.debug('Loading theming data for notification bell styling')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use @nextcloud/logger? :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something is preventing the app to continue. I'd like to avoid loading more dependencies just to find out what and then revert it 😬

this.theming = loadState('theming', 'data', {})
},

Expand All @@ -144,6 +145,7 @@ export default {
this._oldcount = 0

// Bind the button click event
console.debug('Registering notifications container as a menu')
OC.registerMenu($(this.$refs.button), $(this.$refs.container), undefined, true)

this.checkWebNotificationPermissions()
Expand All @@ -155,6 +157,7 @@ export default {
this._fetch()
})
if (hasPush) {
console.debug('Has notify_push enabled, slowing polling to 15 minutes')
this.pollIntervalBase = 15 * 60 * 1000
}

Expand All @@ -173,6 +176,7 @@ export default {

updated() {
if (!this.hadNotifications && this.notifications.length) {
console.debug('New notification, animating the bell icon')
this._$icon
.animate({ opacity: 0.6 }, 600)
.animate({ opacity: 1 }, 600)
Expand All @@ -185,17 +189,22 @@ export default {

methods: {
handleNetworkOffline() {
console.debug('Network is offline, slowing down pollingInterval to ' + this.pollIntervalBase * 10)
this._setPollingInterval(this.pollIntervalBase * 10)
},

handleNetworkOnline() {
this._fetch()
console.debug('Network is online, reseting pollingInterval to ' + this.pollIntervalBase)
this._setPollingInterval(this.pollIntervalBase)
},

setupBackgroundFetcher() {
if (OC.config.session_keepalive) {
console.debug('Started background fetcher as session_keepalive is enabled')
this.interval = window.setInterval(this._backgroundFetch.bind(this), this.pollIntervalCurrent)
} else {
console.debug('Did not start background fetcher as session_keepalive is off')
}
},

Expand Down Expand Up @@ -275,16 +284,19 @@ export default {

if (response.status === 204) {
// 204 No Content - Intercept when no notifiers are there.
console.debug('Fetching notifications but no content, slowing down polling to ' + this.pollIntervalBase * 10)
this._setPollingInterval(this.pollIntervalBase * 10)
} else if (response.status === 200) {
this.userStatus = response.headers['x-nextcloud-user-status']
this.lastETag = response.headers.etag
this.lastTabId = response.tabId
this.notifications = response.data
console.debug('Got notification data')
this._setPollingInterval(this.pollIntervalBase)
this._updateDocTitleOnNewNotifications(this.notifications)
} else if (response.status === 304) {
// 304 - Not modified
console.debug('No new notification data received')
this._setPollingInterval(this.pollIntervalBase)
} else if (response.status === 503) {
// 503 - Maintenance mode
Expand Down Expand Up @@ -316,6 +328,7 @@ export default {
},

_setPollingInterval(pollInterval) {
console.debug('Polling interval updated to ' + pollInterval)
if (this.interval && pollInterval === this.pollIntervalCurrent) {
return
}
Expand All @@ -335,6 +348,7 @@ export default {
* @param {Boolean} temporary If false, the notification bell will be hidden
*/
_shutDownNotifications(temporary) {
console.debug('Shutting down notifications ' + ((temporary) ? 'temporary' : 'bye'))
if (this.interval) {
window.clearInterval(this.interval)
this.interval = null
Expand Down