feed: display link preview with noxy
#34
Merged
offbyn
merged 4 commits from feed-preview-links
into master
2 years ago
Loading…
Reference in New Issue
There is no content yet.
Delete Branch 'feed-preview-links'
Deleting a branch is permanent. It CANNOT be undone. Continue?
fetches the first link and shows it below a text note, all
resources are prxied through noxy.
see nostr/noxy#2
fixes #30
would it be possible to load only those images which are in the current view port?
one issue is, on a frech page load, nostrweb loads lots of events and hits noxy with many requests, resulting in "429 too many requests" rate limit and broken images.
@ -160,0 +171,4 @@
function linkPreview(href, id, relay) {
if ((/\.(gif|jpe?g|png)$/i).test(href)) {
return elem('div', {},
[elem('img', {className: 'preview-image-only', src: getNoxyUrl('data', href, id, relay).href})]
when noxy is hit with too many requests, it'll respond accordingly, with 429 status code. would it make sense to attache a "on error" handler and retry later? something like this in a pseudo-code:
and a similar approach for preview below.
I'll try, maybe there is a way without appending
?ts=time.now()
, asuming you don't send cache headers on 4xx responses.right, noxy doesn't send cache-control in 4xx but will a browser actually make a new request without a
ts
?amazing when it works! this looks very nice:
here you see on my feed, noxy started responding with "429 too many requests" at some point:
💯 definetly, to keep it super simple in this iteration I'll try to just add loading="lazy" attribute to the images, https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-loading
I want, but need to play around with this about how to do it exactly, currently the request is created by
<img src="noxy-url"
, so I am not sure what to do onerror, maybe just removing and adding the image from the DOM will try to request it again. alternativelly we could fetch in js and on success add the image to the DOM, then the question is should it even try to ever load by img src or always from js.lgtm! let's merge now and improve later, but before v1.0.0 :)
f411298129
to80944adef7
2 years agorebased
52b16b75d2
to1a71ae2707
2 years ago1a71ae2707
tocd71da0a87
2 years ago@x1ddos I added lazy loading for images and a queue to fetch metadata (this is very rundimentary and could be improved in various ways in the future).
cd71da0a87
tob321acde02
2 years agorebased
nice! tried locally, works wonderfully. ship it!
b321acde02
into master 2 years agoReviewers
b321acde02
.Step 1:
From your project repository, check out a new branch and test the changes.Step 2:
Merge the changes and update on Gitea.