* Allow founders to transfer territories
* Log territory transfers in new AuditLog table
* Add territory transfer notifications
* Use polymorphic AuditEvent table
* Add setting for territory transfer notifications
* Add push notification
* Rename label from user to stacker
* More space between cancel and confirm button
* Remove AuditEvent table
The audit table is not necessary for territory transfers and only adds complexity and unrelated discussion to this PR.
Thinking about a future-proof schema for territory transfers and how/what to audit at the same time made my head spin.
Some thoughts I had:
1. Maybe using polymorphism for an audit log / audit events is not a good idea
Using polymorphism as is currently used in the code base (user wallets) means that every generic event must map to exactly one specialized event.
Is this a good requirement/assumption? It already didn't work well for naive auditing of territory transfers since we want events to be indexable by user (no array column) so every event needs to point to a single user but a territory transfer involves multiple users.
This made me wonder: Do we even need a table? Maybe the audit log for a user can be implemented using a view? This would also mean no data denormalization.
2. What to audit and how and why?
Most actions are already tracked in some way by necessity: zaps, items, mutes, payments, ...
In that case: what is the benefit of tracking these things individually in a separate table?
Denormalize simply for convenience or performance? Why no view (see previous point)? Use case needs to be more clearly defined before speccing out a schema.
* Fix territory transfer notification id conflict
* Use include instead of two separate queries
* Drop territory transfer setting
* Remove trigger usage
* Prevent transfers to yourself
* 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>
* 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>
* 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>
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>
* 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
* 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>
* 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>