mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-30 00:41:12 +00:00
Add some limits on subscriptions
This commit is contained in:
parent
4cf0945305
commit
395b34554f
@ -1,5 +1,6 @@
|
||||
Bugs
|
||||
|
||||
- [ ] Ellipsize and hyperlink links
|
||||
- [ ] Be sure to deduplicate all events if needed
|
||||
- [ ] Format text with line breaks - pre, or split/br
|
||||
- [ ] Remove dexie, or use it instead of localstorage for cached data
|
||||
|
@ -20,7 +20,8 @@
|
||||
|
||||
onMount(() => {
|
||||
return findNotes(channels.main, {
|
||||
since: new Date().valueOf() / 1000 - 7 * 24 * 60 * 60,
|
||||
since: now() - timedelta(1, 'days'),
|
||||
limit: 100,
|
||||
}, $notes => {
|
||||
notes = $notes
|
||||
})
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
return findNotes(channels.main, {
|
||||
authors: [pubkey],
|
||||
since: now() - timedelta(1, 'days'),
|
||||
limit: 100,
|
||||
}, $notes => {
|
||||
notes = $notes
|
||||
})
|
||||
|
@ -1,4 +1,5 @@
|
||||
import {prop, sortBy, uniqBy, find, last, groupBy} from 'ramda'
|
||||
import {debounce} from 'throttle-debounce'
|
||||
import {writable, derived, get} from 'svelte/store'
|
||||
import {switcherFn, ensurePlural} from 'hurdak/lib/hurdak'
|
||||
import {getLocalJson, setLocalJson, now, timedelta} from "src/util/misc"
|
||||
@ -101,5 +102,5 @@ export const findNotes = (channel, queries, cb) => {
|
||||
}
|
||||
)
|
||||
|
||||
return annotatedNotes.subscribe(cb)
|
||||
return annotatedNotes.subscribe(debounce(300, cb))
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ export const registerRelay = async url => {
|
||||
db.relays.put({...json, url})
|
||||
}
|
||||
|
||||
registerRelay('wss://nostr-relay-dev.wlvs.space')
|
||||
registerRelay('wss://nostr-pub.wellorder.net')
|
||||
registerRelay('wss://nostr-relay.wlvs.space')
|
||||
registerRelay('ws://localhost:7000')
|
||||
|
@ -5,10 +5,12 @@ import {getLocalJson, setLocalJson} from "src/util/misc"
|
||||
|
||||
export const nostr = relayPool()
|
||||
|
||||
// Initialize nostr channels with a noop query
|
||||
|
||||
export const channels = {
|
||||
main: nostr.sub({filter: {}, cb: noop}),
|
||||
modal: nostr.sub({filter: {}, cb: noop}),
|
||||
getter: nostr.sub({filter: {}, cb: noop}),
|
||||
main: nostr.sub({filter: {ids: []}, cb: noop}),
|
||||
modal: nostr.sub({filter: {ids: []}, cb: noop}),
|
||||
getter: nostr.sub({filter: {ids: []}, cb: noop}),
|
||||
}
|
||||
|
||||
// Augment nostr with some extra methods
|
||||
|
@ -27,7 +27,7 @@ export const setLocalJson = (k, v) => {
|
||||
}
|
||||
}
|
||||
|
||||
export const now = () => new Date().valueOf() / 1000
|
||||
export const now = () => Math.round(new Date().valueOf() / 1000)
|
||||
|
||||
export const timedelta = (n, unit = 'seconds') => {
|
||||
switch (unit) {
|
||||
|
Loading…
Reference in New Issue
Block a user