diff --git a/src/main.ts b/src/main.ts index 51f16f0..d044984 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,10 +3,10 @@ import {zeroLeadingBitsCount} from './utils/crypto'; import {elem} from './utils/dom'; import {bounce} from './utils/time'; import {isWssUrl} from './utils/url'; +import {closeSettingsView, config, toggleSettingsView} from './settings'; import {sub24hFeed, subNote, subProfile} from './subscriptions' import {getReplyTo, hasEventTag, isMention, sortByCreatedAt, sortEventCreatedAt} from './events'; import {clearView, getViewContent, getViewElem, getViewOptions, setViewElem, view} from './view'; -import {closeSettingsView, config, toggleSettingsView} from './settings'; import {handleReaction, handleUpvote} from './reactions'; import {closePublishView, openWriteInput, togglePublishView} from './write'; import {handleMetadata, renderProfile} from './profiles'; diff --git a/src/subscriptions.ts b/src/subscriptions.ts index 4dd408a..0f12680 100644 --- a/src/subscriptions.ts +++ b/src/subscriptions.ts @@ -1,5 +1,6 @@ import {Event} from 'nostr-tools'; import {getReplyTo, hasEventTag, isMention} from './events'; +import {config} from './settings'; import {sub, subOnce, unsubAll} from './relays'; type SubCallback = ( @@ -13,6 +14,7 @@ export const sub24hFeed = (onEvent: SubCallback) => { const now = Math.floor(Date.now() * 0.001); const pubkeys = new Set(); const notes = new Set(); + const prefix = Math.floor(config.filterDifficulty * 0.25); sub({ // get past events cb: (evt, relay) => { pubkeys.add(evt.pubkey); @@ -20,9 +22,10 @@ export const sub24hFeed = (onEvent: SubCallback) => { onEvent(evt, relay); }, filter: { + ...(prefix && {ids: ['0'.repeat(prefix)]}), kinds: [1], until: now, - since: Math.floor(now - (24 * 60 * 60)), + ...(!prefix && {since: Math.floor(now - (24 * 60 * 60))}), limit: 100, }, unsub: true