stacker.news/prisma/migrations
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
..
20210427152429_init create reserved usernames 2021-05-21 19:09:11 -05:00
20210507005624_invoices invoiced ... WIP transactions 2021-05-11 10:52:50 -05:00
20210510175729_msats invoiced ... WIP transactions 2021-05-11 10:52:50 -05:00
20210511163249_function transactional wallet management in plpgsql 2021-05-11 15:29:44 -05:00
20210511170231_vote attempts at serializable transactions 2021-05-19 20:09:32 -05:00
20210513002346_withdrawl partial withdrawl 2021-05-12 20:51:37 -05:00
20210513002503_withdrawl_funcs attempts at serializable transactions 2021-05-19 20:09:32 -05:00
20210513191840_enum make withdrawls mostly work 2021-05-13 16:19:51 -05:00
20210521192356_name_trigger force unique user name 2021-05-21 14:34:40 -05:00
20210521234940_reserved_names create reserved usernames 2021-05-21 19:09:11 -05:00
20210524211524_freebies finish mvp 2021-05-24 19:08:56 -05:00
20210601001008_null_names prepare for deployment 2021-06-02 10:23:30 -04:00
20210624171900_checked_notes_at notifications done 2021-06-24 18:56:01 -05:00
20210626191129_lnurl_auth add forgetten lnurl-auth files 2021-06-26 22:18:32 -05:00
20210710130454_withdraw_hash_nounique allow retries of failed withdraw invoice while enforcing uniqueness of pending/confirmed 2021-07-10 09:16:40 -05:00
20210710132315_new_withdraw_funcs allow retries of failed withdraw invoice while enforcing uniqueness of pending/confirmed 2021-07-10 09:16:40 -05:00
20210810195449_fix_item_path_trigger comment edit spagetti 2021-08-10 17:59:06 -05:00
20210818204542_mentions db portion of mentions 2021-08-18 17:20:33 -05:00
20210818220200_mention_unique db portion of mentions 2021-08-18 17:20:33 -05:00
20210819213404_user_withdrawal withdrawl => withdrawal/withdraw 2021-08-19 16:42:21 -05:00
20210819213613_user_withdrawals withdrawl => withdrawal/withdraw 2021-08-19 16:42:21 -05:00
20210819213954_user_withdraw withdrawl => withdrawal/withdraw 2021-08-19 16:42:21 -05:00
20210902174121_story_name update with story 2021-09-02 12:49:17 -05:00
20210902220036_case_insensitive_names case insensitive names 2021-09-02 17:22:00 -05:00
20210908193444_tips fix vote->itemAct migration 2021-09-09 14:04:32 -05:00
20210911215322_tip_default refine tipping 2021-09-12 11:55:38 -05:00
20210914173926_item_boost make post boost transactional 2021-09-14 12:55:59 -05:00
20210921232401_user_bio WIP bios 2021-09-23 12:42:00 -05:00
20210922214428_create_bio WIP bios 2021-09-23 12:42:00 -05:00
20211006144214_created_at_indices add index to created_at columns 2021-10-06 07:43:32 -07:00
20211012203507_invite_modeld invite graphql + basic frontend 2021-10-12 18:49:04 -05:00
20211015180613_invite_func finish up invites 2021-10-15 18:07:51 -05:00
20211025174239_item_act_replace fix boost on freebie post 2021-10-25 12:46:33 -05:00
20211027230800_lnwith lnurl-withdrawal support 2021-10-28 14:59:53 -05:00
20211027231327_lnwith_withid_optional lnurl-withdrawal support 2021-10-28 14:59:53 -05:00
20211104210749_theme add dark mode 2021-11-04 19:07:41 -04:00
20211111202609_item_act_tip_bug fix tipping before upvoting causing boost bug 2021-11-11 14:27:29 -06:00
20211206213650_popovers tip walkthrough 2021-12-09 14:41:09 -06:00
20211213194823_tip_default redo tipping, removing modal, adding walkthrough, setting tipping default to 1 2021-12-13 13:49:34 -06:00
20220104214008_wallet_funcs add job queue 2022-01-05 14:37:34 -06:00
20220106220010_pins support pinned posts + recurring pins 2022-01-07 10:32:31 -06:00
20220107192624_pgcrypto add pgcrypto extension 2022-01-07 13:28:17 -06:00
20220114153043_drop_theme drop theme from users table 2022-01-14 11:42:45 -06:00
20220114153522_add_trust WIP trust 2022-01-14 17:43:12 -06:00
20220119215304_statistics_names protect statistics user name and redirect typos 2022-01-19 16:05:58 -06:00
20220119221313_item_act_var_tip_bug refine tipping experience, removing notion of upvote from UX 2022-01-20 17:04:12 -06:00
20220126155041_search_triggers search index triggers 2022-01-26 11:03:21 -06:00
20220214215140_subs jobs w/o payments yet 2022-02-24 13:05:57 -06:00
20220218193307_sub_desc create worker for auction ranking 2022-02-25 11:34:09 -06:00
20220224203227_item_status create worker for auction ranking 2022-02-25 11:34:09 -06:00
20220224205443_run_auction remove extra migrations, refine jobs 2022-02-28 14:09:21 -06:00
20220301201244_auction_fix fix auction to work as described 2022-03-02 14:55:13 -06:00
20220303170859_exp_auction make jobs expensive, priced based ranking rather than auction 2022-03-03 12:56:02 -06:00
20220307181836_sats_min sats/mo -> sats/min on jobs 2022-03-07 13:30:21 -06:00
20220307201437_job_col add job company and location 2022-03-07 15:50:13 -06:00
20220310191658_more_indexes add more indices to item 2022-03-10 13:17:30 -06:00
20220310192618_a_few_more_indices more indices 2022-03-10 13:26:35 -06:00
20220314162449_last_seen store last time user visited so we can guage retention 2022-03-14 11:43:21 -05:00
20220315171015_item_act_stream record sats spent on auction items 2022-03-16 11:35:51 -05:00
20220316212238_earn earning 2022-03-17 15:13:19 -05:00
20220404191617_stacked denormalize stacked count 2022-04-04 16:54:31 -05:00
20220412190704_item_path_index update ltree extension 2022-11-06 12:48:29 -06:00
20220412203904_default_tip_10 up default tip to 10 2022-04-12 16:09:12 -05:00
20220412205824_path_index_prisma up default tip to 10 2022-04-12 16:09:12 -05:00
20220415193617_exp_comments multiple comments with the same parent are exp in cost 2022-04-17 08:13:52 -05:00
20220418173838_forward WIP forward 2022-04-18 15:19:07 -05:00
20220419162551_fwd_item_act forward tips from posts 2022-04-19 13:32:39 -05:00
20220421195241_note_settings add notification settings 2022-04-21 17:50:02 -05:00
20220508141357_jobs_indicator indicate to user when there are new jobs 2022-05-09 13:01:23 -05:00
20220511171526_upload image uploading backend 2022-05-12 13:44:21 -05:00
20220516144530_profile_photo profile photos 2022-05-16 15:51:22 -05:00
20220517173200_weighted_votes_denorm denormalize ranking metrics 2022-05-17 14:54:12 -05:00
20220517192333_boost_denorm denormalize ranking metrics 2022-05-17 14:54:12 -05:00
20220630170204_upvote_trust improve trust 2022-07-05 14:51:13 -05:00
20220720211644_item_uploads job board enhancements 2022-07-21 17:55:05 -05:00
20220727194641_polls add polls 2022-07-30 08:51:04 -05:00
20220727194920_poll_functions add polls 2022-07-30 08:51:04 -05:00
20220727203003_poll_functions2 add polls 2022-07-30 08:51:04 -05:00
20220806220043_no_free_comments remove free comments 2022-08-06 17:03:57 -05:00
20220810162813_item_spam spam fees 2022-08-11 15:38:10 -05:00
20220810203210_item_spam2 spam fees 2022-08-11 15:38:10 -05:00
20220815195309_edit_funcs full powered editing 2022-08-18 13:15:24 -05:00
20220827143828_positive_ints add integer constraints 2022-08-27 10:48:59 -05:00
20220830183739_create_invoice constrain invoice quantity and amount 2022-08-30 15:33:39 -05:00
20220830213020_hide_invoice_desc optionally hide invoice descriptions 2022-08-30 16:50:47 -05:00
20220830222623_ext_pg_trgm user suggestions on forward 2022-08-31 14:09:49 -05:00
20220831205352_item_and_comment_stats denormalize item sats, comment sats, last comment time, and num comments 2022-09-01 15:28:19 -05:00
20220913010100_fiat_currency Add input for fiat currency in settings 2022-09-13 02:02:55 +02:00
20220913173806_earn_columns improved earning: more detail, longer top tail 2022-09-14 17:01:30 -05:00
20220913173826_earn_function improved earning: more detail, longer top tail 2022-09-14 17:01:30 -05:00
20220920152500_downvotes wild west mode 2022-09-21 14:57:36 -05:00
20220920195257_dont_like_this wild west mode 2022-09-21 14:57:36 -05:00
20220922210703_outlaw presume median downvote on new post 2022-09-22 17:27:27 -05:00
20220923153826_outlaw_float median votes: int -> float 2022-09-23 10:43:57 -05:00
20220926201629_freebies add freebies 2022-09-27 16:19:15 -05:00
20220926204325_item_bio add freebies 2022-09-27 16:19:15 -05:00
20220927214007_reserve_names reserve top level names 2022-09-27 16:43:29 -05:00
20220929183848_job_funcs make jobs great again 2022-09-29 15:42:33 -05:00
20221005192538_auction_update when NOSATS jobs are given 0 bid, make ACTIVE 2022-10-05 15:11:05 -05:00
20221101183505_create_item_freebie improve freebie wrt boost, get off free earlier 2022-11-01 14:32:56 -05:00
20221106181637_item_path_index update ltree extension 2022-11-06 12:48:29 -06:00
20221106184713_item_path_index update ltree extension 2022-11-06 12:48:29 -06:00
20221106203216_item_indices more indices 2022-11-16 10:57:03 -06:00
20221110190205_msats_bigint sats to msats 2022-11-16 10:57:03 -06:00
20221110224543_msats_funcs sats to msats 2022-11-16 10:57:03 -06:00
20221116223041_tipcut let tips affect ranking 2022-11-23 12:12:09 -06:00
20221118202137_tipcut_funcs let tips affect ranking 2022-11-23 12:12:09 -06:00
20221128224540_job_cost improvements to jobs 2022-11-29 11:29:43 -06:00
20221129182008_hide_top_users better user analytics mostly 2022-12-01 15:31:04 -06:00
20221206213226_donate donations to rewards 2022-12-07 18:04:02 -06:00
20221207212053_donate_func donations to rewards 2022-12-07 18:04:02 -06:00
20221208224752_turbo_tipping turbo tipping 2022-12-09 13:25:38 -06:00
20221209201457_donate_func2 fix donation func typo 2022-12-09 14:17:45 -06:00
20221213203919_add_bounty stackernews bounties (#227) 2023-01-26 10:11:55 -06:00
20221213220945_referral referrals 2022-12-19 16:27:52 -06:00
20221214175911_referral_act referrals 2022-12-19 16:27:52 -06:00
20221214201527_referral_funcs referrals 2022-12-19 16:27:52 -06:00
20230106183533_nip05 allow nip05 for users 2023-01-06 18:53:29 -06:00
20230106200624_nostr_relays allow nip05 for users 2023-01-06 18:53:29 -06:00
20230112205950_delete_item delete 2023-01-13 11:52:18 -06:00
20230117185647_slashtags slashtags auth 2023-01-18 12:49:20 -06:00
20230119155952_ots open timestamps 2023-01-22 14:17:50 -06:00
20230119161144_ots_trigger open timestamps 2023-01-22 14:17:50 -06:00
20230123180433_subs_timestamp_fix fix sub submission for timestamping 2023-01-23 12:10:04 -06:00
20230126180748_root_id improve bounty performance 2023-01-26 13:09:57 -06:00
20230126184544_root_id_funcs improve bounty performance 2023-01-26 13:09:57 -06:00
20230126213820_bounty_paid_to denormalize bountyPaidTo 2023-01-26 17:28:10 -06:00
20230126214014_bounty_paid_denorm denormalize bountyPaidTo 2023-01-26 17:28:10 -06:00
20230131163315_streaks streaks 2023-02-01 17:40:49 -06:00
20230131221524_note_cowboy_hat streaks 2023-02-01 17:40:49 -06:00
20230202164411_streak_trigger trigger streak when eligible 2023-02-02 13:47:09 -06:00
20230203193108_streak_user_denorm denormalize user streak to avoid extra dip 2023-02-03 14:40:30 -06:00
20230203193324_streak_update denormalize user streak to avoid extra dip 2023-02-03 14:40:30 -06:00
20230208232335_run_auction_fix stop old expired jobs without sats 2023-02-08 18:00:00 -06:00
20230212001152_bookmarks Implement bookmarking of posts and comments (#235) 2023-02-16 16:23:59 -06:00
20230215152142_desc_on_invoice fix nip57? 2023-02-15 11:20:43 -06:00
20230215153049_desc_invoice_function fix nip57? 2023-02-15 11:20:43 -06:00
20230224163301_item_act_compound_index enhance item related query perf 2023-02-24 10:35:05 -06:00
20230426200416_more_subs nostr sub 2023-05-01 15:58:30 -05:00
20230426222617_poll_subs nostr sub 2023-05-01 15:58:30 -05:00
20230428230115_subscriptions nostr sub 2023-05-01 15:58:30 -05:00
20230501205951_hide_cowboy hide cowboy hat setting 2023-05-01 16:52:02 -05:00
20230501212659_hide_cowboy_rename hide cowboy hat setting 2023-05-01 16:52:02 -05:00
20230506214933_comments_func improve comment performance 2023-05-06 16:51:17 -05:00
20230506224746_comments_with_user avoid extra dip when getting users 2023-05-06 18:18:18 -05:00
20230506232839_higher_tip_default denormalize votes 2023-05-06 18:53:10 -05:00
20230506233136_denorm_upvotes denormalize votes 2023-05-06 18:53:10 -05:00
20230507005859_comments_func_meta I dip you dip one db dip 2023-05-06 20:27:51 -05:00
20230507020956_comments_func_tz fix comment time zone 2023-05-06 21:15:49 -05:00
20230507205613_update_job_priority add user data to comments query when logged out 2023-05-08 15:27:04 -05:00
20230508202036_item_comments_users add user data to comments query when logged out 2023-05-08 15:27:04 -05:00
20230508223532_earn_add add earned sats to items 2023-05-08 18:10:41 -05:00
20230508232041_comment_weight let comments influence ranking 2023-05-09 13:52:35 -05:00
20230509171046_comment_weight_funcs let comments influence ranking 2023-05-09 13:52:35 -05:00
20230509190222_earn_add_retroactive retroactively denormalize earned msats to items/comments 2023-05-09 14:06:05 -05:00
20230518191821_views materialize dashboard in views 2023-05-19 17:38:39 -05:00
20230519022855_user_stats_views use mat views (tm) for historicals (tm) 2023-05-19 17:38:39 -05:00
20230519194614_more_indices use mat views (tm) for historicals (tm) 2023-05-19 17:38:39 -05:00
20230519215240_another_idx use mat views (tm) for historicals (tm) 2023-05-19 17:38:39 -05:00
20230521171442_fix_user_view_post fix post count in stats bug (#288) 2023-05-21 12:18:55 -05:00
20230522022207_users_stats_day_idx recreate user_stats_day index needed for concurrent refresh 2023-05-21 21:23:16 -05:00
20230522122328_hot_ranking_view rank views 2023-05-23 09:21:04 -05:00
20230522153900_schedule_jobs rank views 2023-05-23 09:21:04 -05:00
20230524062059_rank_again improve perf of rank view perf 2023-05-24 02:35:39 -05:00
20230531043651_thread_subscription Add thread subscriptions (#293) 2023-05-31 19:44:06 -05:00
20230601003219_comments_with_me_subscription Add thread subscriptions (#293) 2023-05-31 19:44:06 -05:00
20230612113342_tech_sub Tech sub (#311) 2023-06-12 12:41:22 -05:00
20230612195325_hn_move_to_tech move @hn to tech 2023-06-12 15:10:44 -05:00
20230619022841_push_subscriptions Service worker rework, Web Target Share API & Web Push API (#324) 2023-07-04 14:36:07 -05:00
20230619193610_daily_squatter add daily discussion thread permalink 2023-06-19 14:40:24 -05:00
20230620011238_snl snl live banner 2023-06-20 09:57:06 -05:00
20230620152940_meta_sub ~meta sub 2023-06-20 11:27:41 -05:00
20230620164842_freebies4ever different freebie rules 2023-06-20 12:55:45 -05:00
migration_lock.toml begin working on db schema 2021-03-25 14:29:24 -05:00