Skip to content
Merged
Changes from 1 commit
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
Next Next commit
fix(notification): Allow intercepting the "onclick" for browser notif…
…ications

This allows Talk to jump to the chat without a page refresh again.

Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Feb 8, 2023
commit e8c91a47d731e79033df43337242d64107533473
22 changes: 19 additions & 3 deletions src/Components/Notification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import RichText from '@nextcloud/vue-richtext'
import DefaultParameter from './Parameters/DefaultParameter.vue'
import File from './Parameters/File.vue'
import User from './Parameters/User.vue'
import { emit } from '@nextcloud/event-bus'

export default {
name: 'Notification',
Expand Down Expand Up @@ -329,9 +330,24 @@ export default {
})

if (this.link) {
n.onclick = function(event) {
event.preventDefault()
window.location.href = this.link
n.onclick = async function(e) {
const event = {
cancelAction: false,
notification: this.$props,
action: {
url: this.link,
type: 'WEB',
},
}
await emit('notifications:action:execute', event)

if (!event.cancelAction) {
console.debug('Redirecting because of a click onto a notification', this.link)
window.location.href = this.link
}

// Best effort try to bring the tab to the foreground (works at least in Chrome, not in Firefox)
window.focus()
}.bind(this)
}
},
Expand Down