Commit Graph

47 Commits

Author SHA1 Message Date
ekzyis 853a389b65 Allow pay per invoice for stackers
The modal which pops up if the stacker does not have enough sats now has two options: "fund wallet" and "pay invoice"
2023-07-30 23:45:07 +02:00
ekzyis fd8510d59f Use payment hash instead of invoice id as proof of payment
Our invoice IDs can be enumerated.
So there is a - even though very rare - chance that an attacker could find a paid invoice which is not used yet and use it for himself.
Random payment hashes prevent this.

Also, since we delete invoices after use, using database IDs as proof of payments are not suitable.
If a user tells us an invoice ID after we deleted it, we can no longer tell if the invoice was paid or not since the LN node only knows about payment hashes but nothing about the database IDs.
2023-07-30 23:45:07 +02:00
ekzyis 74893b09dd Add anon comments and posts (link, discussion, poll) 2023-07-30 23:45:07 +02:00
keyan 6407455def upgrade react-bootstrap 2023-07-24 13:53:53 -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 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
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
ekzyis 5c55afc97c Fix no dupes check after link unshortening 2023-05-21 12:50:14 -05:00
ekzyis 4af445d242 Fix fetched data not shown if last action was title clear
There are two flows when clearing both inputs:

1. First clear title, then clear URL, then enter new URL

In this case, new data will be fetched when the URL is cleared since the title is empty. Due to the fetch with empty variables, the fetched data is essentially reset.
Entering a new URL thus triggers a new fetch (since title is still empty) and the fetched data is shown since it is different compared to the previous render.

2. First clear URL, then clear title, then enter new URL

In this case, new data will not be fetched when the URL is cleared since the title is not empty.
When entering a new URL, new data is fetched but will not be shown since the fetched data was never reset and thus did not change compared to the previous render.

This is fixed by always either a) resetting the fetched data or b) fetching new data if the URL changed.
2023-05-21 12:27:01 -05:00
keyan df1f1a483a require sub selection, allow editting 2023-05-10 19:30:51 -05:00
keyan 1a5d8880dd decapitalize all caps titles 2023-05-06 10:54:04 -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 d6c92fec62 prevent layout shift when loading dupes 2023-04-26 13:02:42 -05:00
ekzyis f2f205dc80 Disable post button for 3 seconds max 2023-04-26 13:02:42 -05:00
ekzyis 259b5b7a36 Don't run dupes query empty 2023-04-26 13:02:42 -05:00
ekzyis 29bee1c740 Show dupes loading 2023-04-26 13:02:42 -05:00
ekzyis d43c7cc222 Disable post button while dupes are loading 2023-04-26 13:02:42 -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 9823969418 unshorten links 2023-01-12 12:05:47 -06:00
keyan 2080cb896d lexical beta test url 2023-01-05 13:24:09 -06: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 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 e9e48d5aae better regex for url validation 2022-03-10 16:00:04 -06: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 2d320513f0 remove extra logging 2021-10-28 17:29:02 -05:00
keyan c80e4d107c dupe alerts on link posts 2021-10-28 15:49:51 -05:00
keyan 4421dd6e6e network-only fetch for link title 2021-10-27 11:03:43 -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 f4c108951d give autofocus to url field in link post 2021-08-24 15:03:02 -05:00
keyan ce0e3dac45 auto-populate link title 2021-08-22 10:25:17 -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