2023-06-30 14:05:57 +00:00
|
|
|
/** @jsx h */
|
|
|
|
import { h, render } from "https://esm.sh/preact@10.11.3";
|
|
|
|
import { sleep } from "https://raw.githubusercontent.com/BlowaterNostr/csp/master/csp.ts";
|
|
|
|
import { EventBus } from "../event-bus.ts";
|
|
|
|
import { UI_Interaction_Event } from "./app_update.ts";
|
|
|
|
import { RelaySetting } from "./setting.tsx";
|
|
|
|
import { ConnectionPool } from "https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/relay.ts";
|
2023-07-11 09:19:57 +00:00
|
|
|
import { defaultRelays } from "./setting.ts";
|
2023-06-30 14:05:57 +00:00
|
|
|
|
|
|
|
const pool = new ConnectionPool();
|
2023-07-11 09:19:57 +00:00
|
|
|
pool.addRelayURLs(defaultRelays).then((errs) => {
|
2023-06-30 14:05:57 +00:00
|
|
|
if (errs) {
|
|
|
|
console.log(errs);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const bus = new EventBus<UI_Interaction_Event>();
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
render(
|
|
|
|
<RelaySetting
|
|
|
|
err=""
|
|
|
|
eventBus={bus}
|
|
|
|
input=""
|
|
|
|
relays={pool.getRelays().map((r) => ({
|
|
|
|
status: r.ws.status(),
|
|
|
|
url: r.url,
|
|
|
|
}))}
|
|
|
|
/>,
|
|
|
|
document.body,
|
|
|
|
);
|
|
|
|
await sleep(100); // 10 FPS
|
|
|
|
}
|