Commit Graph

143 Commits (43b74fd89040589678b0ae7de1f505e7fa998c33)
 

Author SHA1 Message Date
OFF0 43b74fd890
system: move pow function and error overlay to system
type and move powEvent and its error overlay to system.ts
2 years ago
OFF0 44bfc83732
settings: refactor pubkey into config.pubkey global
starting to move global application user config to settings.ts.
plan is to only share user settings via the config object, with
this all settings related ui can be moved out of main.js into its
own module.
2 years ago
OFF0 f89a06c680
utils: cleanup and move isvalidurl to utils/url 2 years ago
OFF0 fcbf1c4272
utils: move lock and unlock scroll functions to utils 2 years ago
OFF0 4cdbf0349f
utils: import directly from utils
it is not worth to import everything from utils, as there are too
many functions, better import them directly from each module.
2 years ago
OFF0 5bf3ee4452
styles: move stylesheets to styles 2 years ago
OFF0 e170570934
typescript 2 years ago
OFF0 838afa9ed8
refactor: type element attributes
use attributes of html element type.

so that the following example is correctly typed:

elem('input', {
  className: 'foo',
  hidden: false,
  onclick: () => alert('hi'),
  tabIndex: 1,
  valueAsNumber: 1,
});

but this fails as foo is no valid attribute on div element:

elem('div', {foo: 'bar'});
2 years ago
OFF0 334b09afa1
refactor: type elem and enforce inferred generic type
typed elem so that it returns the exact type of the HTMLElement,
and that name must be a key of HTMLElementTagNameMap.

example:

elem('form'); // returns HTMLFormElement

elem('abc'); // not assignable to parameter of type 'keyof HTMLElementTagNameMap'
2 years ago
OFF0 67af695350
refactor: type events.ts, url.ts and crypto.ts 2 years ago
OFF0 5e75b64619
refactor: type view.ts, dom.ts and time.ts 2 years ago
OFF0 faca657ce4
refactor: type subscriptions.ts
typed subscribe functions in subscriptions.ts
2 years ago
OFF0 6688bb65fc
routes: use nip19 as routes
so we need no guessing logic and know what to subscribe too. in a
later step it add more to the view i.e. show profile meta data for
npub.
2 years ago
OFF0 b65a1b5d95
nip19: use bech32 npub and note in uris
convert pubkey to npub and event id to note and store for
later. use npub and note for uri's so that we dont need to
guess what the view of a specific uri has to render.

this is only the first step that changes uri's, next step is
for the view to react to npub or note and render the
correct view accordingly.
2 years ago
OFF0 589e65ae40
relays: type and upgrade to nostr-tools@1.6.0
move and typed relay related code to relays.ts

upgrade nostr-tools to latest greatest, major version with
breaking changes:

- relayPool is gone in favor of SimplePool, but this commit just
  used relayInit directly as relays should become configurable at
  some point
2 years ago
OFF0 ad81d892e1
routes: use generic view containers
proof of concept to use generic view containers instead of specifc
functions to show and hide particular views.

a view has an identifier (path) which is used to subscribe to
relevant data. changing a view updates the history so that browser
back displays the last view. each view container has its own
scrollbar so that the scrolling position should be preserved when
changing back and forth between different views.

this change also removes CSS tabs in favor of view or overlays
such settings or write a new text note.

profile and notes deeplink use now native HTML anchors to improve
accessibility (copy/paste, open-in-new-tab, search engines).
2 years ago
OFF0 9e46342250
0.0.23
ci/woodpecker/push/woodpecker Pipeline was successful Details
2 years ago
OFF0 e84af81b97
relay: add snort.social relay
ci/woodpecker/push/woodpecker Pipeline was successful Details
relay.snort.social seems to be a popular relay, adding a new one
to the hardcoded list of relays, this should be configurable in
the future.

related damus relay is often not responding or slow, but keeping
it for now.
2 years ago
OFF0 5a18e2952c
profile: increase number of notes shown on profile
ci/woodpecker/push/woodpecker Pipeline was successful Details
there is no good reason to show less notes on a profile deeplink.
changed limit to 450, same as explore feed.
2 years ago
OFF0 593d4c6e38
relay: change wlvs.space to eden.land
ci/woodpecker/push/woodpecker Pipeline was successful Details
wss://nostr-relay.wlvs.space is not working anymore, seems they
moved, see:
- https://nostr.ch/cbb15cbd3a36a79a4611ee2852bea503f764c4d48fdb5988b1124a146efccc55
2 years ago
OFF0 4544ccc996
0.0.22
ci/woodpecker/push/woodpecker Pipeline was successful Details
2 years ago
OFF0 339e1ed97c
feed: style 3 levels of nested threads
ci/woodpecker/pr/woodpecker Pipeline was successful Details
ci/woodpecker/push/woodpecker Pipeline was successful Details
instead of just adding 1 line for all replies to point to the
original note, using smaller profile pic for replies of replies
help to understand the context of the replies.

