diff --git a/README.md b/README.md index c4063f2c..0f520393 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,13 @@ # What is this? -Coracle is a web client for the Nostr protocol. While Nostr is useful for many things, Coracle focuses on providing a high-quality user experience. Check it out at [coracle.social](https://coracle.social). +Coracle is a web client for the Nostr protocol. While Nostr is useful for many things, Coracle focuses on providing a high-quality social media experience. Check it out at [coracle.social](https://coracle.social). [Dufflepud](https://github.com/staab/dufflepud) is a companion server which you can self-host. It helps Coracle with things like link previews and image uploads. Coracle is currently in _alpha_ - expect bugs, slow loading times, and rough edges. +If you like Coracle and want to support its development, you can donate sats via [Geyser](https://geyser.fund/project/coracle). + # Features - [x] Chat @@ -24,7 +26,6 @@ Coracle is currently in _alpha_ - expect bugs, slow loading times, and rough edg # Bugs -- [ ] Use https://nostr.watch/relays.json to populate relays - [ ] Add alerts for replies to posts the user liked - [ ] With link/image previews, remove the url from the note body if it's on a separate last line - [ ] Stack views so scroll position isn't lost on navigation @@ -32,23 +33,9 @@ Coracle is currently in _alpha_ - expect bugs, slow loading times, and rough edg - [ ] Wait for 60% or so of relays to eose to balance completeness with speed - [ ] Add a CSP, check for XSS in image urls -# Current update +# Changelog -- [ ] Write blog post -- [x] Sync user -- [x] Based on petnames, sync network to 2 or 3 degrees of separation - - When a user is added/removed, sync them and add to or remove from network -- [x] Add cursor object to handle since/until/last sync -- [x] Separate fetching and loading from the db - - Each route should have a fetcher and loader. - - The fetcher should keep track of the range of notes it has already gotten - - Separate helper functions into loaders and fetchers -- [x] Main fetch requests: - - Fetch feed by name, since last sync - - Fetch person, including feed - - Fetch note, including context - - This is based on detail pages. Each request should check local db and fall back to network, all within an await. +## 0.2.0 -# Problems to solve - -- [ ] How will newcomers get followed? +- [x] Completely re-worked data synchronization layer, moving from naive just-in-time requests to background listeners and a local copy stored in dexie. Events and tags, but not people are deleted from the database on logout, and old events are periodically purged. +- [x] diff --git a/src/App.svelte b/src/App.svelte index ea2f807e..6b82b1cc 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -10,9 +10,9 @@ import {Router, Route, links, navigate} from "svelte-routing" import {globalHistory} from "svelte-routing/src/history" import {hasParent} from 'src/util/html' - import {timedelta, now} from 'src/util/misc' + import {timedelta, getLastSync, now} from 'src/util/misc' import {store as toast} from "src/state/toast" - import {modal, alerts, settings} from "src/state/app" + import {modal, settings, alerts} from "src/state/app" import relay, {user, connections} from 'src/relay' import Anchor from 'src/partials/Anchor.svelte' import NoteDetail from "src/views/NoteDetail.svelte" @@ -43,31 +43,24 @@ let menuIcon let scrollY let suspendedSubs = [] - let mostRecentAlert = relay.lq(async () => { - const [e] = await relay.filterAlerts($user, 1) + let mostRecentAlert = $alerts.since - return e?.created_at - }) + const logout = async () => { + const $connections = get(connections) + const $settings = get(settings) - const logout = () => { - // Give any animations a moment to finish - setTimeout(() => { - const $connections = get(connections) - const $settings = get(settings) + localStorage.clear() - localStorage.clear() + // Keep relays around + await relay.db.events.clear() + await relay.db.tags.clear() - // Keep relays around - relay.db.events.clear() - relay.db.tags.clear() + // Remember the user's relay selection and settings + connections.set($connections) + settings.set($settings) - // Remember the user's relay selection and settings - connections.set($connections) - settings.set($settings) - - // Do a hard refresh so everything gets totally cleared - window.location = '/login' - }, 200) + // do a hard refresh so everything gets totally cleared + window.location = '/login' } onMount(() => { @@ -83,7 +76,13 @@ const unsubUser = user.subscribe($user => { if ($user && $user.pubkey !== prevPubkey) { relay.pool.syncNetwork() - relay.pool.listenForEvents('App/alerts', {'#p': [$user.pubkey], since: now()}) + relay.pool.listenForEvents( + 'App/alerts', + [{kinds: [1, 7], '#p': [$user.pubkey], since: mostRecentAlert}], + e => { + mostRecentAlert = Math.max(e.created_at, mostRecentAlert) + } + ) } prevPubkey = $user?.pubkey diff --git a/src/partials/Note.svelte b/src/partials/Note.svelte index 4491b16e..9c5d2175 100644 --- a/src/partials/Note.svelte +++ b/src/partials/Note.svelte @@ -16,6 +16,7 @@ export let note export let depth = 0 export let anchorId = null + export let showParent = true export let invertColors = false let reply = null @@ -117,7 +118,7 @@
{formatTimestamp(note.created_at)}