Commit Graph

1064 Commits

Author SHA1 Message Date
ekzyis 40ef4f47c8
Remove unused var (#330)
Co-authored-by: ekzyis <ek@stacker.news>
2023-07-04 14:36:38 -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 3d093d45f3 small fireworks changes 2023-07-03 19:04:07 -05:00
keyan b6628eb159 july 4th festivities 2023-07-03 14:46:54 -05:00
Keyan 7cb05f6d96
Update issue templates 2023-06-23 10:39:37 -05:00
ekzyis eac73e7169
Fix double submit (#328)
Co-authored-by: ekzyis <ek@stacker.news>
2023-06-23 10:21:29 -05:00
ekzyis fa32e22cde
Fix double slash (#325)
Co-authored-by: ekzyis <ek@stacker.news>
2023-06-21 13:09:04 -05:00
keyan 431947eeee different freebie rules 2023-06-20 12:55:45 -05:00
keyan 03e0646560 ~meta sub 2023-06-20 11:27:41 -05:00
keyan 747371a4e4 snl live banner 2023-06-20 09:57:06 -05:00
keyan 59ee15b551 new user email copy 2023-06-19 17:42:47 -05:00
keyan cc6dc8c68b add daily discussion thread permalink 2023-06-19 14:40:24 -05:00
keyan 3e4161ae8c tip -> zap 2023-06-19 13:21:55 -05:00
keyan f8724f75e7 add tab shortcut and better resulting selection ranges 2023-06-19 13:07:06 -05:00
ekzyis b427c921d1
Add SimpleX group invite to footer (#320)
Co-authored-by: ekzyis <ek@stacker.news>
2023-06-16 18:04:56 -05:00
keyan 7ad4b0b438 merge remote 2023-06-13 09:20:38 -05:00
keyan 02ec14549f prevent markdown input cursor from moving 2023-06-13 09:19:50 -05:00
ekzyis 3738f08ac2
Use docker volume for db data (#315)
Co-authored-by: ekzyis <ek@stacker.news>
2023-06-12 20:22:10 -05:00
keyan 73bb4a0141 change more post types copy 2023-06-12 19:43:08 -05:00
keyan f0f51438c4 add top posts/comments to subs 2023-06-12 19:40:18 -05:00
keyan 6ed2c87c49 fix ssr and client side rendering difference warnings 2023-06-12 17:59:53 -05:00
keyan ef533d41a6 move markdown related code to proper component 2023-06-12 17:39:20 -05:00
keyan 6a49f37c68 only honor selection range in textarea 2023-06-12 17:21:13 -05:00
keyan 5958875f1e wait for comments to collapse before scrolling 2023-06-12 16:03:32 -05:00
keyan ab3b24a072 refine pwa back button 2023-06-12 15:49:48 -05:00
keyan ed938527fd simply respect notification alert message 2023-06-12 15:37:12 -05:00
keyan b71c595856 move @hn to tech 2023-06-12 15:10:44 -05:00
keyan d78c98e701 improve rss footer 2023-06-12 14:48:35 -05:00
keyan 342a165ced refine cancel button 2023-06-12 14:39:27 -05:00
keyan 79df6b2be2 prevent default on all markdown shortcuts 2023-06-12 13:49:58 -05:00
ekzyis 069417d130
Enable push notifications in settings (#301)
* Enable push notifications in settings

* Fix checkbox still checked after user denied permission

The error was related to me thinking that the value prop does anything. It didn't.
The value of the checkbox is handled by formik.
So the solution was to hook into formik and use the handler which actually changes the value.

* Add double opt-in to /notifications

* Better styling of alert in /notifications

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-06-12 13:03:44 -05:00
ekzyis 876b3e0fdd
Use <atom:author> in RSS feeds (#312)
Co-authored-by: ekzyis <ek@stacker.news>
2023-06-12 12:41:52 -05:00
ekzyis b890215b98
Tech sub (#311)
* Add tech sub

* Fix line break in RSS popover

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-06-12 12:41:22 -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
ekzyis 393d4c7603
Add Markdown formatting hotkeys: CTRL+K, CTRL+I, CTRL+B (#305)
* Fix usage of deprecated event.keyCode

* Add CTRL+K to insert markdown link formatting

* Also add CTRL+B and CTRL+I

* Fix undo not working after using setValue

Undo doesn't work if inputs are changed using javascript code like helpers.setValue().

The solution is to also use `document.execCommand()`.

See https://stackoverflow.com/questions/27027833/is-it-possible-to-edit-a-text-input-with-javascript-and-add-to-the-undo-stack

However, `document.execCommand()` is deprecated but there seems to be no alternative, see:

- https://stackoverflow.com/questions/60581285/execcommand-is-now-obsolete-whats-the-alternative
- https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand#browser_compatibility
- https://github.com/codex-team/editor.js/discussions/2214

And so far, every browser still seems to support it: https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand#browser_compatibility

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-06-12 12:29:50 -05:00
ekzyis 3ee16422f7
Fix code style (#303)
Co-authored-by: ekzyis <ek@stacker.news>
2023-06-05 14:07:29 -05:00
keyan 369bd82a84 make freebie comments visible case by case 2023-06-03 20:01:50 -05:00
keyan 56f08e0144 allow ctrl-click of post button 2023-06-03 17:49:04 -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 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 d4988694c8 make room in header to pwa back button 2023-06-01 19:34:26 -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 56314bac4e fix window navigation error on firefox 2023-06-01 15:29:20 -05:00
keyan 23a9c76e52 fix build id issue 2023-06-01 15:03:13 -05:00
keyan c93ae90578 remove extra note checking condition 2023-06-01 14:54:44 -05:00
keyan c4b96b998f only request notification permissions on the notifications page 2023-06-01 14:41:20 -05:00
keyan f4b81b0ff0 fix notification clicking after refactor 2023-06-01 13:22:39 -05:00