this is done without increasing indentation as heavy nesting can
mess up the layout so only indentation is visible and the space
for the actual content gets to small.

if needed users can inspect replies and navigate to the deeplink
to see how the next 3 levels are nested.
2 years ago
OFF0 e94c9c92da
feed: sort replies by created at
replies were not sorted correctly, reason for this was that an
array of dom elements was sorted, but instead it should sort the
notes.

regression introduced in:
- 2e40a273c4
2 years ago
OFF0 0dcfa6e0a9
feed: show publish note within the same second
a fast relay might return a newly published note within the same
second, but nostrweb only shows notes that are older than now.

was introduced in 4a68940681
2 years ago
OFF0 f4f951469f
feed: less eager rendering
ci/woodpecker/pr/woodpecker Pipeline was successful Details
ci/woodpecker/push/woodpecker Pipeline was successful Details
before this change every new incoming text note called a render,
that filters, sorts and iterates all known text notes and creates
missing dom elements and appends into the right place.

this change throttles and debounces (both!) the render function,
that less checks have to be performed, especially on page load
when potentially 100s of events arrive within a short time.

it is important to throttle and debounce, else either the last call
is missed or no render is called while events are being received.

this change surfaced an error in recommend server that depended on
all known text notes already being rendered and inside the dom.
this function should probably be handled by render feed itself.
2 years ago
OFF0 dffcbc6b2b
0.0.21
ci/woodpecker/push/woodpecker Pipeline was successful Details
2 years ago
OFF0 2e40a273c4
nip-10: fix duplicate replies in feed
ci/woodpecker/pr/woodpecker Pipeline was successful Details
ci/woodpecker/push/woodpecker Pipeline was successful Details
some replies rendered twice in different positions, seems to be
related to deprecated positional event tags and a regression
introduced in a596121821

on receiving events it analizes the event tags and stores the id
of the replied event so the client can easily search for replies
later. marked tags are prefered with a fallback to positional tags
as described in nip-10.

mentions are ignored at the moment.

example event that had some replies rendered twice:
22e4ea80161ac591059da611d3ab63c583cb1d47a706826db2fc6955ac0a70b5
2 years ago
OFF0 ff4b67a0fb
0.0.20
ci/woodpecker/push/woodpecker Pipeline was successful Details
2 years ago
OFF0 c16ccdb4e3
nip-13: improve mining error
ci/woodpecker/pr/woodpecker Pipeline was successful Details
ci/woodpecker/push/woodpecker Pipeline was successful Details
- fix error overlay colors in light-mode
- improve error text, mentoning what happend and what to do
2 years ago
OFF0 98aa92b9ed
0.0.19
ci/woodpecker/push/woodpecker Pipeline was successful Details
2 years ago
OFF0 a61b54de7c
feed: fix link rendering
ci/woodpecker/pr/woodpecker Pipeline was successful Details
ci/woodpecker/push/woodpecker Pipeline was successful Details
some words were incorrectly detected as links.

changed:
- split words by any whitespace character, not just char 32
- match words _beginning_ with http, https or www.

example of broken link user white space character code 160, see:
feb290999a2746bf0914ede8a811b52eccd423f9f5373232e4f5947131fb47aa
2 years ago
OFF0 8ff1d2c1d8
nip-13: check zero leading bits
ci/woodpecker/pr/woodpecker Pipeline was successful Details
ci/woodpecker/push/woodpecker Pipeline was successful Details
before it was only testing if the nonce commitment is high enough
but didn't verify leading zero bits.

with this change rendering checks now the leading zero bits count
of the event id.
2 years ago
OFF0 4a68940681
feed: render only notes from the past
ci/woodpecker/pr/woodpecker Pipeline was successful Details
ci/woodpecker/push/woodpecker Pipeline was successful Details
some notes have a created at field that is 1 year in the future,
these are always shown on to of the feed. changed to only render
notes that are from the past.
2 years ago
OFF0 c2db08c7dc
0.0.18
ci/woodpecker/push/woodpecker Pipeline was successful Details
2 years ago
OFF0 caf5083caa
nip-13: difficulty filter
ci/woodpecker/pr/woodpecker Pipeline was successful Details
ci/woodpecker/push/woodpecker Pipeline was successful Details
added a slider to adjust the difficulty filter, current default is
0 so all notes are rendered. increasing the filter will hide notes
with lower difficulty target.

changed the max difficulty from 256 to 32 for now so that the
range slider is usable.

