Add link previews

This commit is contained in:
Jonathan Staab 2023-06-15 13:30:24 -07:00
parent 3a6a30c88a
commit 2d2c11fd6a
5 changed files with 35 additions and 10 deletions

View File

@ -1,5 +1,9 @@
# Changelog # Changelog
# 0.2.32
- [x] Add note preview
# 0.2.31 # 0.2.31
- [x] Add the ability to view and write reviews on relays, with ratings - [x] Add the ability to view and write reviews on relays, with ratings

View File

@ -18,12 +18,18 @@
- [ ] Fix unauthenticated experience. Going to an npub just spins - [ ] Fix unauthenticated experience. Going to an npub just spins
- [ ] Convert app store to nip 89 - [ ] Convert app store to nip 89
- [ ] Put search icon in header or hover button, open in modal - [ ] Put search icon in header or hover button, open in modal
- [ ] Hide muted quoted events
- [ ] 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 # Core
- [ ] Deploy ontology.coracle.social - [ ] Deploy ontology.coracle.social
- [ ] Add threads - replies by self get shown at the top of replies? - [ ] Add threads - replies by self get shown at the top of replies?
- [ ] Show link previews when posting
- [ ] Embedded music players for Spotify, youtube, etc - [ ] Embedded music players for Spotify, youtube, etc
- [ ] Make mutes private - [ ] Make mutes private
- [ ] Add nostrscript nevent1qqsvetmqsk8025jadyn82cpmkgxcesjffqajssd2qaq0k8arw9v79tsppadk7cn2v43hggz0vf4x2cm5t5yt4dnl - [ ] Add nostrscript nevent1qqsvetmqsk8025jadyn82cpmkgxcesjffqajssd2qaq0k8arw9v79tsppadk7cn2v43hggz0vf4x2cm5t5yt4dnl

View File

@ -14,6 +14,7 @@
import Modal from "src/partials/Modal.svelte" import Modal from "src/partials/Modal.svelte"
import Heading from "src/partials/Heading.svelte" import Heading from "src/partials/Heading.svelte"
import RelayCard from "src/app/shared/RelayCard.svelte" import RelayCard from "src/app/shared/RelayCard.svelte"
import NoteContent from "src/app/shared/NoteContent.svelte"
import RelaySearch from "src/app/shared/RelaySearch.svelte" import RelaySearch from "src/app/shared/RelaySearch.svelte"
import {getUserWriteRelays, getRelayForPersonHint} from "src/agent/relays" import {getUserWriteRelays, getRelayForPersonHint} from "src/agent/relays"
import {getPersonWithFallback} from "src/agent/db" import {getPersonWithFallback} from "src/agent/db"
@ -29,6 +30,7 @@
let q = "" let q = ""
let image = null let image = null
let compose = null let compose = null
let showPreview = false
let showSettings = false let showSettings = false
let relays = writable( let relays = writable(
(writeTo ? writeTo.map(url => ({url, score: 1})) : getUserWriteRelays()) as Array<{ (writeTo ? writeTo.map(url => ({url, score: 1})) : getUserWriteRelays()) as Array<{
@ -94,6 +96,10 @@
relays.update(reject(propEq("url", relay.url))) relays.update(reject(propEq("url", relay.url)))
} }
const togglePreview = () => {
showPreview = !showPreview
}
onMount(() => { onMount(() => {
if (pubkey && pubkey !== user.getPubkey()) { if (pubkey && pubkey !== user.getPubkey()) {
compose.mention(getPersonWithFallback(pubkey)) compose.mention(getPersonWithFallback(pubkey))
@ -113,14 +119,23 @@
<div class="flex w-full flex-col gap-4"> <div class="flex w-full flex-col gap-4">
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<strong>What do you want to say?</strong> <strong>What do you want to say?</strong>
<div class="border-l-2 border-solid border-gray-6 pl-4"> <div class="ml-2 mt-4 border-l-2 border-solid border-gray-6 pl-3">
<Compose bind:this={compose} {onSubmit} /> {#if showPreview}
<div class="flex justify-end"> <NoteContent note={{content: compose.parse(), tags: []}} />
<small class="text-gray-5"> {/if}
Posting as @{displayPerson(getPersonWithFallback(user.getPubkey()))} <div class:hidden={showPreview}>
</small> <Compose bind:this={compose} {onSubmit} />
</div> </div>
</div> </div>
<div class="flex items-center justify-end gap-2 text-gray-5">
<small>
Posting as @{displayPerson(getPersonWithFallback(user.getPubkey()))}
</small>
<span></span>
<small on:click={togglePreview} class="cursor-pointer underline">
{showPreview ? "Hide" : "Show"} Preview
</small>
</div>
</div> </div>
{#if image} {#if image}
<Media <Media

View File

@ -88,8 +88,8 @@
</script> </script>
<div <div
style={$$props.style} style={$$props.style || "min-height: 6rem"}
class={cx($$props.class, "w-full min-w-0 p-2 text-gray-2 outline-0")} class={cx($$props.class, "w-full min-w-0 text-gray-2 outline-0")}
autofocus autofocus
contenteditable contenteditable
bind:this={input} bind:this={input}

View File

@ -18,7 +18,7 @@
<button <button
class="flex cursor-pointer gap-2 border-solid border-gray-6 px-8 py-4 hover:border-b" class="flex cursor-pointer gap-2 border-solid border-gray-6 px-8 py-4 hover:border-b"
class:border-b={activeTab === tab} class:border-b={activeTab === tab}
on:click={() => setActiveTab(tab)}> on:click|preventDefault={() => setActiveTab(tab)}>
<div>{title}</div> <div>{title}</div>
{#if badge} {#if badge}
<div class="h-6 rounded-full bg-gray-6 px-2">{badge}</div> <div class="h-6 rounded-full bg-gray-6 px-2">{badge}</div>