Skip to content

Check if service workers are supported before offering subscribing to push notifications

Jano requested to merge service_worker_safeguard into master

What does this MR do?

In this branch, the JavaScript not only checks whether PushNotifications are supported, but also whether service workers are supported by the browser before offering push notifications.

This fixes one (and probably the only) occasion in which the push notifications settings stay empty, mentioned in #831 (closed).

How confident are you it won't break things if deployed?

Very. It's just a null check-

Links to related issues

Originated in discussion of !1452 (merged)

Fixes part of #831 (closed)

How to test!

1

  1. Checkout branch locally
  2. Open a private browsing window (they don't support service workers) in a browser that technically supports push notifications (basically any modern browser)
  3. Login as foodsaver
  4. Go to the settings
  5. See text about push notifications not being supported, like this Screenshot_20200425_133705 Opposed to seeing empty controls like on master, like this fs

2

  1. Checkout branch locally
  2. Open a private browsing window (they don't support service workers) in a browser that technically supports push notifications (basically any modern browser)
  3. Login as foodsaver
  4. Don't see a "subscribe to push notifications" banner on dashboard opposed to seeing one and getting an error if trying to subscribe like on master Screenshot_20200425_134342

Checklist

  • added a test, or explain why one is not needed/possible...
  • no unrelated changes
  • asked someone for a code review
  • joined #foodsharing-beta channel at https://slackin.yunity.org
  • added an entry to CHANGELOG.md (description, merge request link, username(s))
  • Once your MR has been merged, you are responsible to update the #foodsharing-beta Slack channel about what has been changed here. They will test your work in different browsers, roles or other settings
Edited by Jano

Merge request reports