this does not yet hide reactions with lower difficulty.
2 years ago
OFF0 a3de8f1595
feed: improve recommend server (kind 2) messages
ci/woodpecker/pr/woodpecker Pipeline was successful Details
ci/woodpecker/push/woodpecker Pipeline was successful Details
- check that event.content is a valid WSS url, drop otherwise
- fix bug that rendered the same server recommendation twice
2 years ago
OFF0 2dd9cf633a
0.0.17
ci/woodpecker/push/woodpecker Pipeline was successful Details
2 years ago
OFF0 37f0a07cf3
nip-13: show working msg and cancel btn while mining
ci/woodpecker/pr/woodpecker Pipeline was successful Details
ci/woodpecker/push/woodpecker Pipeline was successful Details
mining often takes a few seconds. it can be confusing if nothing
happens when a user is publishing their profile, upvoting a note
or posting a new note.

added visual feedback that nostrweb is working with an option to
cancel the mining process.
2 years ago
OFF0 898e7265c2
nip-13: add settings for mining difficulty and timeout
adding settings to change mining difficulty and timeout, so users
can change or disable pow. also added some explanation and link
to nip-13.

setting arbitrary low default to 16 zero mining difficulty and
5 seconds timeout.
2 years ago
OFF0 a596121821
feed: dirty fix to show replies
now that nonce tag is always the first element in the tags list,
a bug surfaced that replies from nostrweb did not render anymore.

reason was that the code expected the first tag to be an e tag and
took its reply-id. this commit is a quick fix that takes the first
reply-id from the first e tag.

the proper way is a bit more complicated as nip-10 defines a
preferred and deprecated way.

this is a quick and dirty fix so that replies work with nip-13 pow
events, but nip-10 event tags should be properly supported but in
a later commit.
2 years ago
OFF0 d5e9ef18c7
nip-13: add timeout and show user facing error if it exceeds
mining may take a long time if the mining difficulty is high.

calculating pow for text notes, upvotes and profile meta
data now has a timeout of 10s. if the timeout exceeds a user
facing error is shown with the option to try again.

the error is currently very basic, and only displays timeout -
something went wrong, cancel and try again button.
2 years ago
OFF0 a1b1f3baee
nip-13: mine pow async in worker any only invoke noxy with pow
added pow to text notes, reactions and metadata events. pow is
mined async in a worker so that the main process does not freeze.

noxy profile images, link and image previews are now now only
invoked if an event has some valid work proof. noxy can decide
if there is enough work and whether or not to serve data for a
certain event.

target difficulty can be implemented in a later step, this change
only check if there is any valid nonce tag with commitment target
greater than 0.
2 years ago
OFF0 7edf1151a6
nip-25: use proper reacted to e and p tags
ci/woodpecker/pr/woodpecker Pipeline was successful Details
ci/woodpecker/push/woodpecker Pipeline was successful Details
the actual event that is being reacted must be the last event tag,
was wrongly using the first one and displayed wrong star if tags
had more than 1 event tag.

upvoting now also includes e and p tags from the event that is
upvoted.

see also https://github.com/nostr-protocol/nips/blob/master/25.md
2 years ago
OFF0 dc2def3361
0.0.16
ci/woodpecker/push/woodpecker Pipeline was successful Details
2 years ago
OFF0 485510314a
relays: update list of relays
ci/woodpecker/pr/woodpecker Pipeline was successful Details
ci/woodpecker/push/woodpecker Pipeline was successful Details
adding damus again (was disabled when it was down and heavy spam
happened last year), remove nostr.sandwich.farm as it currently
errors with '502 Bad Gateway'.
2 years ago
OFF0 89c54ac08f
0.0.15
ci/woodpecker/push/woodpecker Pipeline was successful Details
2 years ago
OFF0 387f4de3f2
content: parse lightning addresses and render as links
ci/woodpecker/pr/woodpecker Pipeline was successful Details
ci/woodpecker/push/woodpecker Pipeline was successful Details
LN addresses use too much screen real estate, render as link seems
more useful.

lightning links are words starting with the following prefix:
lnbc for Bitcoin mainnet, lntb for testnet, lntbs for signet, and
lnbcrt for regtest

https://github.com/lightning/bolts/blob/master/11-payment-encoding.md#human-readable-part
2 years ago
OFF0 d7f75f92e0
content: exlcude links to localhost
ci/woodpecker/pr/woodpecker Pipeline was successful Details
ci/woodpecker/push/woodpecker Pipeline was successful Details
No good reason to link to localhost.
2 years ago
OFF0 dc664fc318
content: exclude links to ip addresses
There is no good reason to link to an ip directly.

Excluding links that look like ipv4 or ipv6.
2 years ago
alex 9b11459f2d
css: temporary disable image previews until things calm down
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/tag/woodpecker Pipeline was successful Details
there's too much porn spam at the moment.
revert this when we find an alternative.
2 years ago