From dbbbec4d07b96aa30951fe62d90fa31294ca6868 Mon Sep 17 00:00:00 2001 From: Jonathan Staab Date: Thu, 6 Apr 2023 17:56:02 -0500 Subject: [PATCH] Try opening feeds filtered by relay in a modal --- ROADMAP.md | 9 +-- src/App.svelte | 10 ++- src/agent/relays.ts | 2 +- src/agent/tables.ts | 1 + src/app/ui.ts | 4 +- src/partials/Modal.svelte | 10 +++ src/partials/Popover.svelte | 2 + src/routes/Bech32Entity.svelte | 4 +- src/routes/RelayDetail.svelte | 5 +- src/util/misc.ts | 9 +-- src/views/feed/Feed.svelte | 77 +++++++++++------------- src/views/feed/RelayFeed.svelte | 39 ++++++++++++ src/views/notes/ForegroundButtons.svelte | 1 - src/views/notes/Note.svelte | 39 +++++++++--- src/views/notes/NoteDetail.svelte | 22 ++++++- src/views/relays/RelayActions.svelte | 56 +++++++++++++++++ src/views/relays/RelayJoin.svelte | 36 ----------- src/views/relays/RelayTitle.svelte | 11 +++- 18 files changed, 230 insertions(+), 107 deletions(-) create mode 100644 src/views/feed/RelayFeed.svelte create mode 100644 src/views/relays/RelayActions.svelte delete mode 100644 src/views/relays/RelayJoin.svelte diff --git a/ROADMAP.md b/ROADMAP.md index 84674e7c..7c736333 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,13 +1,14 @@ # Current -- [ ] Fix scrolling with embedded modals by registering open modals in the component - [ ] Relays bounty - [x] Ability to click into a relay's global feed - - [ ] Ability to filter feeds by relay - - Global Mutes? Global Whitelist? - - Open in modal with "here's what this feed would look like with only this relay" + - [x] Ability to filter feeds by relay + - [-] Global Mutes? Global Whitelist? + - [x] Open in modal with "here's what this feed would look like with only this relay" + - [ ] Fix scrolling with embedded modals by registering open modals in the component - [ ] Ability to create custom feeds - [ ] Fix tag-style event mentions. Probably transform all mentions into entities in parse +- [ ] Some lnurls aren't working npub1y3k2nheva29y9ej8a22e07epuxrn04rvgy28wvs54y57j7vsxxuq0gvp4j - [ ] Fix performance issues - [ ] https://github.com/techfort/LokiJS - Use indexed adapter github.com/techfort/LokiJS/blob/master/tutorials/Persistence%20Adapters.md and partitioning adapter diff --git a/src/App.svelte b/src/App.svelte index 35fbb5d1..b5386f63 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -24,7 +24,7 @@ import user from "src/agent/user" import {loadAppData} from "src/app" import {theme, getThemeVariables} from "src/app/ui" - import {modal, routes, menuIsOpen, logUsage} from "src/app/ui" + import {modal, openModals, routes, menuIsOpen, logUsage} from "src/app/ui" import Anchor from "src/partials/Anchor.svelte" import Content from "src/partials/Content.svelte" import Modal from "src/partials/Modal.svelte" @@ -97,11 +97,16 @@ } onMount(() => { - // Keep scroll position on body, but don't allow scrolling + // Log modals const unsubModal = modal.subscribe($modal => { if ($modal) { logUsage(btoa(["modal", $modal.type].join(":"))) + } + }) + // Keep scroll position on body, but don't allow scrolling + const unsubOpenModals = openModals.subscribe(n => { + if (n > 0) { // This is not idempotent, so don't duplicate it if (document.body.style.position !== "fixed") { scrollY = window.scrollY @@ -133,6 +138,7 @@ return () => { unsubHistory() unsubModal() + unsubOpenModals() } }) diff --git a/src/agent/relays.ts b/src/agent/relays.ts index 36261556..6450dfa1 100644 --- a/src/agent/relays.ts +++ b/src/agent/relays.ts @@ -118,7 +118,7 @@ export const getRelaysForEventParent = event => { // to read from the current user's network's read relays instead. export const getRelaysForEventChildren = event => { return uniqByUrl( - getPubkeyReadRelays(event.pubkey).concat(event.seen_on.map(url => ({url, score: 1}))) + getPubkeyReadRelays(event.pubkey).concat((event.seen_on || []).map(url => ({url, score: 1}))) ) } diff --git a/src/agent/tables.ts b/src/agent/tables.ts index ecd6ccad..a7179f18 100644 --- a/src/agent/tables.ts +++ b/src/agent/tables.ts @@ -36,6 +36,7 @@ export const routes = new Table("routes", "id", { listener.connect() export const getPersonWithFallback = pubkey => people.get(pubkey) || {pubkey} +export const getRelayWithFallback = url => relays.get(url) || {url} const ready = derived(pluck("ready", Object.values(registry)), all(identity)) diff --git a/src/app/ui.ts b/src/app/ui.ts index c88c2f0b..aaec96b7 100644 --- a/src/app/ui.ts +++ b/src/app/ui.ts @@ -6,7 +6,7 @@ import {navigate} from "svelte-routing" import {nip19} from "nostr-tools" import {writable, get} from "svelte/store" import {globalHistory} from "svelte-routing/src/history" -import {sleep, WritableList, synced, hash} from "src/util/misc" +import {sleep, synced, hash} from "src/util/misc" import {warn} from "src/util/logger" import user from "src/agent/user" @@ -48,6 +48,8 @@ export const menuIsOpen = writable(false) // Modals +export const openModals = writable(0) + export const modal = { history: [], set: data => { diff --git a/src/partials/Modal.svelte b/src/partials/Modal.svelte index ee356c1a..b6b0c32d 100644 --- a/src/partials/Modal.svelte +++ b/src/partials/Modal.svelte @@ -1,9 +1,19 @@ { instance = tippy(trigger, { theme, + arrow, placement: placement as Placement, appendTo: () => document.body, allowHTML: true, diff --git a/src/routes/Bech32Entity.svelte b/src/routes/Bech32Entity.svelte index 9792e67a..182eaf66 100644 --- a/src/routes/Bech32Entity.svelte +++ b/src/routes/Bech32Entity.svelte @@ -1,5 +1,5 @@ + + +
+ + +
+ {#if feedRelay.description} +

{feedRelay.description}

+ {/if} +

+ + Below is your current feed including only notes seen on {displayRelay(feedRelay)} +

+ +
+ + {#each filteredNotes.length > 0 ? filteredNotes : notes as note (note.id)} + + {/each} +
+ + +
diff --git a/src/views/notes/ForegroundButtons.svelte b/src/views/notes/ForegroundButtons.svelte index 863757d4..ab56109b 100644 --- a/src/views/notes/ForegroundButtons.svelte +++ b/src/views/notes/ForegroundButtons.svelte @@ -1,5 +1,4 @@ + +{#if actions.length > 0} + {#if actions.length === 1} + + + + +

{actions[0].label}

+
+ {:else} + + {/if} +{/if} diff --git a/src/views/relays/RelayJoin.svelte b/src/views/relays/RelayJoin.svelte deleted file mode 100644 index c7529ba0..00000000 --- a/src/views/relays/RelayJoin.svelte +++ /dev/null @@ -1,36 +0,0 @@ - - -
- {#if relay.contact} - - - - {/if} - {#if joined} - {#if $userRelays.length > 1} - user.removeRelay(relay.url)}> - Leave - - {/if} - {:else} - user.addRelay(relay.url)}> - Join - - {/if} -
diff --git a/src/views/relays/RelayTitle.svelte b/src/views/relays/RelayTitle.svelte index c18dd50c..b9addafe 100644 --- a/src/views/relays/RelayTitle.svelte +++ b/src/views/relays/RelayTitle.svelte @@ -3,7 +3,8 @@ import {between} from "hurdak/lib/hurdak" import {displayRelay} from "src/util/nostr" import {poll, stringToHue, hsl} from "src/util/misc" - import pool from 'src/agent/pool' + import Anchor from "src/partials/Anchor.svelte" + import pool from "src/agent/pool" export let relay @@ -20,9 +21,13 @@
- + {displayRelay(relay)} - + { showStatus = false