Commit Graph

128 Commits

Author SHA1 Message Date
ekzyis 01984c0b43
Add wallet limit banner (#699)
* Colorize balance if over soft limit

* Remove default banner export

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-12-21 17:31:16 -06:00
keyan 5496fe82e9 fix select width on mobile 2023-12-06 13:19:39 -06:00
keyan 10203f565c territories 2023-12-04 21:34:06 -06:00
ekzyis 32403d0c29
Unsubscribe on signout (#653)
Co-authored-by: ekzyis <ek@stacker.news>
2023-11-25 14:29:42 -06:00
keyan af59e3ef54 merge non-normalized user subtypes fixing #645 2023-11-20 09:05:02 -06:00
SatsAllDay 522c821c89
Notification badges (#595)
* First pass of implementing Badging API for notifications

* Only show app badge when driven from push notifications

* Display number of unread push notifications instead of just an empty badge

Clear badge via postMessage when notifications page is loaded

* de-dupe some code, update badge counter on each notification click

* remove ids, track open note count instead

* restore optional chaining

* ensure note count doesn't go below 0, and fix event.waitUntil error when clearing badge

* incorporate PR feedback
2023-11-08 18:17:01 -06:00
keyan 8bc3f5b384 Revert "halloween animation"
This reverts commit e939026295.
2023-11-01 11:57:55 -05:00
keyan e939026295 halloween animation 2023-10-29 16:50:03 -05:00
keyan 41cb6ac3d8 continue notification polling even if found 2023-10-26 11:53:27 -05:00
keyan 3929593d90 don't poll for notifications if we already know 2023-10-22 16:26:52 -05:00
keyan 1ee3d6aa0a small bug fixes 2023-10-01 19:29:07 -05:00
keyan 523b6674b8 make sub changing more intuitive 2023-09-29 14:20:07 -05:00
keyan 4b543ae733 prevent wallet balance overflow 2023-09-12 20:21:59 -05:00
keyan 490edd6833 prevent horizontal layout shift when balance is hidden 2023-09-12 14:50:06 -05:00
ekzyis 6df654b208
Hide wallet balance (#481)
* Hide wallet balance on long press

* Use setting to hide wallet balance

* Fix layout shift on hover

* Fix SSR warning about useLayoutEffect

See https://reactjs.org/link/uselayouteffect-ssr

* Also hide balance in wallet

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-09-12 12:19:26 -05:00
rleed 45bad1219e
Fix link to profile matching current URL, not profile (#395)
* break out profile menu and remove top-level href

* group the bio hint with the menu

* rebase/merge

---------

Co-authored-by: rleed <rleed1@pm.me>
2023-08-15 12:54:24 -05:00
ekzyis b9461b7eb3
Allow zapping, posting and commenting without funds or an account (#336)
* Add anon zaps

* Add anon comments and posts (link, discussion, poll)

* 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.

* 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"

* Fix onSuccess called twice

For some reason, when calling `showModal`, `useMemo` in modal.js and the code for the modal component (here: <Invoice>) is called twice.

This leads to the `onSuccess` callback being called twice and one failing since the first one deletes the invoice.

* Keep invoice modal open if focus is lost

* Skip anon user during trust calculation

* Add error handling

* Skip 'invoice not found' errors

* Remove duplicate insufficient funds handling

* Fix insufficient funds error detection

* Fix invoice amount for comments

* Allow pay per invoice for bounty and job posts

* Also strike on payment after short press

* Fix unexpected token 'export'

* Fix eslint

* Remove unused id param

* Fix comment copy-paste error

* Rename to useInvoiceable

* Fix unexpected token 'export'

* Fix onConfirmation called at every render

* Add invoice HMAC

This prevents entities which know the invoice hash (like all LN nodes on the payment path) from using the invoice hash on SN.

Only the user which created the invoice knows the HMAC and thus can use the invoice hash.

* make anon posting less hidden, add anon info button explainer

* Fix anon users can't zap other anon users

* Always show repeat and contacts on action error

* Keep track of modal stack

* give anon an icon

* add generic date pivot helper

* make anon user's invoices expire in 5 minutes

* fix forgotten find and replace

* use datePivot more places

* add sat amounts to invoices

* reduce anon invoice expiration to 3 minutes

* don't abbreviate

* Fix [object Object] as error message

Any errors thrown here are already objects of shape { message: string }

* Fix empty invoice creation attempts

I stumbled across this while checking if anons can edit their items.

I monkey patched the code to make it possible (so they can see the 'edit' button) and tried to edit an item but I got this error:

  Variable "$amount" of required type "Int!" was not provided.

I fixed this even though this function should never be called without an amount anyway. It will return a sane error in that case now.

* anon func mods, e.g. inv limits

* anon tips should be denormalized

* remove redundant meTotalSats

* correct overlay zap text for anon

* exclude anon from trust graph before algo runs

* remove balance limit on anon

* give anon a bio and remove cowboy hat/top stackers;

* make anon hat appear on profile

* concat hash and hmac and call it a token

* Fix localStorage cleared because error were swallowed

* fix qr layout shift

* restyle fund error modal

* Catch invoice errors in fund error modal

* invoice check backoff

* anon info typo

* make invoice expiration times have saner defaults

* add comma to anon info

* use builtin copy input label

---------

Co-authored-by: ekzyis <ek@stacker.news>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2023-08-11 18:50:57 -05:00
keyan b9fdbde520 fix back button render jitter 2023-08-05 12:56:03 -05:00
keyan e1c51075a2 fix conditional nextFetchPolicy overriding cache-only on SSR and suppress time hydration warnings 2023-07-31 14:54:30 -05:00
keyan 5232b59625 upgrade to next-auth 4 (bonus: improve error pages) 2023-07-29 14:38:20 -05:00
keyan 98552c853c fix back button behavior on select navigation 2023-07-25 15:29:45 -05:00
keyan 4bfd021342 enhance styling 2023-07-25 13:32:48 -05:00
keyan ab2046ab0b fix issues with new linting 2023-07-25 09:14:45 -05: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
keyan 09d7e960cc back to lightning animation 2023-07-05 09:47:44 -05:00
keyan 3068252adf merge github master 2023-07-04 15:35:04 -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 b6628eb159 july 4th festivities 2023-07-03 14:46:54 -05:00
keyan 03e0646560 ~meta sub 2023-06-20 11:27:41 -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 ab3b24a072 refine pwa back button 2023-06-12 15:49:48 -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
keyan 56f08e0144 allow ctrl-click of post button 2023-06-03 17:49:04 -05:00
keyan d4988694c8 make room in header to pwa back button 2023-06-01 19:34:26 -05:00
keyan 56314bac4e fix window navigation error on firefox 2023-06-01 15:29:20 -05:00
keyan c4b96b998f only request notification permissions on the notifications page 2023-06-01 14:41:20 -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 236ee552c6 navbar fixes 2023-05-02 19:22:38 -05:00
keyan 4e817a232d sub related enchancements 2023-05-02 11:55:10 -05:00
keyan 4be5286122 hide cowboy hat setting 2023-05-01 16:52:02 -05:00
keyan a241d683d8 nostr sub 2023-05-01 15:58:30 -05:00
ekzyis 7b838cdeb2
Implement bookmarking of posts and comments (#235) 2023-02-16 16:23:59 -06:00
keyan c1080ec4d7 fixes for top 2023-02-03 13:10:18 -06:00
keyan 072e60c954 streaks 2023-02-01 17:40:49 -06:00
keyan c2685a659e sign up buttons 2023-01-09 18:33:44 -06:00
keyan 7a4a24c6df make notification icon change on hover 2023-01-05 19:15:48 -06:00