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 |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
|
/backport to stable34 |
Fixes #3477
Recon (fully) and implementation (partially) assisted-by: opencode:glm-5.3