Commit Graph

15 Commits

Author SHA1 Message Date
ekzyis f450a00073 Fix logged title 2024-01-14 21:14:14 +01:00
ekzyis bdf9b1f0fd
Territory post notifications (#745)
* Notify founders of new posts

* Only merge notifications of same territory

* Show territory posts in /notifications

* Don't notify on own posts
2024-01-11 11:27:54 -06:00
ekzyis df1edd5b79
Fix push notification counting on iOS devices (#739)
Co-authored-by: ekzyis <ek@stacker.news>
2024-01-10 09:25:30 -06:00
ekzyis 045ba28c41
Remove logging to browser (#733)
* Don't log to browser console

* Don't log options (too verbose)

---------

Co-authored-by: ekzyis <ek@stacker.news>
2024-01-04 13:53:52 -06:00
ekzyis 562b243111
Fix usage of hardcoded strings for sw message types (#730)
Co-authored-by: ekzyis <ek@stacker.news>
2024-01-03 14:02:01 -06:00
ekzyis 31cef5a7b7
Only close notifications manually on iOS (#729)
* Only close notifications manually on iOS

* Use function instead of hardcoded string

---------

Co-authored-by: ekzyis <ek@stacker.news>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2024-01-03 11:56:29 -06:00
ekzyis ade35b9ea0
Add verbose logging in onPush listener (#724)
* refactor: Use log function in service worker

* Add verbose logging on push listener

* Fix TypeError: Cannot read properties of null (reading 'postMessage')

navigator.serviceWorker.controller is null on forced refreshes:

"""
This property returns null if the request is a force refresh (Shift + refresh) or if there is no active worker.
"""

-- https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller

This means when we unregister a service worker manually (like I do for debugging purposes) and then reload the page, there is no service worker available when this code is run.

Adding a check with a more helpful error message should improve UX.

This error might also happen in other cases where a page refresh should also help.

---------

Co-authored-by: ekzyis <ek@stacker.news>
2024-01-03 11:51:04 -06:00
ekzyis 7f512d6adb
Fix silent push due to missing tag support in Safari on iOS (#719)
* Merge notifications manually without relying on tag

* Use tag as argument

* Fix title and undefined sats in DEPOSIT push notification

* Remove wrong comment

* Fix wrong var used for tag check

* Also immediately display STREAK notifications

* Close all notifications with same tag manually before

* Fix merge of DEPOSIT notifications

* Remove unused tag from reduce argument

* Remove FIXME(iOS) comment

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-12-29 18:04:07 -06:00
keyan 9698679d38 attempt another fix for #411 2023-12-28 14:44:56 -06:00
ekzyis 0b872cbbe7
Only resubscribe on compatible old subscriptions (#616)
This change makes resubscriptions backwards compatible by only running the new resubscribe code if the old push subscription was saved under service worker version 2.

Co-authored-by: ekzyis <ek@stacker.news>
2023-11-08 18:18:41 -06:00
SatsAllDay 522c821c89
Notification badges (#595)
* First pass of implementing Badging API for notifications

* Only show app badge when driven from push notifications

* Display number of unread push notifications instead of just an empty badge

Clear badge via postMessage when notifications page is loaded

* de-dupe some code, update badge counter on each notification click

* remove ids, track open note count instead

* restore optional chaining

* ensure note count doesn't go below 0, and fix event.waitUntil error when clearing badge

* incorporate PR feedback
2023-11-08 18:17:01 -06:00
ekzyis 5dfeb700bc
Resubscribe if service worker lost push subscription (#597)
* Also delete push subscription in IndexedDB

* Fix pushsubscriptionchange function signature

* Send SYNC_SUBSCRIPTION after successful registration

* Resubscribe if service worker lost subscription

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-11-05 15:08:44 -06:00
ekzyis 7040dbfce6
Fix missing merge of FOLLOW push notifications (#596)
* Use consistent lowercase titles

* Fix missing merge of FOLLOW push notifications

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-11-05 15:06:38 -06:00
ekzyis eeaf2d5cf6
Fix FORWARDEDTIP change lost in serviceworker (#582)
Co-authored-by: ekzyis <ek@stacker.news>
2023-10-24 11:27:59 -05:00
ekzyis dd36155b04
Fix duplicate push notifications on item edit if mentioned (#563)
* Refactor service worker event listeners into own file

* Refactor service worker onPush listener

* Only show one MENTION push notification per item

* Update index.js to have newline

---------

Co-authored-by: ekzyis <ek@ekzyis.com>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2023-10-20 19:21:44 -05:00