Commit Graph

1095 Commits

Author SHA1 Message Date
Keyan 3730b89667
Merge pull request #972 from benalleng/issue923
Allow links to be fit to their content on the homepage
2024-03-26 11:00:56 -05:00
benalleng dc87594d92 feat: add max-width fit-content 2024-03-26 09:58:48 -04:00
ekzyis 922d2394fd Remove unnecessary withdrawl field 2024-03-26 02:10:46 +01:00
ekzyis 3388f818cf Add withdrawal notifications 2024-03-26 00:50:48 +01:00
Keyan 3a00695041
Merge pull request #965 from stackernews/zap-undo-threshold
Use thresholds to trigger zap undos
2024-03-25 17:34:10 -05:00
Keyan e60f1b80d3
Merge pull request #962 from stackernews/more-zap-undo-fixes
More zap undo fixes II
2024-03-25 17:32:30 -05:00
Keyan 59b0027ad0
Merge pull request #970 from AustinKelsay/bugfix-crosspost-link-context
Add context field to crossposted link if present
2024-03-25 17:25:22 -05:00
austinkelsay a9506c4532 Add context field to crossposted link if present 2024-03-25 17:16:45 -05:00
Satoshi Nakamoto 263d0cc425 remove duplicative styles 2024-03-25 15:35:32 -04:00
Satoshi Nakamoto 32bc483e48 chart skeletons 2024-03-25 15:35:32 -04:00
ekzyis c2aef34ba2 Add threshold for zap undos 2024-03-25 20:34:28 +01:00
ekzyis 42d7a31584 Fix custom zap modal closed after zap undo 2024-03-25 20:32:23 +01:00
ekzyis 0193ac97fe Fix toast progress bar jump due to end flow hack
If an underlying toast finished, an empty toast that automatically immediately hides was dispatched to end the flow ("end flow hack").

If this empty toast had the same tag, the code marked the top toast as hidden even though it was not hidden.

This meant that during render, the animation-delay for the top toast (which was already rendered) was added again, leading to a progress bar jump.

