Casual refactor of entire eventBuilder
This commit is contained in:
@ -5,11 +5,10 @@ import { randomSample, unixNowMs } from "Util";
|
||||
import Relay from "Element/Relay";
|
||||
import useEventPublisher from "Feed/EventPublisher";
|
||||
import { System } from "System";
|
||||
|
||||
import messages from "./messages";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import { setRelays } from "Login";
|
||||
|
||||
import messages from "./messages";
|
||||
const RelaySettingsPage = () => {
|
||||
const publisher = useEventPublisher();
|
||||
const login = useLogin();
|
||||
@ -21,16 +20,18 @@ const RelaySettingsPage = () => {
|
||||
}, [relays]);
|
||||
|
||||
async function saveRelays() {
|
||||
const ev = await publisher.saveRelays();
|
||||
publisher.broadcast(ev);
|
||||
publisher.broadcastForBootstrap(ev);
|
||||
try {
|
||||
const onlineRelays = await fetch("https://api.nostr.watch/v1/online").then(r => r.json());
|
||||
const settingsEv = await publisher.saveRelaysSettings();
|
||||
const rs = Object.keys(relays).concat(randomSample(onlineRelays, 20));
|
||||
publisher.broadcastAll(settingsEv, rs);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
if (publisher) {
|
||||
const ev = await publisher.contactList(login.follows.item, login.relays.item);
|
||||
publisher.broadcast(ev);
|
||||
publisher.broadcastForBootstrap(ev);
|
||||
try {
|
||||
const onlineRelays = await fetch("https://api.nostr.watch/v1/online").then(r => r.json());
|
||||
const relayList = await publisher.relayList(login.relays.item);
|
||||
const rs = Object.keys(relays).concat(randomSample(onlineRelays, 20));
|
||||
publisher.broadcastAll(relayList, rs);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user