Improve initial load using purplepag.es

This commit is contained in:
Jonathan Staab 2023-04-20 10:47:35 -05:00
parent 282c036fa5
commit 3e1b0cb9fe
5 changed files with 21 additions and 19 deletions

View File

@ -1,5 +1,10 @@
# Changelog
# 0.2.25
- [x] Add purplepag.es to sign in flow
- [x] Include people with only a display_name in search
## 0.2.24
- [x] Replace localforage with loki.js for storage

View File

@ -1,7 +1,6 @@
# Current
- [ ] Remember message/chat status
- [ ] Add purplepag.es to sign in flow
- [ ] Add way to turn off likes/zaps
- [ ] Improve AUTH status display
- [ ] Image classification

View File

@ -95,10 +95,10 @@ const Meta = {
const forceUrls = (import.meta.env.VITE_FORCE_RELAYS || "").split(",").filter(identity)
const defaultUrls = [
"wss://purplepag.es",
"wss://relay.damus.io",
"wss://relay.nostr.band",
"wss://nostr-pub.wellorder.net",
"wss://nostr.zebedee.cloud",
"wss://nos.lol",
"wss://brb.io",
]
const getUrls = relays => {

View File

@ -25,15 +25,7 @@ import user from "src/agent/user"
export const initializeRelayList = async () => {
// Throw some hardcoded defaults in there
await relays.patch([
{url: "wss://brb.io"},
{url: "wss://nostr.zebedee.cloud"},
{url: "wss://nostr-pub.wellorder.net"},
{url: "wss://relay.nostr.band"},
{url: "wss://nostr.pleb.network"},
{url: "wss://relay.nostrich.de"},
{url: "wss://relay.damus.io"},
])
await relays.patch(pool.defaultUrls.map(objOf("url")))
// Load relays from nostr.watch via dufflepud
try {

View File

@ -1,6 +1,6 @@
<script lang="ts">
import type {Relay} from "src/util/types"
import {isNil, find, all, last} from "ramda"
import {isNil, prop, uniqBy, objOf, find, all, last} from "ramda"
import {onDestroy, onMount} from "svelte"
import {navigate} from "svelte-routing"
import {sleep, shuffle} from "src/util/misc"
@ -25,8 +25,14 @@
let currentRelays = {} as Record<number, Relay>
let attemptedRelays = new Set()
let customRelays = []
let knownRelays = watch("relays", table => shuffle(table.all()))
let allRelays = []
let knownRelays = watch("relays", table =>
uniqBy(
prop("url"),
// Make sure our hardcoded urls are first, since they're more likely to find a match
pool.defaultUrls.map(objOf("url")).concat(shuffle(table.all()))
)
)
$: allRelays = $knownRelays.concat(customRelays)
@ -57,13 +63,13 @@
currentRelays[i] = null
// Make sure we have relays and follows before calling it good. This helps us avoid
// nuking follow lists later on
if (searching && user.getRelays().length > 0 && user.getPetnames().length > 0) {
if (searching && user.getRelays().length > 0) {
searching = false
modal = "success"
await Promise.all([loadAppData(user.getPubkey()), sleep(3000)])
// Reload everything, it's possible we didn't get their petnames if we got a match
// from something like purplepag.es. This helps us avoid nuking follow lists later
await Promise.all([loadAppData(user.getPubkey()), sleep(1500)])
navigate("/notes")
} else {