refine relay page
This commit is contained in:
parent
96f22b9553
commit
9834a31511
2 changed files with 51 additions and 13 deletions
|
|
@ -52,7 +52,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.card2 {
|
.card2 {
|
||||||
@apply overflow-hidden text-ellipsis rounded-box bg-base-100 p-6 text-base-content;
|
@apply text-ellipsis rounded-box bg-base-100 p-6 text-base-content;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card2.card2-sm {
|
.card2.card2-sm {
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,29 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {onMount} from "svelte"
|
import {onMount} from "svelte"
|
||||||
import {readable} from "svelte/store"
|
import {derived} from "svelte/store"
|
||||||
|
import {uniq} from "@welshman/lib"
|
||||||
import {displayRelayUrl} from "@welshman/util"
|
import {displayRelayUrl} from "@welshman/util"
|
||||||
import {relaySearch} from "@welshman/app"
|
import {relaySearch, getRelayUrls, userRelaySelections, userInboxRelaySelections, getReadRelayUrls, getWriteRelayUrls} from "@welshman/app"
|
||||||
import Button from "@lib/components/Button.svelte"
|
import Button from "@lib/components/Button.svelte"
|
||||||
import Icon from "@lib/components/Icon.svelte"
|
import Icon from "@lib/components/Icon.svelte"
|
||||||
import {INDEXER_RELAYS, discoverRelays} from "@app/state"
|
import {INDEXER_RELAYS, discoverRelays} from "@app/state"
|
||||||
|
|
||||||
const relays = readable(INDEXER_RELAYS)
|
const readRelayUrls = derived(userRelaySelections, getReadRelayUrls)
|
||||||
|
const writeRelayUrls = derived(userRelaySelections, getWriteRelayUrls)
|
||||||
|
const inboxRelayUrls = derived(userInboxRelaySelections, getRelayUrls)
|
||||||
|
|
||||||
const removeRelay = (url: string) => null
|
const removeRelay = (url: string) => null
|
||||||
|
|
||||||
const addRelay = (url: string) => null
|
const addRelay = (url: string) => null
|
||||||
|
|
||||||
let term = ""
|
let term = ""
|
||||||
|
let currentRelayUrls: string[] = []
|
||||||
|
|
||||||
|
$: currentRelayUrls = uniq([
|
||||||
|
...currentRelayUrls,
|
||||||
|
...getRelayUrls($userRelaySelections),
|
||||||
|
...getRelayUrls($userInboxRelaySelections),
|
||||||
|
]).sort()
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
const sub = discoverRelays()
|
const sub = discoverRelays()
|
||||||
|
|
@ -25,22 +35,50 @@
|
||||||
<div class="content column gap-4">
|
<div class="content column gap-4">
|
||||||
<h1 class="superheading mt-20">Relays</h1>
|
<h1 class="superheading mt-20">Relays</h1>
|
||||||
<p class="text-center">Get connected with the nostr network</p>
|
<p class="text-center">Get connected with the nostr network</p>
|
||||||
{#each $relays as url}
|
{#each currentRelayUrls as url}
|
||||||
<div class="card2 card2-sm flex items-center justify-between">
|
{@const read = $readRelayUrls.includes(url)}
|
||||||
<div class="flex items-center gap-2">
|
{@const write = $writeRelayUrls.includes(url)}
|
||||||
<Icon icon="remote-controller-minimalistic" />
|
{@const inbox = $inboxRelayUrls.includes(url)}
|
||||||
{displayRelayUrl(url)}
|
<div class="card2 card2-sm flex flex-col gap-2 overflow-visible">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<Icon icon="remote-controller-minimalistic" />
|
||||||
|
{displayRelayUrl(url)}
|
||||||
|
</div>
|
||||||
|
<Button class="flex items-center" on:click={() => removeRelay(url)}>
|
||||||
|
<Icon icon="close-circle" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div class="flex gap-3">
|
||||||
|
<div
|
||||||
|
class="tooltip tooltip-right"
|
||||||
|
data-tip="Notes for you will {read ? '' : 'not'} be sent here.">
|
||||||
|
<Button class="btn btn-sm btn-{read ? 'primary' : 'neutral'}">
|
||||||
|
Read
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="tooltip tooltip-right"
|
||||||
|
data-tip="Notes you publish will {write ? '' : 'not'} be sent here.">
|
||||||
|
<Button class="btn btn-sm btn-{write ? 'primary' : 'neutral'}">
|
||||||
|
Write
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="tooltip tooltip-right"
|
||||||
|
data-tip="Direct messages will {inbox ? '' : 'not'} be sent here.">
|
||||||
|
<Button class="btn btn-sm btn-{inbox ? 'primary' : 'neutral'}">
|
||||||
|
Inbox
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Button class="flex items-center" on:click={() => removeRelay(url)}>
|
|
||||||
<Icon icon="close-circle" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
<label class="input input-bordered flex w-full items-center gap-2">
|
<label class="input input-bordered flex w-full items-center gap-2">
|
||||||
<Icon icon="magnifer" />
|
<Icon icon="magnifer" />
|
||||||
<input bind:value={term} class="grow" type="text" placeholder="Search for relays..." />
|
<input bind:value={term} class="grow" type="text" placeholder="Search for relays..." />
|
||||||
</label>
|
</label>
|
||||||
{#each $relaySearch.searchValues(term).filter(url => !$relays.includes(url)) as url (url)}
|
{#each $relaySearch.searchValues(term).filter(url => !currentRelayUrls.includes(url)) as url (url)}
|
||||||
<div class="card2 card2-sm flex items-center justify-between">
|
<div class="card2 card2-sm flex items-center justify-between">
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<Icon icon="remote-controller-minimalistic" />
|
<Icon icon="remote-controller-minimalistic" />
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue