This commit is contained in:
Ren Amamiya 2023-09-26 09:40:02 +07:00
parent 236131087a
commit 1d93f8cf6a
5 changed files with 17 additions and 17 deletions

View File

@ -21,7 +21,7 @@ export function NWCScreen() {
};
return (
<div className="flex h-full w-full items-center justify-center">
<div className="flex h-full w-full items-center justify-center bg-white/5">
<div className="flex w-full flex-col gap-5">
<div className="text-center">
<h3 className="text-2xl font-bold leading-tight">

View File

@ -40,13 +40,18 @@ export const NDKInstance = () => {
const successes = responses.filter((res) => res.ok);
const verifiedRelays: string[] = successes.map((res) => {
// TODO: support payment
const url = new URL(res.url);
// @ts-expect-error, not have type yet
if (!res.data.limitation?.payment_required) {
const url = new URL(res.url);
if (url.protocol === 'http:') return `ws://${url.hostname + url.pathname}`;
if (url.protocol === 'https:') return `wss://${url.hostname + url.pathname}`;
if (res.data?.limitation?.payment_required) {
if (url.protocol === 'http:')
return `ws://${url.hostname + url.pathname + db.account.npub}`;
if (url.protocol === 'https:')
return `wss://${url.hostname + url.pathname + db.account.npub}`;
}
if (url.protocol === 'http:') return `ws://${url.hostname + url.pathname}`;
if (url.protocol === 'https:') return `wss://${url.hostname + url.pathname}`;
});
// return all validated relays

View File

@ -25,26 +25,19 @@ export function ActiveAccount() {
useEffect(() => {
const filter: NDKFilter = {
'#p': [db.account.pubkey],
kinds: [
NDKKind.Text,
NDKKind.Contacts,
NDKKind.Repost,
NDKKind.Reaction,
NDKKind.Zap,
],
kinds: [NDKKind.Text, NDKKind.Repost, NDKKind.Reaction, NDKKind.Zap],
since: Math.floor(Date.now() / 1000),
};
sub(
filter,
async (event) => {
console.log('new notify: ', event);
addActivity(event);
switch (event.kind) {
case NDKKind.Text:
return await sendNativeNotification('Mention');
case NDKKind.Contacts:
return await sendNativeNotification("You've a new follower");
case NDKKind.Repost:
return await sendNativeNotification('Repost');
case NDKKind.Reaction:

View File

@ -148,7 +148,7 @@ export function Repost({
<User pubkey={event.pubkey} time={event.created_at} variant="repost" />
<div className="relative flex flex-col">
<User pubkey={data.pubkey} time={data.created_at} />
<div className="-mt-2 flex items-start gap-3">
<div className="-mt-5 flex items-start gap-3">
<div className="w-10 shrink-0" />
<div className="relative z-20 flex-1">
{renderKind(data)}

View File

@ -47,11 +47,13 @@ export function useNostr() {
closeOnEose: false,
groupable: groupable ?? true,
});
subManager.set(JSON.stringify(filter), subEvent);
subEvent.addListener('event', (event: NDKEvent) => {
callback(event);
});
subManager.set(JSON.stringify(filter), subEvent);
console.log(subManager.keys());
};
const fetchUserData = async (preFollows?: string[]) => {