improve relay connection

This commit is contained in:
reya 2023-11-16 07:59:29 +07:00
parent 875225591a
commit b41ec353c6
5 changed files with 27 additions and 6 deletions

View File

@ -4,6 +4,8 @@ import { Await, useLoaderData, useNavigate, useParams } from 'react-router-dom';
import { ArrowLeftIcon, LoaderIcon } from '@shared/icons'; import { ArrowLeftIcon, LoaderIcon } from '@shared/icons';
import { User } from '@shared/user'; import { User } from '@shared/user';
import { NIP11 } from '@utils/types';
import { RelayEventList } from './components/relayEventList'; import { RelayEventList } from './components/relayEventList';
export function RelayScreen() { export function RelayScreen() {
@ -59,7 +61,7 @@ export function RelayScreen() {
</div> </div>
} }
> >
{(resolvedRelay) => ( {(resolvedRelay: NIP11) => (
<div className="flex flex-col gap-5"> <div className="flex flex-col gap-5">
<div> <div>
<h3 className="font-semibold leading-tight text-neutral-900 dark:text-neutral-100"> <h3 className="font-semibold leading-tight text-neutral-900 dark:text-neutral-100">
@ -114,7 +116,7 @@ export function RelayScreen() {
Supported NIPs: Supported NIPs:
</h5> </h5>
<div className="mt-2 grid grid-cols-7 gap-2"> <div className="mt-2 grid grid-cols-7 gap-2">
{resolvedRelay.supported_nips.map((item: string) => ( {resolvedRelay.supported_nips.map((item) => (
<a <a
key={item} key={item}
href={`https://nips.be/${item}`} href={`https://nips.be/${item}`}

View File

@ -12,14 +12,14 @@ import { QUOTES } from '@stores/constants';
interface NDKContext { interface NDKContext {
ndk: undefined | NDK; ndk: undefined | NDK;
fetcher: undefined | NostrFetcher;
relayUrls: string[]; relayUrls: string[];
fetcher: NostrFetcher;
} }
const NDKContext = createContext<NDKContext>({ const NDKContext = createContext<NDKContext>({
ndk: undefined, ndk: undefined,
relayUrls: [],
fetcher: undefined, fetcher: undefined,
relayUrls: [],
}); });
const NDKProvider = ({ children }: PropsWithChildren<object>) => { const NDKProvider = ({ children }: PropsWithChildren<object>) => {

View File

@ -406,7 +406,7 @@ export class LumeStorage {
`SELECT * FROM relays WHERE account_id = "${this.account.id}" ORDER BY id DESC LIMIT 50;` `SELECT * FROM relays WHERE account_id = "${this.account.id}" ORDER BY id DESC LIMIT 50;`
); );
if (!result || result.length < 1) return FULL_RELAYS; if (!result || !result.length) return FULL_RELAYS;
return result.map((el) => el.relay); return result.map((el) => el.relay);
} }

View File

@ -86,7 +86,7 @@ export function NotifyNote({ event }: { event: NDKEvent }) {
</div> </div>
</div> </div>
<div className="flex gap-2"> <div className="flex gap-2">
<div className="flex-1">{renderKind(data)}</div> <div className="flex-1">{data ? renderKind(data) : <p>Loading...</p>}</div>
<button <button
type="button" type="button"
onClick={() => onClick={() =>

19
src/utils/types.d.ts vendored
View File

@ -139,3 +139,22 @@ export interface NDKCacheEventTag {
value: string; value: string;
tagValue: string; tagValue: string;
} }
export interface NIP11 {
name: string;
description: string;
pubkey: string;
contact: string;
supported_nips: number[];
software: string;
version: string;
limitation: {
[key: string]: string | number | boolean;
};
relay_countries: string[];
language_tags: string[];
tags: string[];
posting_policy: string;
payments_url: string;
icon: string[];
}