minor fixes
This commit is contained in:
@@ -4,49 +4,46 @@ import { RelayPool } from 'nostr-relaypool';
|
||||
import useSWRSubscription from 'swr/subscription';
|
||||
|
||||
export const useChannelProfile = (id: string, channelPubkey: string) => {
|
||||
const { data } = useSWRSubscription(
|
||||
id
|
||||
? [
|
||||
{
|
||||
kinds: [41],
|
||||
'#e': [id],
|
||||
},
|
||||
{
|
||||
ids: [id],
|
||||
kinds: [40],
|
||||
},
|
||||
]
|
||||
: null,
|
||||
(key, { next }) => {
|
||||
const pool = new RelayPool(FULL_RELAYS);
|
||||
const unsubscribe = pool.subscribe(
|
||||
key,
|
||||
FULL_RELAYS,
|
||||
(event: { kind: number; pubkey: string; content: string }) => {
|
||||
switch (event.kind) {
|
||||
case 40:
|
||||
next(null, JSON.parse(event.content));
|
||||
break;
|
||||
case 41:
|
||||
if (event.pubkey === channelPubkey) {
|
||||
next(null, JSON.parse(event.content));
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
undefined,
|
||||
undefined,
|
||||
const { data } = useSWRSubscription(id ? id : null, (key, { next }) => {
|
||||
const pool = new RelayPool(FULL_RELAYS);
|
||||
const unsubscribe = pool.subscribe(
|
||||
[
|
||||
{
|
||||
unsubscribeOnEose: true,
|
||||
kinds: [41],
|
||||
'#e': [key],
|
||||
},
|
||||
{
|
||||
ids: [key],
|
||||
kinds: [40],
|
||||
},
|
||||
],
|
||||
FULL_RELAYS,
|
||||
(event: { kind: number; pubkey: string; content: string }) => {
|
||||
switch (event.kind) {
|
||||
case 40:
|
||||
next(null, JSON.parse(event.content));
|
||||
break;
|
||||
case 41:
|
||||
console.log(event);
|
||||
if (event.pubkey === channelPubkey) {
|
||||
next(null, JSON.parse(event.content));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
);
|
||||
},
|
||||
undefined,
|
||||
undefined,
|
||||
{
|
||||
unsubscribeOnEose: true,
|
||||
}
|
||||
);
|
||||
|
||||
return () => {
|
||||
unsubscribe();
|
||||
};
|
||||
}
|
||||
);
|
||||
return () => {
|
||||
unsubscribe();
|
||||
};
|
||||
});
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -14,10 +14,10 @@ export const messageParser = (noteContent: any) => {
|
||||
return <ImagePreview key={match + i} url={match} size="small" />;
|
||||
} else if (match.match(/(http:|https:)?(\/\/)?(www\.)?(youtube.com|youtu.be)\/(watch|embed)?(\?v=|\/)?(\S+)?/)) {
|
||||
// youtube
|
||||
return <YoutubePreview key={match + i} url={match} />;
|
||||
return <YoutubePreview key={match + i} url={match} size="small" />;
|
||||
} else if (match.match(/\.(mp4|webm)$/i)) {
|
||||
// video
|
||||
return <VideoPreview key={match + i} url={match} />;
|
||||
return <VideoPreview key={match + i} url={match} size="small" />;
|
||||
} else {
|
||||
return (
|
||||
<a key={match + i} href={match} className="cursor-pointer text-fuchsia-500" target="_blank" rel="noreferrer">
|
||||
|
||||
Reference in New Issue
Block a user