import { LitElement, html, css } from "lit"; import { repeat } from "lit/directives/repeat.js"; import "./components/nsite-card.js"; import { pool, relays } from "./pool.js"; export class NsiteApp extends LitElement { static properties = { selected: { state: true }, status: { state: true, type: String }, sites: { state: true, type: Array }, }; static styles = css` .sites { display: flex; gap: 0.5em; flex-wrap: wrap; } `; seen = new Set(); constructor() { super(); this.sites = []; } connectedCallback() { super.connectedCallback(); pool.subscribeMany(relays, [{ kinds: [34128], "#d": ["/index.html"] }], { onevent: (event) => { if (this.seen.has(event.pubkey)) return; this.seen.add(event.pubkey); this.sites = [...this.sites, event].sort((a, b) => b.created_at - a.created_at); }, }); } render() { return html`