From 7dd6edaac5715655facc5f5201103478279feb88 Mon Sep 17 00:00:00 2001 From: Jonathan Staab Date: Mon, 12 Jun 2023 17:57:03 -0700 Subject: [PATCH] Add advanced search --- ROADMAP.md | 3 + src/agent/network.ts | 6 +- src/app/App.svelte | 2 +- src/app/shared/Feed.svelte | 92 +++++++++++++++------ src/app/shared/FeedAdvanced.svelte | 125 +++++++++++++++++++++++++++++ src/app/shared/NoteContent.svelte | 15 ++-- src/app/views/TopicFeed.svelte | 2 +- src/partials/Anchor.svelte | 4 +- src/partials/Button.svelte | 2 +- src/partials/Input.svelte | 5 +- src/partials/Modal.svelte | 27 +++++-- src/partials/MultiSelect.svelte | 2 +- src/partials/Suggestions.svelte | 2 +- src/util/misc.ts | 4 + 14 files changed, 240 insertions(+), 51 deletions(-) create mode 100644 src/app/shared/FeedAdvanced.svelte diff --git a/ROADMAP.md b/ROADMAP.md index 35ee514a..1f92b5da 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -15,6 +15,9 @@ - https://github.com/bhky/opennsfw2 - [ ] Private groups using nsec bunker - [ ] Fix unauthenticated experience. Going to an npub just spins +- [ ] Convert app store to nip 89 +- [ ] Put search icon in header or hover button, open in modal +- [ ] Advanced search # Core diff --git a/src/agent/network.ts b/src/agent/network.ts index 72f2d514..406a7d04 100644 --- a/src/agent/network.ts +++ b/src/agent/network.ts @@ -125,12 +125,12 @@ class Cursor { until: Record since: number seen: Set - constructor({relays, limit = 20, delta = undefined}) { + constructor({relays, limit = 20, delta = undefined, until = now()}) { this.relays = relays this.limit = limit this.delta = delta - this.until = fromPairs(relays.map(({url}) => [url, now()])) - this.since = delta ? now() : 0 + this.until = fromPairs(relays.map(({url}) => [url, until])) + this.since = 0 this.seen = new Set() } async loadPage({filter, onChunk}) { diff --git a/src/app/App.svelte b/src/app/App.svelte index 2bac80c6..dca76c03 100644 --- a/src/app/App.svelte +++ b/src/app/App.svelte @@ -65,7 +65,7 @@ // Log modals, keep scroll position on body, but don't allow scrolling const unsubModal = modal.stack.subscribe($stack => { - if ($stack.length > 0) { + if ($stack.filter(x => !x.mini).length > 0) { logUsage(btoa(["modal", last($stack).type].join(":"))) // This is not idempotent, so don't duplicate it diff --git a/src/app/shared/Feed.svelte b/src/app/shared/Feed.svelte index b4835b06..2fca4440 100644 --- a/src/app/shared/Feed.svelte +++ b/src/app/shared/Feed.svelte @@ -1,13 +1,16 @@ @@ -150,8 +192,10 @@ {/if} + +
- {#each notes as note (note.id)} + {#each filteredNotes as note (note.id)} {/each}
diff --git a/src/app/shared/FeedAdvanced.svelte b/src/app/shared/FeedAdvanced.svelte new file mode 100644 index 00000000..b574dc91 --- /dev/null +++ b/src/app/shared/FeedAdvanced.svelte @@ -0,0 +1,125 @@ + + +
+ {modal = modal ? null : 'mini'}} /> + +
+ +{#if modal} + + +
+ Search + + + +
+ {#if modal === 'maxi'} +
+
+ Since + +
+
+ Until + +
+
+ {#if !hide.includes('authors')} +
+ Authors + +
+
+ +
+
+
+
+ {/if} + {#if !hide.includes('#t')} +
+ Topics + +
+
+ #{item.name} +
+
+
+
+ {/if} + {#if !hide.includes('#p')} +
+ Mentions + +
+
+ +
+
+
+
+ {/if} +
+ Apply Filters +
+ {/if} +
+
+{/if} diff --git a/src/app/shared/NoteContent.svelte b/src/app/shared/NoteContent.svelte index 8913f839..335752d5 100644 --- a/src/app/shared/NoteContent.svelte +++ b/src/app/shared/NoteContent.svelte @@ -1,6 +1,5 @@ diff --git a/src/partials/Anchor.svelte b/src/partials/Anchor.svelte index b861a885..70d1a3ee 100644 --- a/src/partials/Anchor.svelte +++ b/src/partials/Anchor.svelte @@ -26,13 +26,13 @@ switcher(type, { anchor: "underline", button: - "py-2 px-4 rounded bg-input text-accent whitespace-nowrap border border-solid border-gray-6 hover:bg-input-hover", + "py-2 px-4 rounded-full bg-input text-accent whitespace-nowrap border border-solid border-gray-6 hover:bg-input-hover", "button-circle": "w-10 h-10 flex justify-center items-center rounded-full bg-input text-accent whitespace-nowrap border border-solid border-gray-6 hover:bg-input-hover", "button-circle-dark": "w-10 h-10 flex justify-center items-center rounded-full bg-gray-8 text-white whitespace-nowrap border border-solid border-gray-7", "button-accent": - "py-2 px-4 rounded bg-accent text-white whitespace-nowrap border border-solid border-accent-light hover:bg-accent-light", + "py-2 px-4 rounded-full bg-accent text-white whitespace-nowrap border border-solid border-accent-light hover:bg-accent-light", }) ) diff --git a/src/partials/Button.svelte b/src/partials/Button.svelte index 575803d5..8bc5696a 100644 --- a/src/partials/Button.svelte +++ b/src/partials/Button.svelte @@ -7,7 +7,7 @@ const className = cx( $$props.class, - "py-2 px-4 rounded cursor-pointer border border-solid transition-all", + "py-2 px-4 rounded-full cursor-pointer border border-solid transition-all", {"text-gray-5": disabled}, switcher(theme, { default: "bg-input text-accent border-gray-6 hover:bg-input-hover", diff --git a/src/partials/Input.svelte b/src/partials/Input.svelte index f5ad3415..57a92348 100644 --- a/src/partials/Input.svelte +++ b/src/partials/Input.svelte @@ -7,7 +7,7 @@ const className = cx( $$props.class, - "rounded shadow-inset py-2 px-4 pr-10 w-full placeholder:text-gray-5", + "rounded-full shadow-inset py-2 px-4 w-full placeholder:text-gray-5", "bg-input border border-solid border-gray-3 text-black", {"pl-10": $$slots.before, "pr-10": $$slots.after} ) @@ -21,7 +21,8 @@ {/if} {#if $$slots.after} -
+
{/if} diff --git a/src/partials/Modal.svelte b/src/partials/Modal.svelte index 91c5896c..45e605fe 100644 --- a/src/partials/Modal.svelte +++ b/src/partials/Modal.svelte @@ -4,6 +4,7 @@ import {fly, fade} from "svelte/transition" import {modal} from "src/partials/state" + export let mini = false export let index = null export let virtual = true export let isOnTop = true @@ -19,7 +20,7 @@ onMount(() => { if (virtual) { - modal.push({id, virtual: true}) + modal.push({id, mini, virtual: true}) } }) @@ -37,17 +38,27 @@ } }} /> -