Commit Graph

35 Commits

Author SHA1 Message Date
keyan 56197ce9a4 dark mode shouldn't be cached forever 2023-07-05 09:40:34 -05:00
ekzyis f417092107
Fix CORS in service worker (#342)
* Add crossOrigin to generated <script> elements if CDN is used

* Add CORS headers to darkmode.js

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-07-05 09:36:00 -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 cc6dc8c68b add daily discussion thread permalink 2023-06-19 14:40:24 -05:00
keyan e1f59763ea remove logging 2023-06-01 20:21:54 -05:00
keyan d65763ab27 don't serve stale server side props from pwa 2023-06-01 20:11:29 -05:00
keyan 25b93546ad get commit hash in prod 2023-06-01 16:57:58 -05:00
keyan ce6b055456 go back to old build id gen 2023-06-01 15:31:16 -05:00
keyan 23a9c76e52 fix build id issue 2023-06-01 15:03:13 -05:00
keyan 3de8df5ab5 enhancements for footer version with prod support 2023-06-01 12:57:31 -05:00
ekzyis e97509eea7
Use PWA with display: standalone (#292)
* Use next-pwa

* Use standalone + back button

* Use Notification API

* Use custom service worker

* Use url_handlers

* Add offline page

* Use smaller icon in notification

* Only prompt for notifications if logged in

* small enhancements to standalone pwa

* remove unused back arrow

---------

Co-authored-by: ekzyis <ek@stacker.news>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2023-05-31 17:28:33 -05:00
keyan 8b6829df50 relax CORS on lnurlp (eg nostr browser clients) 2023-01-25 11:43:58 -06:00
keyan 2d012ba7fe allow nip05 for users 2023-01-06 18:53:29 -06:00
keyan 525cab2573 upgrade deps 2022-11-06 11:28:58 -06:00
keyan 79af550168 add guide to footer 2022-10-23 10:43:39 -05:00
keyan 1bcfb787a6 add changelog to footer 2022-10-10 16:58:50 -05:00
keyan 515f997147 link to privacy 2022-10-04 12:19:15 -05:00
keyan 1df733f02b update CORS on static assets 2022-07-10 18:24:59 -05:00
keyan b954186d31 jobs w/o payments yet 2022-02-24 13:05:57 -06:00
keyan 155307127c add sub route 2022-02-24 11:54:25 -06:00
keyan b739ae391e add lightning font 2022-01-21 12:58:21 -06:00
keyan 1baaf6089c add cdn 2022-01-21 12:43:57 -06:00
keyan a9fb5c8fe6 prep for CDN by setting headers 2022-01-21 12:24:03 -06:00
keyan 34a433c273 protect statistics user name and redirect typos 2022-01-19 16:05:58 -06:00
keyan 06b0424b82 mess with cache etc 2021-10-25 14:49:46 -05:00
keyan 50477c1b65 dockerize dev env 2021-10-20 14:57:11 -05:00
keyan eafe474746 WIP lightning addr 2021-10-07 11:37:59 -07:00
keyan 9ed7abde0e do gzip compression in nginx 2021-10-06 20:26:57 -07:00
keyan 61be400365 use app manifest for build id 2021-10-05 13:01:40 -07:00
keyan bc0ec2c609 debug build) 2021-10-05 12:53:53 -07:00
keyan 4a81da6d13 use app version as the build id 2021-10-05 12:37:08 -07:00
keyan 3e70636df2 use app version as the build id 2021-10-05 12:28:22 -07:00
keyan 48146d1757 update with story 2021-09-02 12:49:17 -05:00
keyan 8dea20a594 add faq 2021-07-15 18:06:21 -05:00
keyan 0f6cb029c3 add plausible and proxy it 2021-07-15 15:49:13 -05:00