Commit Graph

51 Commits

Author SHA1 Message Date
SatsAllDay e6ee7f73c4
Make the web manifest dynamic to incorporate preferred color scheme (#398)
Remove the static manifest file and serve it via an API route instead.

Change the background color of the PWA depending on the client hint provided data
2023-08-15 12:58:27 -05:00
keyan 0fb1bf7095 fix git dubious ownership error in dev docker setup 2023-08-09 10:25:34 -05:00
keyan 7967891e99 validate service worker on every request 2023-08-07 16:36:02 -05:00
keyan 3333cc86a2 inline dark mode script 2023-08-07 12:06:58 -05:00
keyan aea8948c45 dark-mode needs to block block 2023-08-04 20:45:12 -05:00
keyan 8d8e2859dd fix dark mode 2023-08-04 19:21:51 -05:00
keyan b1b8f9de56 implement our own nprogress bar 2023-08-01 21:06:15 -05:00
keyan 738bd052f1 cache lightning font encodings forever 2023-07-29 15:15:58 -05:00
keyan de089aa429 service worker enhancements 2023-07-29 14:33:19 -05:00
keyan 688d67a0d6 improve service worker asset precaching and offline page 2023-07-28 10:57:12 -05:00
keyan b468b71e09 disable service worker in dev 2023-07-27 12:45:18 -05:00
keyan 59f7b6ff26 Revert "Revert "shield your eyes; massive, squashed refactor; nextjs/react/react-dom/apollo upgrades""
This reverts commit 18910fa2ed.
2023-07-23 10:08:43 -05:00
keyan 441ec62476 formatting 2023-07-23 09:17:45 -05:00
keyan 18910fa2ed Revert "shield your eyes; massive, squashed refactor; nextjs/react/react-dom/apollo upgrades"
This reverts commit d0314ab73c.
2023-07-23 09:16:12 -05:00
keyan d0314ab73c shield your eyes; massive, squashed refactor; nextjs/react/react-dom/apollo upgrades 2023-07-21 17:33:11 -05:00
Will O'Beirne 9b57bbcda3
add cors headers to /api/lnwith route (#359) 2023-07-19 16:09:03 -05:00
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