Slightly improve anonymous usage

This commit is contained in:
Jonathan Staab 2023-02-15 16:08:17 -06:00
parent 7dbb69e54a
commit 25511fdde4
6 changed files with 44 additions and 38 deletions

View File

@ -7,6 +7,7 @@
- [ ] Custom views should combine pubkeys, relays, event ids, and topics
- [ ] Fix anon/new user experience
- [ ] Clicking stuff that would publish kicks you to the login page, we should open a modal instead.
- [ ] Initial user load doesn't have any relays, cache user or wait for people db to be loaded
- [ ] Fix bugs on bugsnag

View File

@ -264,12 +264,12 @@
{/if}
</a>
</li>
{/if}
<li class="cursor-pointer">
<a class="block px-4 py-2 hover:bg-accent transition-all" href="/search/people">
<i class="fa-solid fa-search mr-2" /> Search
</a>
</li>
{/if}
<li class="cursor-pointer">
<a class="block px-4 py-2 hover:bg-accent transition-all" href="/notes/network">
<i class="fa-solid fa-tag mr-2" /> Notes
@ -284,6 +284,7 @@
{/if}
</a>
</li>
{/if}
<li class="h-px mx-3 my-4 bg-medium" />
<li class="cursor-pointer relative">
<a class="block px-4 py-2 hover:bg-accent transition-all" href="/relays">
@ -293,6 +294,7 @@
{/if}
</a>
</li>
{#if $user}
<li class="cursor-pointer">
<a class="block px-4 py-2 hover:bg-accent transition-all" href="/keys">
<i class="fa-solid fa-key mr-2" /> Keys

View File

@ -308,7 +308,7 @@ const onReady = cb => {
const unsub = ready.subscribe($ready => {
if ($ready) {
cb()
unsub()
setTimeout(() => unsub())
}
})
}

View File

@ -270,8 +270,6 @@ const subscribeUntilEose = async (
const now = Date.now()
const eose = new Set()
let closed = true
const attemptToComplete = () => {
// If we've already unsubscribed we're good
if (!agg.isActive()) {

View File

@ -3,7 +3,6 @@
import {onDestroy} from 'svelte'
import {navigate} from 'svelte-routing'
import {waitFor} from 'hurdak/lib/hurdak'
import Content from 'src/partials/Content.svelte'
import Input from 'src/partials/Input.svelte'
import Anchor from 'src/partials/Anchor.svelte'
import Spinner from 'src/partials/Spinner.svelte'
@ -46,33 +45,31 @@
})
</script>
<Content>
{#if mode === 'input'}
<div class="flex gap-2">
<Input placeholder="nprofile..." bind:value={value} wrapperClass="flex-grow" />
<Anchor type="button" on:click={() => goToEntity(value)}>
<i class="fa fa-arrow-right" />
</Anchor>
<Anchor type="button" on:click={() => setMode('scan')}>
<i class="fa fa-camera" />
</Anchor>
</div>
<div class="text-center text-light">
Enter any nostr identifier (npub, nevent, nprofile or note), or click on the
camera icon to scan with your device's camera instead.
</div>
{:else}
{#if !ready}
<Spinner>
Loading your camera...
</Spinner>
{/if}
<video bind:this={video} />
{#if ready}
<Anchor type="unstyled" class="flex gap-2 items-center" on:click={() => setMode('input')}>
<i class="fa fa-arrow-left" />
<span class="underline">Go back</span>
</Anchor>
{/if}
{#if mode === 'input'}
<div class="flex gap-2">
<Input placeholder="nprofile..." bind:value={value} wrapperClass="flex-grow" />
<Anchor type="button" on:click={() => goToEntity(value)}>
<i class="fa fa-arrow-right" />
</Anchor>
<Anchor type="button" on:click={() => setMode('scan')}>
<i class="fa fa-qrcode" />
</Anchor>
</div>
<div class="text-center text-light">
Enter any nostr identifier (npub, nevent, nprofile or note), or click on the
camera icon to scan with your device's camera instead.
</div>
{:else}
{#if !ready}
<Spinner>
Loading your camera...
</Spinner>
{/if}
</Content>
<video bind:this={video} />
{#if ready}
<Anchor type="unstyled" class="flex gap-2 items-center" on:click={() => setMode('input')}>
<i class="fa fa-arrow-left" />
<span class="underline">Go back</span>
</Anchor>
{/if}
{/if}

View File

@ -1,16 +1,24 @@
<script>
import {fuzzy} from "src/util/misc"
import {personKinds} from "src/util/nostr"
import Input from "src/partials/Input.svelte"
import PersonInfo from 'src/partials/PersonInfo.svelte'
import {user} from 'src/agent/helpers'
import {user, getUserRelays} from 'src/agent/helpers'
import database from 'src/agent/database'
import network from 'src/agent/network'
let q
let search
database.people.iter({'name:!nil': null}).then(people => {
search = fuzzy(people, {keys: ["name", "about", "pubkey"]})
database.watch('people', people => {
search = fuzzy(
people.all({'name:!nil': null}),
{keys: ["name", "about", "pubkey"]}
)
})
// Prime our database, in case we don't have any people stored yet
network.listenUntilEose(getUserRelays(), {kinds: personKinds, limit: 300})
</script>
<Input bind:value={q} placeholder="Search for people">
@ -18,7 +26,7 @@
</Input>
{#each (search ? search(q) : []).slice(0, 30) as person (person.pubkey)}
{#if person.pubkey !== $user.pubkey}
{#if person.pubkey !== $user?.pubkey}
<PersonInfo {person} />
{/if}
{/each}