Fix quote length

This commit is contained in:
Jonathan Staab 2023-06-19 13:23:40 -07:00
parent d5b3d935a4
commit 24a198bf80
4 changed files with 63 additions and 22 deletions

View File

@ -1,5 +1,29 @@
# Current
- [ ] White-labeled
- [ ] Add invite code registration for relay
- [ ] Add endpoint to nostream that updates whitelist
- [ ] Show invite code somewhere so users can share it.
- [ ] Use a signed string so it's based on pubkey?
- [ ] Nostream is public-read, apply registration to reads as well
- [ ] Avoid leaking events from private relays
- [ ] Image classification
- https://github.com/bhky/opennsfw2
- [ ] Convert app store to nip 89
- [ ] Put search icon in header or hover button, open in modal
- [ ] Centralize relays
- This is ok, relays are the source of decentralization
- clients can help with discoverability
- Add agent to dufflepud database that scrapes relays and reviews
- Serve relays from dufflepud
- Or maybe set up a special purpose relay for relay recs?
# Core
- [ ] Private groups
- [ ] Support server-rendered link previews
- [ ] Feeds load forever if a modal is open
- [ ] Support other list types than 30001
- [ ] Spam
- Add configurable POW req for replies
- Add event queue and undo, use the delay to calculate POW

View File

@ -1,5 +1,5 @@
<script lang="ts">
import {without} from "ramda"
import {without, last} from "ramda"
import {
parseContent,
getLinks,
@ -18,7 +18,9 @@
import NoteContentQuote from "src/app/shared/NoteContentQuote.svelte"
import NoteContentEntity from "src/app/shared/NoteContentEntity.svelte"
export let note, anchorId, maxLength, showEntire
export let note, maxLength
export let anchorId = false
export let showEntire = false
export let showMedia = false
const fullContent = parseContent(note)
@ -44,13 +46,13 @@
<QRCode fullWidth onClick="copy" code={value} />
</div>
{:else if type === LINK}
<NoteContentLink {value} showMedia={showMedia && isStartOrEnd(i) && value.url.includes('/')} />
<NoteContentLink {value} showMedia={showMedia && isStartOrEnd(i) && last(value.url.split('://')).includes('/')} />
{:else if type.match(/^nostr:np(rofile|ub)$/)}
<NoteContentPerson {value} />
{:else if type.startsWith("nostr:") && showMedia && isStartOrEnd(i) && value.id !== anchorId}
<NoteContentQuote {note} {value}>
<div slot="note-content" let:quote>
<svelte:self note={quote} />
<svelte:self note={quote} {anchorId} {maxLength} {showMedia} showEntire={false} />
</div>
</NoteContentQuote>
{:else if type.startsWith("nostr:")}

View File

@ -11,10 +11,13 @@
import {getPersonWithFallback} from "src/agent/db"
import {sampleRelays} from "src/agent/relays"
import network from "src/agent/network"
import user from "src/agent/user"
export let note
export let value
let muted = false
const openPerson = pubkey => modal.push({type: "person/feed", pubkey})
const loadQuote = async () => {
@ -28,14 +31,23 @@
filter: [{ids: [id]}],
})
muted = user.applyMutes([event]).length === 0
return event || Promise.reject()
} catch (e) {
warn(e)
}
}
const openQuote = () => {
modal.push({type: "note/detail", note: {id: value.id}})
const openQuote = e => {
// stopPropagation wasn't working for some reason
if (e.target.textContent !== "Show") {
modal.push({type: "note/detail", note: {id: value.id}})
}
}
const unmute = e => {
muted = false
}
</script>
@ -44,18 +56,25 @@
{#await loadQuote()}
<Spinner />
{:then quote}
{@const person = getPersonWithFallback(quote.pubkey)}
<div class="mb-4 flex items-center gap-4">
<PersonCircle size={6} {person} />
<Anchor
stopPropagation
type="unstyled"
class="flex items-center gap-2"
on:click={() => openPerson(quote.pubkey)}>
<h2 class="text-lg">{displayPerson(person)}</h2>
</Anchor>
</div>
<slot name="note-content" {quote} />
{#if muted}
<p class="mb-1 py-24 text-center text-gray-5" in:fly={{y: 20}}>
You have muted this note.
<Anchor on:click={unmute}>Show</Anchor>
</p>
{:else}
{@const person = getPersonWithFallback(quote.pubkey)}
<div class="mb-4 flex items-center gap-4">
<PersonCircle size={6} {person} />
<Anchor
stopPropagation
type="unstyled"
class="flex items-center gap-2"
on:click={() => openPerson(quote.pubkey)}>
<h2 class="text-lg">{displayPerson(person)}</h2>
</Anchor>
</div>
<slot name="note-content" {quote} />
{/if}
{:catch}
<p class="mb-1 py-24 text-center text-gray-5" in:fly={{y: 20}}>
Unable to load a preview for quoted event

View File

@ -144,10 +144,6 @@ export const createScroller = (loadMore, {reverse = false, element = null} = {})
element = element || document.body
// NOTE TO FUTURE SELF
// If the scroller is saturating request channels on a slow relay, the
// loadMore function is not properly awaiting all the work necessary.
// That is the problem, but see commit 8371fde for another strategy
let done = false
const check = async () => {
// While we have empty space, fill it