Commit Graph

354 Commits

Author SHA1 Message Date
keyan a17b4d1f1a refine push notification ui and catch promises 2023-07-04 17:19:59 -05:00
ekzyis 388e00dd04
Service worker rework, Web Target Share API & Web Push API (#324)
* npm uninstall next-pwa

next-pwa was last updated in August 2022.
There is also an issue which mentions that next-pwa is abandoned (?): https://github.com/shadowwalker/next-pwa/issues/482

But the main reason for me uninstalling it is that it adds a lot of preconfigured stuff which is not necessary for us.
It even lead to a bug since pages were cached without our knowledge.

So I will go with a different PWA approach. This different approach should do the following:
- make it more transparent what the service worker is doing
- gives us more control to configure the service worker and thus making it easier

* Use workbox-webpack-plugin

Every other plugin (`next-offline`, `next-workbox-webpack-plugin`, `next-with-workbox`, ...) added unnecessary configuration which felt contrary to how PWAs should be built.
(PWAs should progressivly enhance the website in small steps, see https://web.dev/learn/pwa/getting-started/#focus-on-a-feature)

These default configurations even lead to worse UX since they made invalid assumptions about stacker.news:
We _do not_ want to cache our start url and we _do not_ want to cache anything unless explicitly told to.
Almost every page on SN should be fresh for the best UX.

To achieve this, by default, the service worker falls back to the network (as if the service worker wasn't there).

Therefore, this should be the simplest configuration with a valid precache and cache busting support.

In the future, we can try to use prefetching to improve performance of navigation requests.

* Add support for Web Share Target API

See https://developer.chrome.com/articles/web-share-target/

* Use Web Push API for push notifications

I followed this (very good!) guide: https://web.dev/notifications/

* Refactor code related to Web Push

* Send push notification to users on events

* Merge notifications

* Send notification to author of every parent recursively

* Remove unused userId param in savePushSubscription

As it should be, the user id is retrieved from the authenticated user in the backend.

* Resubscribe user if push subscription changed

* Update old subscription if oldEndpoint was given

* Allow users to unsubscribe

* Use LTREE operator instead of recursive query

* Always show checkbox for push notifications

* Justify checkbox to end

* Update title of first push notification

* Fix warning from uncontrolled to controlled

* Add comment about Notification.requestPermission

* Fix timestamp

* Catch error on push subscription toggle

* Wrap function bodies in try/catch

* Use Promise.allSettled

* Filter subscriptions by user notification settings

* Fix user notification filter

* Use skipWaiting

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-07-04 14:36:07 -05:00
keyan 747371a4e4 snl live banner 2023-06-20 09:57:06 -05:00
keyan 3e4161ae8c tip -> zap 2023-06-19 13:21:55 -05:00
keyan f0f51438c4 add top posts/comments to subs 2023-06-12 19:40:18 -05:00
keyan 369bd82a84 make freebie comments visible case by case 2023-06-03 20:01:50 -05:00
keyan d815cae715 add 'stacking since' to profile 2023-06-02 19:55:45 -05:00
keyan 8ac570d403 fixing subscribe and child reply duplicates 2023-06-02 16:48:39 -05:00
keyan c93ae90578 remove extra note checking condition 2023-06-01 14:54:44 -05:00
ekzyis ace2a4df3b
Match any port in dupe check (#297)
Co-authored-by: ekzyis <ek@stacker.news>
2023-05-31 19:49:28 -05:00
ekzyis 36d5478e74
Redirect to /login on /settings 401 (#295)
Co-authored-by: ekzyis <ek@stacker.news>
2023-05-31 19:47:03 -05:00
ekzyis 0c251ca376
Add thread subscriptions (#293)
* Add thread subscriptions

* remove dead code: reply only notifications

* break out thread subscription queries to reduce search space

* one db dip for item lists/threads re:meSubscription

---------

Co-authored-by: ekzyis <ek@stacker.news>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2023-05-31 19:44:06 -05:00
keyan 0de134309c improve perf of rank view perf 2023-05-24 02:35:39 -05:00
keyan 28263bc6c7 rank views 2023-05-23 09:21:04 -05:00
ekzyis a4e6ec0fba Add docs for local LND setup 2023-05-19 18:28:46 -05:00
keyan 31ce8cec93 truncate time to proper interval 2023-05-19 18:22:28 -05:00
keyan 4aee2c745f stats are averages now 2023-05-19 18:12:48 -05:00
keyan f6ab939bcc use mat views (tm) for historicals (tm) 2023-05-19 17:38:39 -05:00
keyan 0a3f5fd201 materialize dashboard in views 2023-05-19 17:38:39 -05:00
keyan 236dcae13b remove user analytics dos vector 2023-05-17 17:56:34 -05:00
keyan df1f1a483a require sub selection, allow editting 2023-05-10 19:30:51 -05:00
keyan 2579a6b51c fix ranking function order operation in wild west mode 2023-05-09 15:07:23 -05:00
keyan 80968d7b35 let comments influence ranking 2023-05-09 13:52:35 -05:00
keyan d948a653c9 add earned sats to items 2023-05-08 18:10:41 -05:00
keyan fbd746b023 fix auction ranking with query layers 2023-05-08 17:32:37 -05:00
keyan 67b815d9d6 preserve ordering in new layered item query 2023-05-08 15:06:42 -05:00
keyan 7b60dc5e9f use getItem meta helper more places 2023-05-07 15:21:58 -05:00
keyan 3c8ea0db22 reduce io blocking ssr 2023-05-07 10:44:57 -05:00
keyan 3465eb7aba handle application uris in invoices 2023-05-07 10:02:59 -05:00
keyan 61d57056ed I dip you dip one db dip 2023-05-06 20:27:51 -05:00
keyan 1c608d42f4 denormalize votes 2023-05-06 18:53:10 -05:00
keyan a97f8229b0 avoid extra dip when getting users 2023-05-06 18:18:18 -05:00
keyan 347a6a54d2 improve comment performance 2023-05-06 16:51:17 -05:00
keyan 3d4d86a40a simplify item queries with subs 2023-05-05 13:06:53 -05:00
keyan b406f0c340 avoid db dip for sub 2023-05-05 12:39:57 -05:00
keyan abd9555792 fix recent comments 2023-05-04 19:20:48 -05:00
keyan b59f277a3b fix job count on analytics 2023-05-04 13:44:00 -05:00
keyan cd9c0086ef fix top users missing return field 2023-05-02 17:02:08 -05:00
keyan 4be5286122 hide cowboy hat setting 2023-05-01 16:52:02 -05:00
keyan a241d683d8 nostr sub 2023-05-01 15:58:30 -05:00
keyan d08d593f69 undo april fools 2023-04-03 09:08:15 -05:00
keyan 9cbc895e29 april fools 2023-04-01 16:59:37 -05:00
keyan e4a3095cb4 give pinned item recent sort by default 2023-03-19 10:43:33 -05:00
keyan 9afbe0abd8 enhance item related query perf 2023-02-24 10:35:05 -06:00
ekzyis 7b838cdeb2
Implement bookmarking of posts and comments (#235) 2023-02-16 16:23:59 -06:00
keyan 30cde2ea38 fix nip57? 2023-02-15 11:20:43 -06:00
ekzyis c941c76292 Mention slashtags auth in README
This also makes SLASHTAGS_SECRET optional.
If none is set, random bytes will be generated. This is useful for local development.
2023-02-10 16:12:18 -06:00
keyan 97f74da0fd top cowboys 2023-02-09 12:41:28 -06:00
keyan a5b2de64d3 remove bolt on posts forwarding to self 2023-02-08 18:11:28 -06:00
keyan 4cae1ae230 reuse validation on server 2023-02-08 13:39:53 -06:00