diff --git a/README.md b/README.md index 71aea2e7..9cfa47e6 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/routes/Notes.svelte b/src/routes/Notes.svelte index 0ba41878..b6ad46b9 100644 --- a/src/routes/Notes.svelte +++ b/src/routes/Notes.svelte @@ -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 }) diff --git a/src/routes/UserDetail.svelte b/src/routes/UserDetail.svelte index 08eae676..55de837b 100644 --- a/src/routes/UserDetail.svelte +++ b/src/routes/UserDetail.svelte @@ -22,6 +22,8 @@ return findNotes(channels.main, { authors: [pubkey], + since: now() - timedelta(1, 'days'), + limit: 100, }, $notes => { notes = $notes }) diff --git a/src/state/app.js b/src/state/app.js index d8e8cec4..de15eef7 100644 --- a/src/state/app.js +++ b/src/state/app.js @@ -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)) } diff --git a/src/state/db.js b/src/state/db.js index a31b56bc..44c2b5d5 100644 --- a/src/state/db.js +++ b/src/state/db.js @@ -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') diff --git a/src/state/nostr.js b/src/state/nostr.js index fa61c384..7d78fe2f 100644 --- a/src/state/nostr.js +++ b/src/state/nostr.js @@ -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 diff --git a/src/util/misc.js b/src/util/misc.js index 4ebd69ce..e5b6abbc 100644 --- a/src/util/misc.js +++ b/src/util/misc.js @@ -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) {