Merge branch 'main' into mobile/prepare-webviews-2
* main: (26 commits) Add a new Pins section to docs/API.md covering pin/unpin and the pinned cards list response. Align board name start so it doesn't get too big Clean up card/events header layout Sync email to Stripe when user changes email address (#2432) Fix IDOR in webhook activation endpoint (#2431) Add card reactions to API docs and reactions_url to card JSON (#2427) Remove unnecessary claude plan Allow boosts on cards (#2411) Revert "Fix notification click URL by using correct data property" Add migration to remove draft cards from search index Guard search indexing with searchable? check Forbid comments on draft cards prefactor: update search to use published cards Fix notification click URL by using correct data property Wait for service worker to be active before subscribing Fix stuck state when permission granted but no subscription Extract Card::Commentable Include arm64 build in Docker workflow Remove unnecessary `await` in push handler Correctly initialise WebPush connection (#2417) ...
This commit is contained in:
@@ -11,8 +11,7 @@ export default class extends Controller {
|
||||
|
||||
switch(Notification.permission) {
|
||||
case "default":
|
||||
this.subscribeButtonTarget.hidden = false
|
||||
this.explainerTarget.hidden = true
|
||||
this.#showButtonToSubscribe()
|
||||
break
|
||||
case "granted":
|
||||
const registration = await this.#getServiceWorkerRegistration()
|
||||
@@ -20,6 +19,8 @@ export default class extends Controller {
|
||||
|
||||
if (registration && subscription) {
|
||||
this.element.classList.add(this.enabledClass)
|
||||
} else {
|
||||
this.#showButtonToSubscribe()
|
||||
}
|
||||
break
|
||||
}
|
||||
@@ -54,8 +55,9 @@ export default class extends Controller {
|
||||
return navigator.serviceWorker.getRegistration("/service-worker.js", { scope: "/" })
|
||||
}
|
||||
|
||||
#registerServiceWorker() {
|
||||
return navigator.serviceWorker.register("/service-worker.js", { scope: "/" })
|
||||
async #registerServiceWorker() {
|
||||
await navigator.serviceWorker.register("/service-worker.js", { scope: "/" })
|
||||
return navigator.serviceWorker.ready
|
||||
}
|
||||
|
||||
async #subscribe(registration) {
|
||||
@@ -76,6 +78,11 @@ export default class extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
#showButtonToSubscribe() {
|
||||
this.subscribeButtonTarget.hidden = false
|
||||
this.explainerTarget.hidden = true
|
||||
}
|
||||
|
||||
async #requestPermissionAndSubscribe(registration) {
|
||||
const permission = await Notification.requestPermission()
|
||||
if (permission === "granted") this.#subscribe(registration)
|
||||
|
||||
Reference in New Issue
Block a user