This commit is contained in:
Jonathan Staab 2023-08-04 14:30:33 -07:00
parent e0b745b364
commit e84691e459
9 changed files with 21 additions and 42 deletions

View File

@ -53,7 +53,7 @@
"marked": "^5.1.0", "marked": "^5.1.0",
"nostr-tools": "^1.12.1", "nostr-tools": "^1.12.1",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"paravel": "^0.2.1", "paravel": "^0.2.2",
"qr-scanner": "^1.4.2", "qr-scanner": "^1.4.2",
"qrcode": "^1.5.1", "qrcode": "^1.5.1",
"ramda": "^0.28.0", "ramda": "^0.28.0",

View File

@ -3,6 +3,7 @@
import "@fortawesome/fontawesome-free/css/solid.css" import "@fortawesome/fontawesome-free/css/solid.css"
import type {ComponentType, SvelteComponentTyped} from "svelte" import type {ComponentType, SvelteComponentTyped} from "svelte"
import {nip19} from "nostr-tools"
import type {Relay} from "src/engine" import type {Relay} from "src/engine"
import {onMount} from "svelte" import {onMount} from "svelte"
import {Router, links} from "svelte-routing" import {Router, links} from "svelte-routing"
@ -69,7 +70,7 @@
const TypedRouter = Router as ComponentType<SvelteComponentTyped> const TypedRouter = Router as ComponentType<SvelteComponentTyped>
Object.assign(window, {...engine, user, bech32ToHex, hexToBech32}) Object.assign(window, {...engine, nip19, user, bech32ToHex, hexToBech32})
export let pathname = location.pathname export let pathname = location.pathname
export let hash = location.hash export let hash = location.hash

View File

@ -8,7 +8,7 @@
import Card from "src/partials/Card.svelte" import Card from "src/partials/Card.svelte"
import Spinner from "src/partials/Spinner.svelte" import Spinner from "src/partials/Spinner.svelte"
import PersonCircle from "src/app/shared/PersonCircle.svelte" import PersonCircle from "src/app/shared/PersonCircle.svelte"
import {Directory, Nip65, user, Network} from "src/app/engine" import {Directory, Settings, Nip65, user, Network} from "src/app/engine"
export let note export let note
export let value export let value
@ -23,7 +23,10 @@
const sub = Network.subscribe({ const sub = Network.subscribe({
timeout: 5000, timeout: 5000,
relays: Nip65.mergeHints(3, [relays, Nip65.getEventHints(3, note)]), relays: Nip65.mergeHints(Settings.getSetting("relay_limit"), [
relays,
Nip65.getEventHints(3, note),
]),
filter: (id filter: (id
? {ids: [id]} ? {ids: [id]}
: filterVals(xs => xs.length > 0, { : filterVals(xs => xs.length > 0, {

View File

@ -39,6 +39,10 @@
}) })
} }
if (!isSelf && false) {
actions.push({onClick: loginAsUser, label: "Login as", icon: "right-to-bracket"})
}
if (Env.FORCE_RELAYS.length === 0) { if (Env.FORCE_RELAYS.length === 0) {
actions.push({onClick: openProfileInfo, label: "Details", icon: "info"}) actions.push({onClick: openProfileInfo, label: "Details", icon: "info"})
} }
@ -52,6 +56,8 @@
} }
} }
const loginAsUser = () => Keys.login("pubkey", pubkey)
const openProfileInfo = () => modal.push({type: "person/info", pubkey}) const openProfileInfo = () => modal.push({type: "person/info", pubkey})
const share = () => modal.push({type: "person/share", pubkey}) const share = () => modal.push({type: "person/share", pubkey})

View File

