setShowAdult(e.target.checked)} />
diff --git a/src/components/SlideShow.tsx b/src/components/SlideShow.tsx
index 2b3a4e1..8b9ac52 100644
--- a/src/components/SlideShow.tsx
+++ b/src/components/SlideShow.tsx
@@ -91,19 +91,34 @@ const SlideShow = () => {
const listAuthors = useAuthorsFromList(settings.list);
const [contacts] = useAtom(followsAtom);
- const authorsToQuery = settings.follows
- ? contacts?.tags.filter(t => t[0] === 'p').map(t => t[1]) || []
- : listAuthors && listAuthors.length > 0
- ? listAuthors
- : settings.npubs.map(p => nip19.decode(p).data as string);
+ const filter = useMemo(() => {
+ const authorsToQuery = settings.follows
+ ? contacts?.tags.filter(t => t[0] === 'p').map(t => t[1]) || []
+ : listAuthors && listAuthors.length > 0
+ ? listAuthors
+ : settings.npubs.map(p => nip19.decode(p).data as string);
- const filterTags = settings.topic ? topics[settings.topic].tags : settings.tags;
+ const filterTags = settings.topic ? topics[settings.topic].tags : settings.tags;
- const { events } = useEvents(buildFilter(filterTags, authorsToQuery, settings.showReposts), {
+ return buildFilter(filterTags, authorsToQuery, settings.showReposts);
+ }, [
+ contacts?.tags,
+ listAuthors,
+ settings.follows,
+ settings.npubs,
+ settings.showReposts,
+ settings.tags,
+ settings.topic,
+ ]);
+
+ const { events } = useEvents(filter, {
cacheUsage: NDKSubscriptionCacheUsage.PARALLEL,
+ // when seeing global, close stream because of too many updates.
+ closeOnEose: settings.npubs.length == 0 && settings.tags.length == 0
});
useEffect(() => {
+ // console.log('set posts');
setPosts(
events
.filter(
diff --git a/src/components/env.ts b/src/components/env.ts
index e175cd3..42306a7 100644
--- a/src/components/env.ts
+++ b/src/components/env.ts
@@ -47,7 +47,19 @@ export const topics: { [key: string]: Topic } = {
},
lifestyle: {
name: 'Lifestyle',
- tags: ['fashion', 'flowerstr', 'foodstr', 'style', 'weedstr', 'travel', 'travelstr', 'happy', 'life', 'love'],
+ tags: [
+ 'fashion',
+ 'flowerstr',
+ 'foodstr',
+ 'style',
+ 'weedstr',
+ 'travel',
+ 'travelstr',
+ 'happy',
+ 'life',
+ 'love',
+ 'hiking',
+ ],
},
gardenandfarm: { name: 'Gardening und Farming', tags: ['gardening', 'gardenstr', 'nature', 'farming', 'farmstr'] },
};
@@ -132,6 +144,7 @@ export const adultContentTags = [
'nakedart',
'nasstr',
'nodestr',
+ 'naughty',
'nsfw',
'nude',
'nudeart',
@@ -240,6 +253,7 @@ export const adultNPubs = [
'npub1ylrnf0xfp9wsmqthxlqjqyqj9yy27pnchjwjq93v3mq66ts7ftjs6x7dcq', // Welcome To The Jungle
'npub1z0xv9t5w6evrcg860kmgqq5tfj55mz84ta40uszjnfp9uhw2clkq63yrak', // ???
'npub1f3n7hq0a6vyfsjrv9vfdwtasa0g98ve96he68rxsvq9x6cl8tvxqmv6ca4', // Lady Sex (nude anime)
+ 'npub1ylq5s3xsdmzgzvgzll6ghcs3qa8a9ajl955hj4tcpmyruvjsl8nq5wqhd8', // Dnera
'npub1t07mr7m65lg3ecr5eapu6qe4ayt2wgjpqjs8x58m5kx2r2cutsyqyzzzs9', // NOT NSFW but spammy ai pictures
'npub1curnt7jtq8mhl9fcswnwvuvc9ccm6lvsdv4kzydx75v92kldrvdqh7sq09', // NOT NSFW but spammy ai pictures
diff --git a/src/components/nostrImageDownload.ts b/src/components/nostrImageDownload.ts
index e65f7cf..18013ce 100644
--- a/src/components/nostrImageDownload.ts
+++ b/src/components/nostrImageDownload.ts
@@ -1,6 +1,7 @@
import { NDKEvent, NDKFilter, NDKTag } from '@nostr-dev-kit/ndk';
import { adultContentTags, adultPublicKeys, mixedAdultNPubs } from './env';
import uniq from 'lodash/uniq';
+import { unixNow } from '../ngine/time';
export type Post = {
event: NDKEvent;
@@ -23,7 +24,7 @@ export type NostrImage = {
export const buildFilter = (tags: string[], authors: string[], withReposts = false) => {
const filter: NDKFilter = {
kinds: [1, 1063] as number[],
- limit: authors.length > 0 ? 1000 : 500,
+ limit: authors.length > 0 ? 1000 : tags.length > 0 ? 500 : 500,
};
if (withReposts) {
@@ -32,10 +33,10 @@ export const buildFilter = (tags: string[], authors: string[], withReposts = fal
if (authors && authors.length > 0) {
filter.authors = authors;
+ } else if (tags && tags.length > 0) {
+ filter['#t'] = tags;
} else {
- if (tags && tags.length > 0) {
- filter['#t'] = tags;
- }
+ filter.since = unixNow() - 60 * 60 * 24; // 24h
}
// console.log('filter', filter);
@@ -67,6 +68,8 @@ export const urlFix = (url: string) => {
};
export const extractImageUrls = (text: string): string[] => {
+ if (text == undefined) return [];
+
const urlRegex = /(https?:\/\/[^\s]+)/g;
const matchedUrls = (text.match(urlRegex) || []).map(u => urlFix(u));
return uniq(matchedUrls);
diff --git a/src/ngine/hooks/useEvents.ts b/src/ngine/hooks/useEvents.ts
index 49631f7..be02f93 100644
--- a/src/ngine/hooks/useEvents.ts
+++ b/src/ngine/hooks/useEvents.ts
@@ -15,16 +15,18 @@ export default function useEvents(filter: NDKFilter | NDKFilter[], opts?: Subscr
const [eose, setEose] = useState(false);
const [events, setEvents] = useState
([]);
const id = useMemo(() => {
+ console.warn('new ID!!!');
return hashSha256(filter);
}, [filter]);
useEffect(() => {
if (filter && !opts?.disable) {
- console.log('useEvents: new Subscription');
+ // console.log('useEvents: new Subscription', filter, opts);
setEvents([]);
const relaySet = relays?.length ?? 0 > 0 ? NDKRelaySet.fromRelayUrls(relays as string[], ndk) : undefined;
const sub = ndk.subscribe(filter, opts, relaySet);
sub.on('event', (ev: NDKEvent) => {
+ // console.log('new event ');
setEvents(evs => {
const newEvents = evs.concat([ev]).sort((a, b) => (b.created_at ?? 0) - (a.created_at ?? 0));
return uniqBy(newEvents, (e: NDKEvent) => e.tagId());
diff --git a/src/utils/useAuthorsFromList.ts b/src/utils/useAuthorsFromList.ts
index fd25415..5313756 100644
--- a/src/utils/useAuthorsFromList.ts
+++ b/src/utils/useAuthorsFromList.ts
@@ -1,7 +1,8 @@
+import { useMemo } from 'react';
import useEvent from '../ngine/hooks/useEvent';
import { nip19 } from 'nostr-tools';
-const useAuthorsFromList = (listAddr?: string) => {
+const useAuthorsFromList = (listAddr?: string): string[] => {
const validListAttr = listAddr?.indexOf('naddr') == 0;
const addr = listAddr ? (nip19.decode(listAddr).data as nip19.AddressPointer) : undefined;
const addrIsDefined = addr && addr.pubkey && addr.identifier;
@@ -13,13 +14,17 @@ const useAuthorsFromList = (listAddr?: string) => {
{ kinds: [30000], authors: authorFilter, '#d': identFilter },
{ disable: !validListAttr && !addrIsDefined }
);
- const authors: string[] =
- (validListAttr &&
- listEvent
- ?.getMatchingTags('p')
- .map(t => t[1])
- .flat()) ||
- [];
+
+ const authors: string[] = useMemo(() => {
+ return (
+ (validListAttr &&
+ listEvent
+ ?.getMatchingTags('p')
+ .map(t => t[1])
+ .flat()) ||
+ []
+ );
+ }, [listEvent, validListAttr]);
return authors;
};
diff --git a/src/utils/useLists.ts b/src/utils/useLists.ts
index 74d8665..ec3bfff 100644
--- a/src/utils/useLists.ts
+++ b/src/utils/useLists.ts
@@ -16,10 +16,14 @@ const usePeopleLists = (npub?: string) => {
return eventsWithName.map(e => {
const nameTag = e.getMatchingTags('d').slice(0, 1).flat();
- const name = nameTag ? nameTag[1] : 'unknown';
+ const titleTag = e.getMatchingTags('title').slice(0, 1).flat();
+ const descriptionTag = e.getMatchingTags('description').slice(0, 1).flat();
+
+ const name = titleTag.length>0 ? titleTag[1] : nameTag ? nameTag[1] : 'unknown';
+ const description = descriptionTag.length > 0 && descriptionTag[1];
const people = e.tags.filter(t => t[0] === 'p')?.map(t => t[1]);
- return { id: e.id, nevent: e.encode(), name, people };
+ return { id: e.id, nevent: e.encode(), name, people, description };
});
}, [events]);
diff --git a/src/utils/useNav.ts b/src/utils/useNav.ts
index d74a11d..edf3198 100644
--- a/src/utils/useNav.ts
+++ b/src/utils/useNav.ts
@@ -52,6 +52,7 @@ const useNav = () => {
}
const postfix = searchParams.length > 0 ? `?${searchParams.join('&')}` : '';
+ console.log(settings);
if (settings.topic) {
navigate(`/topic/${settings.topic}${postfix}`);
} else if (settings.follows) {
@@ -63,7 +64,7 @@ const useNav = () => {
} else if (validNpubs.length == 1) {
navigate(`/p/${validNpubs[0]}${postfix}`);
} else {
- navigate(`/${postfix}`);
+ navigate(`/global${postfix}`);
}
};