This is fixed by no longer using this "end flow hack" where a toast is dispatched but a dedicated function to end flows.
2024-03-25 20:32:23 +01:00
ekzyis 17071fa615 Add missing tag to custom zap toasts 2024-03-25 20:32:23 +01:00
keyan e8f9a186c6 fix image url construction 2024-03-20 14:18:11 -05:00
ekzyis d237861ff5
Use module path aliases (#938)
* Use module path aliases

* fix broken refactor

* path mapping for svgs, style, and remaining places (bonus: lose babel dep)

---------

Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2024-03-19 19:37:31 -05:00
ekzyis 687d71f246
Purchase archived territories (#897)
* Handle archived territories in territory form

* Use dedicated mutation

* Add sanity check for eternal territories

* Fix fields and cost ignored

* Remove no longer needed manual validation in upsertSub

* Remove founder check

* Always check if sub is archived

Using { abortEarly: false } now since previously, if no description was not given, we wouldn't detect if the sub was archived since validation would abort on empty descriptions.

Only on submission all fields would get validated but since we ignore archived errors during submission, the user would never see that the sub is archived before submission
+ the wrong mutation would run if archived is not already true before submission.

Hence, we need to validate all fields always.

There is currently still a bug where the validation does not immediately run but maybe this can be fixed by simply using validateImmediately on the Formik component.

* Fix archived warning not shown after first render

* Only create transfers if owner actually changes

* Reuse helper functions in lib/territory.js

* Rename var to editing

* Use onChange instead of validation override

* Run same validation on server for unarchiving

* Fix 'territory archived' shown during edits

* Use && instead of ternary operator for conditional query

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2024-03-19 17:23:59 -05:00
Keyan 18d126c610
Merge pull request #929 from stackernews/referral-link-privacy-setting
Add setting for no referral links on copy
2024-03-17 12:55:33 -05:00
ekzyis 5b15fd88a9 Fix ToC due to repeated slug calls 2024-03-17 18:24:39 +01:00
ekzyis 2ba4063645 Add setting for no referral links on copy 2024-03-17 16:23:03 +01:00
ekzyis 687012d1a0
API Keys (#915)
* Generate API key in settings

* Check x-api-key for GraphQL API requests

* Don't fallback to cookie if x-api-key header was provided

* Select all session fields

* Fix error if API key not found

* Fix style in settings via form-label className

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2024-03-14 15:32:34 -05:00
ekzyis 501885cfa0
Ignore if sub belongs to user during existence check (#904)
* Ignore if sub belongs to user during existence check

* Remove code no longer needed

* Fix territory edit

Territory edits were broken because validation failed for existing territories and if you edit an territory, it obviously already exists.

This commit fixes this by ignoring the territory that we're currently editing.

* Fix existence check using stale cache

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2024-03-14 11:17:53 -05:00
ekzyis c8e65d5a23
Don't hide self in top even if hidden (#905)
* Don't hide self in top even if hidden

* Also don't hide self in top cowboys

* only use anon icon for anon stuff

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2024-03-13 19:26:59 -05:00
ekzyis f94de0f3ac
Fix zap shadow on hover (#906) 2024-03-13 11:48:16 -05:00
Keyan 23ee62fb21
add sndev shell script and enhance docker compose local dev
* add hot reloading worker:dev script

* refine docker config

* sndev bash script and docker reliability stuff

* make posix shell

* restart: always -> unless-stopped

* proper check for postgres health

* add db seed to sndev

* refinements after fresh builds

* begin adding regtest network

* add changes to .env.sample

* reorganize docker and add static certs/macroon to lnd

* copy wallet and macaroon dbs for deterministic wallets/macaroons

* fix perms of shared directories

* allow debian useradd with duplicate id

* add auto-mining

* make bitcoin health check dependent on blockheight

* open channel between ln nodes

* improve channel opens

* add sndev payinvoice

* add sndev withdraw

* ascii art

* add sndev status

* sndev passthrough to docker and containers

* add sndev psql command

* remove script logging

* small script cleanup

* smaller db seed

* pin opensearch version

Co-authored-by: ekzyis <ek@stacker.news>

* pin opensearch dashboard

Co-authored-by: ekzyis <ek@stacker.news>

* add sndev prisma

* add help for all commands

* set -e

* s3 and image proxy with broken name resolution

* finally fully working image uploads

* use a better diff algo

---------

Co-authored-by: ekzyis <ek@stacker.news>
2024-03-13 09:04:09 -05:00
ekzyis 179a539d4d
Parse numeric strings as numbers (#902)
* Parse numeric strings as numbers

* Additionally check for type of field value
2024-03-06 19:45:00 -06:00
keyan b38a5e653c make image aspect ratio a fraction 2024-03-06 15:15:11 -06:00
keyan 6a6f4a88aa refine bounty icon margin for wrapping in comments 2024-03-06 14:20:03 -06:00
JP Melanson ecf859ee4c
Change poll icon color when active (#680) (#898) 2024-03-06 14:02:48 -06:00
Keyan 2fc1ef44dd
Fix image rerender jitter and layout shift (#896)
* fix image jitter and layout shift

* prevent unecessary context rerenders
2024-03-06 13:53:46 -06:00
ekzyis 8d49c034c6
Fix alignment of info icon (#895) 2024-03-05 16:27:29 -06:00
ekzyis b379e7467f
Territory transfers (#878)
* Allow founders to transfer territories

* Log territory transfers in new AuditLog table

* Add territory transfer notifications

* Use polymorphic AuditEvent table

* Add setting for territory transfer notifications

* Add push notification

* Rename label from user to stacker

* More space between cancel and confirm button

* Remove AuditEvent table

The audit table is not necessary for territory transfers and only adds complexity and unrelated discussion to this PR.

Thinking about a future-proof schema for territory transfers and how/what to audit at the same time made my head spin.

Some thoughts I had:

1. Maybe using polymorphism for an audit log / audit events is not a good idea

Using polymorphism as is currently used in the code base (user wallets) means that every generic event must map to exactly one specialized event.

Is this a good requirement/assumption? It already didn't work well for naive auditing of territory transfers since we want events to be indexable by user (no array column) so every event needs to point to a single user but a territory transfer involves multiple users.

This made me wonder: Do we even need a table? Maybe the audit log for a user can be implemented using a view? This would also mean no data denormalization.

2. What to audit and how and why?

Most actions are already tracked in some way by necessity: zaps, items, mutes, payments, ...

In that case: what is the benefit of tracking these things individually in a separate table?

Denormalize simply for convenience or performance? Why no view (see previous point)? Use case needs to be more clearly defined before speccing out a schema.

* Fix territory transfer notification id conflict

* Use include instead of two separate queries

* Drop territory transfer setting

* Remove trigger usage

* Prevent transfers to yourself
2024-03-05 13:56:02 -06:00
keyan b5de515f5e render outlawed images and links as text 2024-03-04 19:29:50 -06:00
keyan b16234630b better link rel attr handling 2024-03-04 19:20:14 -06:00
keyan 0a0bfbbb37 replace welcome banner with msm banner 2024-03-04 16:51:36 -06:00
keyan fd7e3b04f9 make tabindex camel cased 2024-03-04 15:38:56 -06:00
JP Melanson fb1281dfd2
Trigger image upload from keyboard (#891) (#893)
* Adding tabindex to ImageUpload div wrapper in order to make it selectable
* Adding keyboard event handler to listen to Enter key stroke and trigger file upload selection

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2024-03-01 18:42:47 -06:00
keyan aa7c233177 fix bolt color hover on mobile 2024-03-01 18:32:40 -06:00
Keyan 0b0e36e3cb
Monthly rewards (#890)
* show placeholder for hidden stackers in top

* top rewardability views

* make territory revenue idependent job

* monthly rewards and leaderboard on rewards pages

* fix earn reschedule

* add query for rewards leaderboard

* reduce likelihood of rewards racing with views

* fix earn and refine values views
2024-03-01 10:28:55 -06:00
ekzyis 89de8a9907
Fix out of order undos for turbo zaps (#883)
Turbo zaps had different toast bodies so they weren't merged together. This gave stackers the option to undo these zaps out of order.

When zaps are undone out of order, the client cache can get in a bad state. Using the item id as a tag fixes that such that zaps for the same item will always get merged together.

This can be seen as a workaround for hacky zap undo code but I think it's also better UX so maybe we should do this anyway.
2024-02-26 18:10:43 -06:00
ekzyis bbdd969394
Fix missing progress bar for custom zaps (#882) 2024-02-26 18:09:29 -06:00
ekzyis 38f2aa309d
Fix bolt hover ignores turbozaps (#881)
* Fix bolt hover color ignores turbo zaps

* Refactor next tip code into own function
2024-02-26 18:09:09 -06:00
ekzyis 9cb657ab9a
Fix territory context menu visible for anon (#877) 2024-02-25 10:21:10 -06:00
ekzyis 8cd147f67f
Insert image at cursor position (#874) 2024-02-25 10:18:07 -06:00
ekzyis a067a9fcf1
Use progress bar for pending payments (#873)
The progress bar indicates when the invoice will expire.

This works by passing in a timeout to the withToastFlow wrapper.

If timeout is set, progressBar option will be true for the toast and delay will be set to the timeout.

If progressBar is set, the progress bar will use the delay for its duration.
2024-02-24 14:33:08 -06:00
ekzyis 817234a7fa
More zap undo fixes (#872)
* Don't throw error if invoice attached

* Only show progress bar for undo toasts

* Update zap undo info in settings

* Skip zap undo toast flow for external payments
2024-02-24 11:38:40 -06:00
ekzyis d987069fae
Fix toast progress bar desync (#871)
* Fix toast progress bar desync

If a toast gets rendered again with the same animation-delay, the animation-delay seems to get added.

This commit fixes that by ensuring that animation-delay is only set if the toast was not rendered before.

* Fix comment
2024-02-23 09:14:51 -06:00
ekzyis fa4f09ddca
Territory notifications for everyone (#870)
* Territory notifications

* Migrate old setting to new table

* Auto subscribe founders to their territories on creation

* Fix (un)subscribe not shown to founder

* Rename to toggleSubSubscription

* Fix inconsistency between toggleSubSubscription and toggleMuteSub

* Add dedicated button in header for following territories

* Don't drop noteTerritoryPosts column

* Fix db dip in Sub.meSubscription resolver

* Move territory subscribe to new territory context menu

* Decrease space between share icon and mute button

* Fix eslint
2024-02-23 09:12:49 -06:00
mzivil b0bf7add34
Show founded territories on profile (#868)
* add nterritories field to User

* add userSubs query

* show territories tab on user profiles

hide the tab if user has 0 territories, except when the
viewer navigated directly to the user's territories page

* add USER_WITH_SUBS query for user territories page

* add user territories page
2024-02-21 19:55:48 -06:00
ekzyis 6f8b6c36d8
Remove console.log (#869) 2024-02-21 19:34:51 -06:00
Austin Kelsay 565e939245
Nostr crossposting all item types (#779)
* crosspost-item

* crosspost old items, update with nEventId

* Updating noteId encoding, cleaning up a little

* Fixing item-info condition, cleaning up

* Linting

* Add createdAt variable back

* Change instances of eventId to noteId

* Adding upsertNoteId mutation

* Cleaning up updateItem, using toasts to communivate success/failure in crosspost-item

* Linting

* Move crosspost to share button, make sure only OP can crosspost

* Lint

* Simplify conditions

* user might have no nostr extension installed

Co-authored-by: ekzyis <27162016+ekzyis@users.noreply.github.com>

* change upsertNoteId to updateNoteID for resolver and mutations, change isOp to mine, remove unused noteId params

* Basic setup for crossposting poll / link items

* post rebase fixes and Bounty and job crossposts

* Job crossposting working

* adding back accidentally removed import

* Lint / rebase

* Outsource as much crossposting logic from discussion-form into use-crossposter as possible

* Fix incorrect property for user relays, fix itemId param in updateNoteId

* Fix toast messages / error cases in use-crossposter

* Update item forms to for updated use-crossposter hook

* CrosspostDropdownItem in share updated to accomodate use-crossposter update

* Encode paramaterized replacable event id's in naddress format with nostr-tools, bounty to follw nip-99 spec

* Increase timeout on relay connection / cleaning up

* No longer crossposting job

* Add blastr, fix crosspost button in item-info for polls/discussions, finish removing job crosspostr code

* Fix toaster error, create reusable crossposterror function to surface toaster

* Cleaning up / comments / linting

* Update copy

* Simplify CrosspostdropdownItem, keep replies from being crossposted

* Moved query for missing item fields when crossposting to use-crossposter hook

* Remove unneeded param in CrosspostDropdownItem, lint

* Small fixes post rebase

* Remove unused import

* fix nostr-tools version, fix package-lock.json

* Update components/item-info.js

Co-authored-by: ekzyis <ek@stacker.news>

* Remove unused param, determine poll item type from pollCost field, add mutiny strfry relay to defaults

* Update toaster implementations, use no-cache for item query, restructure crosspostItem to use await with try catch

* crosspost info modal that lives under adv-post-form now has dynamic crossposting info

* Move determineItemType into handleEventCreation, mover item/event handing outside of do ... while loop

* Lint

* Reconcile skip method with onCancel function in toaster

* Handle failedRelays being undefined

* determine item type from router.query.type if available otherwise use item fields

* Initiliaze failerRelays as undefined but handle error explicitly

* Lint

* Fix crosspost default value for link, poll, bounty forms

---------

Co-authored-by: ekzyis <27162016+ekzyis@users.noreply.github.com>
Co-authored-by: ekzyis <ek@stacker.news>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2024-02-21 19:18:36 -06:00
ekzyis c57fcd6518
Allow zap undo's for short period of time (#857)
* Cancel zaps

* Hide zap error toast

* Immediately throw error about insufficient funds

* Optimistic UX

* Also hide success zap toast

* Show undo instead of cancel

* Include sat amount in toast

* Fix undo toasts removed on navigation

* Add setting for zap undos

* Add undo to custom zaps

* Use WithUndos suffix

* Fix toast flow transition

* Fix setting not respected

* Skip undo flow if funds insufficient

* Remove brackets around undo

* Fix insufficient funds detection

* Fix downzap undo

* Add progress bar to toasts

* Use 'button' instead of 'notification' in zap undo info

* Remove console.log

* Fix toast progress bar restarts

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2024-02-21 18:48:42 -06:00
mzivil 46a0af19eb
Make poll expiration configurable (#860)
* add poll expires at column to Item table

* update upsertPoll mutation for pollExpiresAt param

* use pollExpiresAt to show time left for poll

* correctly pluralize days for timeLeft

* correctly update pollExpiresAt when item is updated to remove poll expiration

* add DateTimePicker and DateTimeInput components to select datetimes

* update pollExpiresAt to be nullable and more than 1 day in the future

* hide time left text if poll has no expiration

* initialize pollExpiresAt with current value or default of 25 hours in the future

we add a one hour time buffer so that the user doesn't get a validation error
for pollExpiresAt if they post their poll within an hour from creation. there's
still a chance they'll hit the validation error but they should see the error
message toast

* add DateTimeInput into the options part of the poll form

add right padding to make room for the "clear" button.

allow field to be cleared (i.e. null pollExpiresAt) to allow
non-ending polls.

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2024-02-21 12:18:43 -06:00
ekzyis 843471e5dc
Fill bolts on hover with next zap color (#867) 2024-02-20 17:46:27 -06:00
ekzyis 5de014cba8
Toast flows (#856)
* Use toast flows

"Toast flows" are a group of toasts that should be shown after each other.

Before this commit, they were implemented by manually removing previous toasts in the same flow.

Now a flowId can be passed and ToastProvider will make sure that there always only exists one toast with the same flowId.

This is different to toast tags since tags don't replace toasts with the same tag, they only are shown "above" them.

* Create wrapper for toast flows
2024-02-19 19:03:30 -06:00
ekzyis a7018e25c6
Refactor removeToast (#854) 2024-02-18 13:33:32 -06:00
benthecarman 2d5b1f090d
Handle space separated NWC info event (#855) 2024-02-18 13:29:53 -06:00
ekzyis 6e6c355a3f
Add tests for internal linking (#808)
* Add tests for internal linking

* Add workflow for unit tests

* Use jest
2024-02-17 15:53:36 -06:00
ekzyis 81ab960d92
Fix NWC support detection (#845)
* Fix NWC support detection

* Fix missing toast if support for pay_invoice not detected
2024-02-17 10:30:13 -06:00
keyan 7065008f5d remove overspecified condition 2024-02-16 13:26:15 -06:00
keyan 0d549abff9 fix erronous reference to me in user profile 2024-02-16 13:15:00 -06:00
ekzyis 03b1b173ad
Rename HODL to JIT in frontend comments (#843) 2024-02-16 12:27:15 -06:00
ekzyis 3d1bcd38c6
Fix onSubmit not ignoring payment cancels from WebLN payments (#842) 2024-02-16 12:26:43 -06:00
ekzyis 5c56267aaa
Changed my nym to ek (#844) 2024-02-16 12:25:43 -06:00
Keyan 798fab097d
Make territory billing period changeable (#840)
* allow updates to territory billing

* simplify prorating

* handle updates during grace period and rehydrating archive
2024-02-16 12:25:12 -06:00
ekzyis cfd762a5b6
Fix toast autohide (#839) 2024-02-15 16:49:54 -06:00
ekzyis afe096e516
Fix QR code interaction with WebLN provider (#834)
* Fix passing of bolt11 for QR payments

* Fix missing provider check

* Only cancel invoice if hash and hmac were given

* Fix duplicate toast on error

* Fix relay might not be set yet when sendPayment is called
2024-02-15 11:20:15 -06:00
ekzyis 1444ff476e
Validate pubkey, relay URL and secret of NWC URL (#810)
* Validate pubkey, relay URL and secret of NWC URL

* Fix NWC secret regexp

* Use sequential validation in Yup schema

* Add note about possible mismatch between hostnames and pubkeys

* Remove unused param
2024-02-14 15:09:13 -06:00
keyan bbbd5060d0 add numbering to top stacker and territories 2024-02-14 15:06:42 -06:00
mzivil f59ee5df17
Add ranked territories to 'top' page (#828)
* add subViewGroup function to create view to read sub stats from

* add topSubs resolver to graphql query

* add TOP_SUBS query fragment

* add SUB_SORTS for top territory sorting

* add custom cache policy for topSubs

* add territories to top header select

* add top territories page

* add db views for sub stats

* configure sub_stats views to refresh by worker

* filter rows with empty subName

* update msats_spent calculation to include all ItemAct in sub

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2024-02-14 14:27:00 -06:00
Alex Lewin b3498fe277
Add Opt-in to Display Linked Accounts in Profile (#826)
* Add display linked accounts to settings

* Apply suggestions from code review

Co-authored-by: ekzyis <ek@stacker.news>

* small styling enhancements

---------

Co-authored-by: ekzyis <ek@stacker.news>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2024-02-14 13:33:31 -06:00
keyan 5c3c7fb185 allow more restricted macroons fix #827 2024-02-14 12:58:25 -06:00
keyan 04991b4ddf try url object with next/link to fix #822 2024-02-13 19:44:03 -06:00
ekzyis d6465162bd
Fix missing setInitialized (#815)
Payment methods were not marked as initialized if the local storage item did not exist on page load.
2024-02-13 14:30:54 -06:00
Keyan ec4e1b5da7
LND autowithdraw (#806)
* wip

* wip

* improved validatation, test connection before save, code reuse

* worker send to lnd

* autowithdraw priority
2024-02-13 13:17:56 -06:00
ekzyis 894a73d713
Show item page in internal links (#807)
* Include item page in link text

* Fix invalid URLs parsed
2024-02-12 13:34:33 -06:00
mzivil 6355d7eabc
Add nsfw setting to territories (#788)
* add nsfw column to sub

* add nsfw boolean to territorySchema

* save nsfw value in upsertSub mutation

* return nsfw value from Sub query for correct value in edit territory form

* add nsfw checkbox to territory form

* add nsfw badge to territory header

* add nsfwMode to user

* show nsfw badge next to item territory

* exclude nsfw sub from items query

* show nsfw mode checkbox on settings page

* fix nsfw badge formatting

* separate user from current, signed in user

* update relationClause to join with sub table

* refactor to simplify hide nsfw sql

* filter nsfw items when viewing user items

* hide nsfw posts for logged out users

* filter nsfw subs based on user preference

* show nsfw sub name if logged out user is viewing the page

* show current sub at the top of the list instead of bottom

* always join item with sub to check nsfw

* check for sub presence before showing nsfw badge on item

* skip manually adding sub to select if sub is null

* fix relationClause to join with root item

* move moderation and nsfw into accordion

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2024-02-09 20:35:32 -06:00
ekzyis b3d485e8c4
Refactor default payment method setting (#803)
* Refactor setting of default providers

* fixed warning about component update while rendering another component
* individual providers no longer need to know if they are the default or not
* default setting is now handled by WebLNContext -- the same context that returns the provider. this makes a lot more sense and is a lot easier to read
* default payment checkbox is now also disabled if there is only one enabled provider or if it is the default provider

* Fix order lost on page reload

On page reload, the providers were synced in the order they were loaded.

This means that the default payment provider setting was lost.

Fixed this by syncing order to local storage and on page reload, only syncing providers when they were initialized (else the order would have been lost again).
2024-02-09 09:42:26 -06:00
ekzyis ec3e8f0079
Remove deprecated comment (#801) 2024-02-09 09:39:59 -06:00
ekzyis 310011f05d
Expose WebLN interface via React Context (#749)
* Add LNbits card

* Save LNbits Provider in WebLN context

* Check LNbits connection on save

* refactor: put LNbitsProvider into own file

* Pay invoices using WebLN provider from context

* Remove deprecated FIXME

* Try WebLN provider first

* Fix unhandled promise rejection

* Fix this in sendPayment

* Be optimistic regarding WebLN zaps

This wraps the WebLN payment promise with Apollo cache updates.

We will be optimistics and assume that the payment will succeed and update the cache accordingly.

When we notice that the payment failed, we undo this update.

* Bold strike on WebLN zap

If lightning strike animation is disabled, toaster will be used.

* Rename undo variable to amount

* Fix zap undo

* Add NWC card

* Attempt to check NWC connection using info event

* Fix NaN on zap

Third argument of update is reserved for context

* Fix TypeError in catch of QR code

* Add basic NWC payments

* Wrap LNbits getInfo with try/catch

* EOSE is enough to check NWC connection

* refactor: Wrap WebLN providers into own context

I should have done this earlier

* Show red indicator on error

* Fix useEffect return value

* Fix wrong usage of pubkey

The event pubkey is derived from the secret. Doesn't make sense to manually set it. It's also the wrong pubkey: we're not the wallet service.

* Use p tag in NWC request

* Add comment about required filter field

* Aesthetic changes to NWC sendPayment

* Add TODO about receipt verification

* Fix WebLN attempted again after error

* Fix undefined name

* Add code to mock NWC relay

* Revert "Bold strike on WebLN zap"

This reverts commit a9eb27daec0cd2ef30b56294b05e0056fb5b4184.

* Fix update undo

* Fix lightning strike before payment

* WIP: Wrap WebLN payments with toasts

* add toasts for pending, error, success
* while pending, invoice can be canceled
* there are still some race conditions between payiny the invoice / error on payment and invoice cancellation

* Fix invoice poll using stale value from cache

* Remove unnecessary if

* Make sure that pay_invoice is declared as supported

* Check if WebLN provider is enabled before calling sendPayment

* Fix bad retry

If WebLN payments failed due to insufficient balances, the promise resolved and thus the action was retried but failed immediately since the invoice (still) wasn't paid.

* Fix cache undo update

* Fix no cache update after QR payment

* refactor: Use fragments to undo cache updates

* Remove console.log

* Small changes to NWC relay mocking

* Return SendPaymentResponse

See https://www.webln.guide/building-lightning-apps/webln-reference/webln.sendpayment

* Also undo cache update on retry failure

* Disable NWC mocking

* Fix initialValue not set

But following warning is now shown in console:

"""
Warning: A component is changing a controlled input to be uncontrolled.
This is likely caused by the value changing from a defined to undefined, which should not happen.
Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components
"""

* Remove comment since only relevant for blastr (mutiny relay)

* Remove TODO

* Fix duplicate cache update

* Fix QR modal not closed after payment

* Ignore lnbits variable unused

* Use single relay connection for all NWC events

* Fix missing timer and subscription cleanup

* Remove TODO

Confirmed that nostr-tools verifies events and filters for us.

See https://github.com/nbd-wtf/nostr-tools/blob/master/abstract-relay.ts#L161

* Fix switch from controlled to uncontrolled input

* Show 'configure' on error

* Use budgetable instead of async

* Remove EOSE listener

Only nostr.mutinywallet.com didn't respond with info events due to implementation-specific reasons. This is no longer the case.

* Use invoice expiry for NWC timeout

I don't think there was a specific reason why I used 60 seconds initially.

* Validate LNbits config on save

* Validate NWC config on save

* Also show unattach if configuration is invalid

If unattach is only shown if configuration is valid, resetting the configuration is not possible while it's invalid. So we're stuck with a red wallet indicator.

* Fix detection of WebLN payment

It depended on a Apollo cache update function being available. But that is not the case for every WebLN payment.

* Fix formik bag lost

* Use payment instead of zap in toast

* autoscale capture svc by response time

* docs and changes for testing lnbits locally

* Rename configJSON to config

Naming of config object was inconsistent with saveConfig function which was annoying.

Also fixed other inconsistencies between LNbits and NWC provider.

* Allow setting of default payment provider

* Update TODO comment about provider priority

The list 'paymentMethods' is not used yet but is already implemented for future iterations.

* Add wallet security disclaimer

* Update labels

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2024-02-08 12:33:13 -06:00
ekzyis 46eeb729c3 Fix pinned items don't show up in home 2024-02-04 22:15:18 +01:00
mzivil f2f39f4c22 fix clicks on billing types label not toggling correct radio
Currently, all the billing types radios are being assigned the
same "billingType" id, so clicking on any of the labels
always selects the monthly one. If you inspect the HTML, all the
billing type labels have 'for="billingType"' which is how the HTML
knows which input to select.

We have to keep the "name" attribute the same because that's how
the input values are linked to the billingType form field.

To fix, we explicitly assign the "id" prop for each radio so
that the <label>'s "for" attribute is tied to the correct
radio input.
2024-02-03 16:59:37 -05:00
mzivil 3328c1daa3 fix clicks on post types label not toggling correct checkbox
Currently, all the post types checkbox are being assigned the
same "postTypes" id, so clicking on any of the post type labels
always toggles the first one. If you inspect the HTML, all the
post type labels have 'for="postTypes"' which is how the HTML
knows which checkbox to toggle.

We have to keep the "name" attribute the same because that's how
the checkbox values are linked to the postTypes field.

To fix, we explicitly assign the id prop for each checkbox so
that the <label>'s "for" attribute is tied to the correct
checkbox input.
2024-02-03 16:59:37 -05:00
keyan c23f1f82bc allow pins to be zapped but not from pin position 2024-02-03 15:27:36 -06:00
Keyan b2ba333905
Merge pull request #777 from stackernews/toast-tags
Add tags and onCancel to toasts
2024-02-01 11:10:10 -06:00
ekzyis 730158fd5c Finalize hodl invoices after payment within 60 seconds 2024-02-01 17:28:06 +01:00
ekzyis 1fa129272a Use toast body as default tag 2024-02-01 16:17:54 +01:00
ekzyis 878d661154 Add tag and cancel support to toasts 2024-02-01 16:17:54 +01:00
keyan 61c64646b5 use capture microservice 2024-01-30 18:22:40 -06:00
ekzyis d1ed72bb85
Allow territory founders to pin items (#767)
* Add pinning of items

* Fix empty section in context menu

* Pin comments

* Fix layout shift during comment pinning

* Add comments, rename, formatting

* Max 3 pins allowed

* Fix argument

* Fix missing position update for other items

* Improve error message

* only show saloon in home

* refine pinItem style and transaction usage

* pin styling enhancements

* simpler handling of excess pins

* fix pin positioning like mergePins

* give existing pins null subName

* prevent empty items on load

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2024-01-30 11:04:56 -06:00
keyan 35c76c077e improved footnote styling and list styling 2024-01-28 13:26:32 -06:00
keyan 2338be774d better quoteblock styling 2024-01-28 13:26:32 -06:00
keyan 5086c2036d add ids to all toasts to help id rogue toasts 2024-01-28 13:26:32 -06:00
ekzyis e4aff5d11b
Format internal links as #<id> (#765)
* Format internal links

* Fix URL text ignored
2024-01-24 17:29:52 -06:00
keyan dc8d35fdcf only open related posts when there aren't comments 2024-01-20 15:17:34 -06:00
keyan 70aa7dd1ad fix single date in datepicker 2024-01-19 20:38:35 -06:00
keyan 968263ba6a have datepicker store unix timestamps 2024-01-19 15:30:36 -06:00
keyan eb99fcef9e improve stat gathering 2024-01-19 15:19:26 -06:00
keyan 0134968fc1 don't trigger date picker onchange until 2 dates are picked 2024-01-19 15:14:52 -06:00
keyan d14123cc42 improved comment linking 2024-01-17 19:03:49 -06:00
ekzyis 2ceada66d6
Remove plausible link (#762) 2024-01-17 18:11:00 -06:00
keyan 61a66127d1 search/related posts refinements 2024-01-17 17:39:48 -06:00
ekzyis 9ef0c81245
refactor: replace recursion with promise sequence in `useInvoiceable` (#752)
* refactor: replace recursion with promise sequence

This commit refactors `useInvoicable`. The hard-to-follow recursion was replaced by awaiting promises which resolve or reject when one step of our JIT invoice flow is done.

Therefore, `onSubmit` is now fully agnostic of JIT invoices. The handler only returns when payment + action was successful or canceled - just like when a custodial zap was successful.

* refactor more and fix bugs

* move invoice cancel logic into hook where invoice is also created
* fix missing invoice cancellation if user closes modal or goes back.
* refactor promise logic: it makes more sense to wrap the payment promise with the modal promise than the other way around.

* Fix unhandled rejection

* Fix unnecessary prop drilling

* Fix modal not closed after successful action

* Fix unnecessary async promise executor

* Use function to set state
2024-01-16 18:40:11 -06:00
keyan 9af3388353 semantic search 2024-01-15 17:22:57 -06:00
keyan 1dae33312f allow territories to be renamed 2024-01-11 17:48:08 -06:00
keyan 86e8350994 autowithdraw to lightning address 2024-01-11 13:10:07 -06:00
keyan 572103b2e3 improve wallet limit phrasing 2024-01-11 13:08:37 -06:00
ekzyis bdf9b1f0fd
Territory post notifications (#745)
* Notify founders of new posts

* Only merge notifications of same territory

* Show territory posts in /notifications

* Don't notify on own posts
2024-01-11 11:27:54 -06:00
keyan 9a9e81b109 refine territory details on post form 2024-01-08 19:02:00 -06:00
ekzyis f8cbd43be7
Show territory details in post form (#725)
* Show territory details in post form

* Style territory details in post form

* Keep details closed by default

* Use SUB_FULL

* Undo unused changes to specify accordian default

---------

Co-authored-by: ekzyis <ek@stacker.news>
2024-01-08 17:46:23 -06:00
keyan 5137f1423d change reply placeholder 2024-01-04 18:48:10 -06:00
keyan 26e0dd6f7e Revert "fix #703"
This reverts commit 8996fd085a.
2024-01-03 20:39:26 -06:00
keyan 6a600c2043 fix null sub in select 2024-01-03 19:45:30 -06:00
ekzyis 31a40e15be
refactor delete notification (#731)
Co-authored-by: ekzyis <ek@stacker.news>
2024-01-03 16:24:46 -06:00
keyan 8996fd085a fix #703 2024-01-03 16:12:33 -06:00
keyan 717f8d1ef6 territory billing notifications 2024-01-03 15:20:10 -06:00
ekzyis 562b243111
Fix usage of hardcoded strings for sw message types (#730)
Co-authored-by: ekzyis <ek@stacker.news>
2024-01-03 14:02:01 -06:00
ekzyis 31cef5a7b7
Only close notifications manually on iOS (#729)
* Only close notifications manually on iOS

* Use function instead of hardcoded string

---------

Co-authored-by: ekzyis <ek@stacker.news>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2024-01-03 11:56:29 -06:00
ekzyis ade35b9ea0
Add verbose logging in onPush listener (#724)
* refactor: Use log function in service worker

* Add verbose logging on push listener

* Fix TypeError: Cannot read properties of null (reading 'postMessage')

navigator.serviceWorker.controller is null on forced refreshes:

"""
This property returns null if the request is a force refresh (Shift + refresh) or if there is no active worker.
"""

-- https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller

This means when we unregister a service worker manually (like I do for debugging purposes) and then reload the page, there is no service worker available when this code is run.

Adding a check with a more helpful error message should improve UX.

This error might also happen in other cases where a page refresh should also help.

---------

Co-authored-by: ekzyis <ek@stacker.news>
2024-01-03 11:51:04 -06:00
keyan c597acfb8f add mempool link 2024-01-02 16:35:01 -06:00
keyan 240ac3497d refine territory mutes 2023-12-31 10:52:19 -06:00
keyan 76b63240db fix territory mutes for logged out 2023-12-30 19:45:41 -06:00
keyan 0999004646 mute territories in overflow 2023-12-30 19:41:16 -06:00
keyan 9ab1d770eb remove debug log statement 2023-12-30 18:43:41 -06:00
keyan f267137662 add muted section to territory select 2023-12-30 18:19:42 -06:00
keyan 214e863458 mute territories 2023-12-30 17:16:09 -06:00
ekzyis 3a0c50566b
Fix TypeError (reading 'moderated') (#722)
Co-authored-by: ekzyis <ek@stacker.news>
2023-12-30 14:40:06 -06:00
ekzyis c23799be81
Remove ineffective guard against all caps (#723)
Co-authored-by: ekzyis <ek@stacker.news>
2023-12-30 14:38:41 -06:00
keyan dc15be914c opt-in moderation for territory founders 2023-12-29 18:05:16 -06:00
keyan 45e7503784 improve outlawed comment ux 2023-12-27 18:14:22 -06:00
keyan 6170853d72 unify idempotent act and act 2023-12-27 10:15:18 -06:00
keyan 73ad93f2bb idempotent zaps 2023-12-26 20:27:52 -06:00
keyan 374a7985da unify zap/downzap/bounty mutation 2023-12-26 16:51:47 -06:00
keyan 67a9fe23cf stablize act mutation reference 2023-12-26 15:55:48 -06:00
keyan 8c5c29ee45 remove snow 2023-12-25 18:05:45 -06:00
ekzyis 05bdd988fa
Christmas zaps (#707)
* Christmas zaps

* Also add 50px margin on left side

* Remove wrong comment

* Use grey snow in light mode

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-12-24 16:49:41 -06:00
keyan ac1c64e402 reduce redundant messaging in wallet limit banner 2023-12-21 17:52:35 -06:00
keyan f3ac63050e floor the chain fee float 2023-12-21 17:45:03 -06:00
keyan 4c36b7813a refine wallet limit banner slightly 2023-12-21 17:40:11 -06:00
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 fdf8f8e395 fix footnote links 2023-12-20 18:54:56 -06:00
keyan 633c96d619 handle hash urls with 'view more' 2023-12-20 18:16:34 -06:00
st4rgut24 e9a5d22a6e
Add chain fees to price carousel (#658)
* add chain fees to price carousel

* restore check for valid carousel values

* add nym to contributors

---------

Co-authored-by: stargut <stargut@starguts-MacBook-Pro.local>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2023-12-20 16:06:22 -06:00
ekzyis 056be01f15
Request persistent storage (#701)
* Request persistent storage

* Only prompt for persistent storage if push notifications enabled

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-12-20 14:38:43 -06:00
keyan 65744364f1 undo zap/downzap and improve downzap ux 2023-12-19 19:55:19 -06:00
keyan 7e0da18878 down zap ui polish 2023-12-19 18:25:41 -06:00
keyan 9455847484 add timeouts for nostr extension calls 2023-12-19 16:01:48 -06:00
Austin Kelsay 5737027c0f
Nostr crossposting improvements (#629)
* Add nostr event id field to items

* crosspost-item

* crosspost old items, update with nEventId

* Updating noteId encoding, cleaning up a little

* Fixing item-info condition, cleaning up

* Linting

* Spacing nit

* Add createdAt variable back

* Change instances of eventId to noteId

* Adding upsertNoteId mutation

* Cleaning up updateItem, using toasts to communivate success/failure in crosspost-item

* Linting

* Fix type

* Move crosspost to share button, make sure only OP can crosspost

* Lint

* Simplify conditions

* user might have no nostr extension installed

Co-authored-by: ekzyis <27162016+ekzyis@users.noreply.github.com>

* change upsertNoteId to updateNoteID for resolver and mutations, change isOp to mine, remove unused noteId params

* Use nostr.com for linking out with noteId

* lint

* add noopener to window.open call

* Simplify condition, throw GraphQLError

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: ekzyis <27162016+ekzyis@users.noreply.github.com>
2023-12-19 11:48:48 -06:00
ekzyis 6682817578
Do not remove orientation EXIF data (#683)
* Keep orientation metadata

* npm install piexifjs

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-12-19 09:45:21 -06:00
keyan fc3f46a343 fix #687 2023-12-17 13:23:52 -06:00
keyan 3a7d899ce7 fix missing view more? #687 2023-12-15 18:18:30 -06:00
keyan a5e50821b7 gofac yourself 2023-12-14 11:30:51 -06:00
keyan ca02d627c1 make anon fees consistent 2023-12-10 16:56:22 -06:00
keyan c8bca3ef63 allow territory founders to disable freebies 2023-12-10 15:41:20 -06:00
keyan e08fca15b6 set billing state from existing on edit 2023-12-08 19:11:25 -06:00
keyan 1d66be68cc make territory billing renewal opt-in 2023-12-08 14:02:00 -06:00
ekzyis 5e51fe5330
Fix bio replies (#669)
Co-authored-by: ekzyis <ek@stacker.news>
2023-12-07 15:50:36 -06:00
keyan c33d4b9b01 fix horizontal layout shift from select 2023-12-06 13:40:14 -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
keyan 82a1b450f5 view more viewheight 2023-12-04 20:08:52 -06:00
keyan e8e22ad7d4 fix click to reveal text initial render 2023-12-04 18:02:48 -06:00
keyan 86cdb69082 add copyright policy 2023-12-04 16:56:13 -06:00
keyan 4127adb169 click to reveal text when very long 2023-12-04 16:30:39 -06:00
keyan 6c576bda84 legal footer 2023-12-04 13:42:39 -06:00
keyan f465c6d881 remove negative lookbehind for #656 and fix mention regex 2023-12-03 12:58:28 -06:00
ekzyis 32403d0c29
Unsubscribe on signout (#653)
Co-authored-by: ekzyis <ek@stacker.news>
2023-11-25 14:29:42 -06:00
keyan a1114e5270 fix mention positioning 2023-11-22 09:12:43 -06:00
keyan 8e01568622 remove dead gql 2023-11-21 17:26:24 -06:00
keyan 70e4b27c03 fix youtube/twitter embed styling when there's text 2023-11-21 16:20:54 -06:00
keyan 6bc1b08606 fix twitter embed styling 2023-11-21 15:39:53 -06:00
keyan 20e46e747d small refinements to image min-width 2023-11-21 14:58:15 -06:00
keyan 47a5b311c3 refine mentions 2023-11-21 14:49:39 -06:00
keyan a74c5201bc reply cancel confirm 2023-11-21 12:49:22 -06:00
keyan 21c1fd11ba refine quote reply hook and #643 2023-11-21 12:35:37 -06:00
keyan d211fe93ea fix quote reply by removing imperative logic 2023-11-20 21:38:18 -06:00
keyan 2bcf3acda6 fix small images #619 2023-11-20 19:54:22 -06:00
keyan 58a9d03e28 only query for deleteScheduledAt when needed 2023-11-20 15:38:49 -06:00
keyan a12e969bd1 fix #631 2023-11-20 13:54:09 -06:00
keyan 1266ae2983 fee button improvements 2023-11-20 13:20:28 -06:00
keyan af59e3ef54 merge non-normalized user subtypes fixing #645 2023-11-20 09:05:02 -06:00
SatsAllDay 44e12a4b44
Move the `AD` badge to be alongside other item info badges (#647) 2023-11-20 08:33:59 -06:00
SatsAllDay 4596681fbc
Toast on delete bot directive usage (#620)
* Toast on successful delete bot directive

* refactor duplicate code into a reusable function

* restore empty spacing lines to clean up the diff

* perf optimization, only query for deleteScheduledAt for your own items

* Issue a warning toast if the delete bot was mentioned but the item was not scheduled for deletion

* use bs-secondary color for warning

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2023-11-19 15:09:47 -06:00
st4rgut24 d84c46df81
Dont display price component until after initial render (#637)
* Dont display price component until after initial render

* change variable name and remove log

* fix linting issues

---------

Co-authored-by: stargut <stargut@starguts-MBP.fios-router.home>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2023-11-19 15:01:12 -06:00
SatsAllDay 64a16373c5
Fix client-side error boundary (#623)
* * add error boundary immediately above page component

* send error logs to server via LoggerContext

* display error stack and component stack in copyable text area

* wrap every context provider in an error boundary

* memoize context values to fix error boundary propagation issue

* Wrap page component in an error boundary so we can use our context utilities
for a better experience, like toast and logger

Still have a top-level error boundary that catches things from the context providers,
just in case.

Don't display the whole error stack, just because it's ugly, but make it copyable
2023-11-19 14:24:56 -06:00
ekzyis 158baa61e3
Strip EXIF data before upload on client (#634)
Co-authored-by: ekzyis <ek@stacker.news>
2023-11-19 14:22:46 -06:00
keyan a318727f9c fix freebie dialog (#460) 2023-11-19 14:16:35 -06:00
keyan 589b15b597 fix custom dates to use ms since epoch 2023-11-14 10:23:44 -06:00
keyan ffe9983b80 fix successive zap timing issues? 2023-11-13 20:02:34 -06:00
keyan 7b58edb77b reintroduce searching by most recent 2023-11-13 18:17:45 -06:00
ekzyis 503f4c380b
Disable reply button while uploading (#627)
Co-authored-by: ekzyis <ek@stacker.news>
2023-11-13 09:30:01 -06:00
keyan d599ec76ce fix mention clientside cache problems 2023-11-12 14:51:12 -06:00
keyan 03acce2305 fix nostr auth (#621) 2023-11-12 11:59:18 -06:00
keyan 081e22f63e fix post headings 2023-11-12 09:04:28 -06:00
keyan a78661c6e7 omit op from self-reply fee escalation 2023-11-11 16:47:54 -06:00
keyan c23e49872a make fee button less of a hack 2023-11-10 18:18:10 -06:00
keyan 3499f92436 dramatically improve search 2023-11-10 09:22:30 -06:00
keyan 7cb3a7ad64 small receipt styling 2023-11-10 09:22:14 -06:00
keyan 494b8b3dcd better organize user graphql types 2023-11-09 19:05:35 -06:00
rleed d86d8b3bac
Provide option to clear withdrawal invoices (#591)
* add settings option

* add auto-drop worker

* add manual delete option

* add warning and note

* cleanup

* incorporate most review feedback

* add warning to settings option

* remove debugging tweaks and simplify

* refine auto delete bolt11s

* refine UI

---------

Co-authored-by: rleed <rleed1@pm.me>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2023-11-09 11:50:43 -06:00