Repository navigation
feat: open the target when a background push notification is clicked - #3478
Conversation
|
Hey @nickvergessen, Just wanted to let you know that this is a possible blocker for nextcloud/assistant#695 If you have any suggestions, I'd be glad to discuss them in the PR. |
| if (!link) { | ||
| // no target: focus an existing window of this instance if any | ||
| event.waitUntil(self.clients.matchAll({ type: 'window' }).then((clientList) => { | ||
| for (const client of clientList) { | ||
| if (client.url.startsWith(self.location.origin)) { | ||
| return client.focus() | ||
| } | ||
| } | ||
| })) | ||
| return | ||
| } | ||
| event.waitUntil(self.clients.matchAll({ type: 'window' }).then(async (clientList) => { | ||
| for (const client of clientList) { | ||
| // navigate() only works for same-origin targets | ||
| if (client.url.startsWith(self.location.origin) | ||
| && link.startsWith(self.location.origin + '/') | ||
| && 'focus' in client) { | ||
| try { | ||
| await client.focus() | ||
| return await client.navigate(link) | ||
| } catch (e) { | ||
| console.warn('Failed to navigate the focused client, opening a new window', e) | ||
| return self.clients.openWindow(link) | ||
| } | ||
| } | ||
| } | ||
| // cross-origin link or no existing window: openWindow handles both |
There was a problem hiding this comment.
Since this would overwrite pinned tabs or opened tabs meant to be a working-task reminder, I'd prefer to simply always open a new tab?
There was a problem hiding this comment.
LGTM, landed in ca16bd5
Looking forward to the merge
There was a problem hiding this comment.
Related, but in another repo: Talk is intercepting notifications when app is open, and switching you to another chat. Would you want it also to open a new tab?
(it needs to be fixed anyway, so rfc are welcome)
e900191 to
ca16bd5
Compare
Fixes nextcloud#3477 Assisted-by: opencode:glm-5.3 Signed-off-by: WSHAPER <42714629+WSHAPER@users.noreply.github.com>
f153577 to
fc1dc67
Compare
|
/backport to stable35 |
Fixes #3477
Recon (fully) and implementation (partially) assisted-by: opencode:glm-5.3