Commit Graph

32 Commits

Author SHA1 Message Date
keyan d0314ab73c shield your eyes; massive, squashed refactor; nextjs/react/react-dom/apollo upgrades 2023-07-21 17:33:11 -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
ekzyis fa32e22cde
Fix double slash (#325)
Co-authored-by: ekzyis <ek@stacker.news>
2023-06-21 13:09:04 -05:00
keyan 342a165ced refine cancel button 2023-06-12 14:39:27 -05:00
ekzyis e243c1c224
Add cancel button for editing all post types + bio (#310)
* Add cancel button when editing any post type

* Add cancel button when editing bio

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-06-12 12:35:28 -05:00
keyan 9d31d56ec0 fix missing advanced options in bounty/discussion form 2023-05-16 13:30:19 -05:00
keyan df1f1a483a require sub selection, allow editting 2023-05-10 19:30:51 -05:00
keyan b406f0c340 avoid db dip for sub 2023-05-05 12:39:57 -05:00
keyan a241d683d8 nostr sub 2023-05-01 15:58:30 -05:00
keyan 4cae1ae230 reuse validation on server 2023-02-08 13:39:53 -06:00
keyan 10ff3fa1c3 delete 2023-01-13 11:52:18 -06:00
keyan ed153b5199 add similar section to posts 2023-01-12 14:30:17 -06:00
keyan d9d426e5c3 add freebies 2022-09-27 16:19:15 -05:00
keyan a5d1d8dc0f user suggestions on forward 2022-08-31 14:09:49 -05:00
keyan 016e357ebd clear inputs 2022-08-30 17:02:45 -05:00
keyan 388c7d0240 full powered editing 2022-08-18 13:15:24 -05:00
keyan ddb4a30c4b spam fees 2022-08-11 15:38:10 -05:00
keyan 08defc561b improved heading and images for markdown 2022-07-13 18:00:48 -05:00
keyan d7210662b3 limit title length to 80 characters 2022-07-13 10:49:55 -05:00
keyan d978ff5ea5 forward tips from posts 2022-04-19 13:32:39 -05:00
keyan 822fa9113a refactor link/dicussion to upserts and reuse more code 2022-04-18 17:10:26 -05:00
keyan 2b594109ea WIP forward 2022-04-18 15:19:07 -05:00
keyan d40b0ae063 fix double posting on slow connections 2022-03-10 12:25:16 -06:00
keyan e42f1d6bb9 WIP save drafts of posts 2022-01-07 12:28:23 -06:00
keyan 9a96879e46 on new post take user to recent 2022-01-07 10:50:41 -06:00
keyan dd97710d71 many small design enhancements 2021-11-12 16:39:52 -06:00
keyan e965b0c17b small ui tweaks 2021-10-29 12:56:31 -05:00
keyan e7787e3e67 WIP bios 2021-09-23 12:42:00 -05:00
keyan e4c1c2f1e1 refine tipping 2021-09-12 11:55:38 -05:00
keyan 650ad03de5 move boost to post creation 2021-09-11 16:52:19 -05:00
keyan 9fce2154f6 reuse formatted countdown component 2021-08-11 15:34:10 -05:00
keyan a48cd33db3 edit posts - links and discussions 2021-08-11 15:13:10 -05:00