@ -1,5 +1,5 @@
<script> <script>
import {filter, slice, pluck, reverse, max, last, sortBy} from "ramda" import {filter, propEq, slice, pluck, reverse, max, last, sortBy} from "ramda"
import {onMount} from "svelte" import {onMount} from "svelte"
import {doPipe, batch, seconds} from "hurdak" import {doPipe, batch, seconds} from "hurdak"
import {fly} from "src/util/transition" import {fly} from "src/util/transition"
@ -33,7 +33,7 @@
return reverse( return reverse(
sortBy( sortBy(
e => formatTimestampAsLocalISODate(e.created_at).slice(0, 13) + findReplyId(e), e => formatTimestampAsLocalISODate(e.created_at).slice(0, 13) + findReplyId(e),
user.applyMutes($events) user.applyMutes($events.filter(propEq("recipient", Keys.pubkey.get())))
) )
) )
}) })

View File

@ -5,7 +5,7 @@ import type {Engine} from "src/engine/Engine"
import type {Event} from "src/engine/types" import type {Event} from "src/engine/types"
export class Alerts { export class Alerts {
events = collection<Event>("id") events = collection<Event & {recipient: string}>("id")
lastChecked = writable(0) lastChecked = writable(0)
latestNotification = this.events.derived(reduce((n, e) => Math.max(n, e.created_at), 0)) latestNotification = this.events.derived(reduce((n, e) => Math.max(n, e.created_at), 0))
hasNewNotfications = derived([this.lastChecked, this.latestNotification], ([c, n]) => n > c) hasNewNotfications = derived([this.lastChecked, this.latestNotification], ([c, n]) => n > c)
@ -28,7 +28,7 @@ export class Alerts {
return return
} }
Alerts.events.key(e.id).set(e) Alerts.events.key(e.id).set({...e, recipient: pubkey})
} }
noteKinds.forEach(kind => { noteKinds.forEach(kind => {

View File

@ -81,38 +81,7 @@ export class Network {
const executor = new Executor(target) const executor = new Executor(target)
executor.handleAuth({ executor.handleAuth({onAuth: this.authHandler})
onAuth: (url: string, challenge: string) => {
return this.authHandler?.(url, challenge)
},
onOk: (url: string, id: string, ok: boolean, message: string) => {
// Once we get a good auth response don't wait to send stuff to the relay
if (ok) {
this.pool.get(url)
this.pool.booted = true
}
},
})
// Eagerly connect and handle AUTH
executor.target.sockets.forEach((socket: any) => {
const {limitation} = this.engine.Nip65.getRelayInfo(socket.url)
const waitForBoot = limitation?.payment_required || limitation?.auth_required
// This happens automatically, but kick it off anyway
socket.connect()
// Delay REQ/EVENT until AUTH flow happens. Highly hacky, as this relies on
// overriding the `shouldDeferWork` property of the socket. We do it this way
// so that we're not blocking sending to all the other public relays
if (!bypassBoot && waitForBoot && socket.status === Socket.STATUS.PENDING) {
socket.shouldDeferWork = () => {
return socket.booted && socket.status !== Socket.STATUS.READY
}
setTimeout(() => Object.assign(socket, {booted: true}), 2000)
}
})
return executor return executor
} }

View File

@ -26,8 +26,8 @@
class="relative flex flex-col gap-2" class="relative flex flex-col gap-2"
on:click={() => instance.hide()}> on:click={() => instance.hide()}>
<div <div
class="absolute top-0 right-0 bottom-0 w-32 rounded-3xl bg-gray-8" class="absolute bottom-0 right-0 top-0 w-32 rounded-3xl bg-gray-8"
style="filter: blur(15px) opacity(0.75)" /> style="filter: blur(15px)" />
{#each actions as { label, icon, onClick }} {#each actions as { label, icon, onClick }}
<div class="relative z-10 cursor-pointer text-gray-2" on:click={onClick}> <div class="relative z-10 cursor-pointer text-gray-2" on:click={onClick}>
<span class="absolute right-0 mr-12 mt-2 whitespace-nowrap">{label}</span> <span class="absolute right-0 mr-12 mt-2 whitespace-nowrap">{label}</span>

BIN
yarn.lock

Binary file not shown.