From 9dc679a9443cb3698ad8b809ff1d67beb43f8de9 Mon Sep 17 00:00:00 2001 From: Jonathan Staab Date: Fri, 30 Dec 2022 15:52:29 -0800 Subject: [PATCH] Add mentions when composing a note or reply, tweak some feed timings --- README.md | 10 +- src/App.svelte | 35 +++---- src/partials/Badge.svelte | 10 ++ src/partials/Button.svelte | 2 + src/partials/Compose.svelte | 164 +++++++++++++++++++++++++++++++++ src/partials/Note.svelte | 43 ++++----- src/partials/Notes.svelte | 10 +- src/partials/Textarea.svelte | 5 +- src/relay/cmd.js | 13 ++- src/relay/db.js | 8 +- src/routes/Login.svelte | 4 +- src/routes/Logout.svelte | 29 ++++++ src/routes/NoteCreate.svelte | 24 +++-- src/routes/Notes.svelte | 8 -- src/util/html.js | 10 ++ src/util/misc.js | 2 +- src/views/notes/Network.svelte | 2 +- src/views/person/Notes.svelte | 2 +- 18 files changed, 296 insertions(+), 85 deletions(-) create mode 100644 src/partials/Compose.svelte create mode 100644 src/routes/Logout.svelte diff --git a/README.md b/README.md index 6b7c192c..8295ddc5 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,7 @@ If you like Coracle and want to support its development, you can donate sats via - [x] Notifications - [x] Link previews - [x] Add notes, follows, likes tab to profile -- [ ] Show relative dates -- [ ] Mentions - render done, now reference in compose +- [x] Mentions - [ ] Image uploads - [ ] An actual readme - [ ] Server discovery and relay publishing - https://github.com/nostr-protocol/nips/pull/32/files @@ -38,6 +37,13 @@ If you like Coracle and want to support its development, you can donate sats via # Changelog +## 0.2.6 + +- [x] Add support for at-mentions +- [x] Improve cleanup on logout +- [x] Move add note button to be available everywhere +- [x] Fix reporting relay along with tags + ## 0.2.5 - [x] Batch load context for feeds diff --git a/src/App.svelte b/src/App.svelte index 4571d924..42daac0d 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -22,6 +22,7 @@ import Alerts from "src/routes/Alerts.svelte" import Notes from "src/routes/Notes.svelte" import Login from "src/routes/Login.svelte" + import Logout from "src/routes/Logout.svelte" import Profile from "src/routes/Profile.svelte" import Settings from "src/routes/Settings.svelte" import Keys from "src/routes/Keys.svelte" @@ -45,26 +46,6 @@ let suspendedSubs = [] let mostRecentAlert = $alerts.since - const logout = async () => { - const $connections = get(connections) - const $settings = get(settings) - - localStorage.clear() - - // Keep relays around - await relay.db.events.clear() - await relay.db.tags.clear() - - // Remember the user's relay selection and settings - connections.set($connections) - settings.set($settings) - - // do a hard refresh so everything gets totally cleared - setTimeout(() => { - window.location = '/login' - }, 100) - } - onMount(() => { // Close menu on click outside document.querySelector("html").addEventListener("click", e => { @@ -148,6 +129,7 @@ + @@ -202,7 +184,7 @@
  • - + Logout
  • @@ -228,6 +210,17 @@ {/if} + {#if $user} +
    + + + +
    + {/if} + {#if $modal}
    +{#if inert} + +
    + {person.name || person.pubkey.slice(0, 8)} + +{:else} {person.name || person.pubkey.slice(0, 8)} +{/if} diff --git a/src/partials/Button.svelte b/src/partials/Button.svelte index dcf3d3a0..ae882247 100644 --- a/src/partials/Button.svelte +++ b/src/partials/Button.svelte @@ -3,10 +3,12 @@ import {switcher} from "hurdak/lib/hurdak" export let theme = "default" + export let disabled = false const className = cx( $$props.class, "py-2 px-4 rounded cursor-pointer", + {'text-light': disabled}, switcher(theme, { default: "bg-white text-accent", accent: "text-white bg-accent", diff --git a/src/partials/Compose.svelte b/src/partials/Compose.svelte new file mode 100644 index 00000000..7964e1c8 --- /dev/null +++ b/src/partials/Compose.svelte @@ -0,0 +1,164 @@ + + +
    +
    + +
    +{#each suggestions as person, i (person.pubkey)} +
    pickSuggestion(person)}> + +
    +{/each} diff --git a/src/partials/Note.svelte b/src/partials/Note.svelte index 661cea59..1b8ded60 100644 --- a/src/partials/Note.svelte +++ b/src/partials/Note.svelte @@ -12,6 +12,7 @@ import {settings, modal} from "src/state/app" import {formatTimestamp} from 'src/util/misc' import Badge from "src/partials/Badge.svelte" + import Compose from "src/partials/Compose.svelte" import Card from "src/partials/Card.svelte" import relay, {user} from 'src/relay' @@ -76,26 +77,21 @@ const startReply = () => { if ($user) { - reply = reply || '' + reply = reply || true } else { navigate('/login') } } const sendReply = () => { - if (reply) { - relay.cmd.createReply(reply, note) + const {content, mentions} = reply.parse() + + if (content) { + relay.cmd.createReply(note, content, mentions) reply = null } } - - const onReplyKeyDown = e => { - if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) { - e.preventDefault() - sendReply() - } - } -{#if reply !== null} +{#if reply}
    -