Group notifications better

This commit is contained in:
Jonathan Staab 2023-05-27 15:45:50 -07:00
parent 6ac4df7ee9
commit 6e686c61af
6 changed files with 24 additions and 3 deletions

View File

@ -5,6 +5,7 @@
- [x] Register url handler for web+nostr and use that for sharing
- [x] Combine search and scan pages
- [x] Clean up notifications page
- [x] Add note share page
# 0.2.28

View File

@ -1,5 +1,8 @@
# Current
- [ ] Fix connection management stuff. Have GPT help
- [ ] Add zap splits https://github.com/nostr-protocol/nips/pull/552
- [ ] Integrate simplex sharing? https://simplex.chat/docs/guide/readme.html
- [ ] Add threads - replies by self get shown at the top of replies?
- [ ] Fix rich text -> plain text using library
- [ ] Highlights

View File

@ -165,7 +165,7 @@ export const listen = async () => {
// Only grab notifications since we last checked, with some wiggle room
const since =
clamp([now() - timedelta(30, "days"), now()], notifications._coll.max("created_at")) -
timedelta(1, "hours")
timedelta(1, "days")
const eventIds = doPipe(userEvents, [
t => t.all({kind: 1, created_at: {$gt: now() - timedelta(30, "days")}}),

View File

@ -4,7 +4,12 @@
import {onMount} from "svelte"
import {fly} from "svelte/transition"
import {navigate} from "svelte-routing"
import {now, timedelta, formatTimestampAsDate, createScroller} from "src/util/misc"
import {
now,
formatTimestampAsDate,
formatTimestampAsLocalISODate,
createScroller,
} from "src/util/misc"
import {findReplyId} from "src/util/nostr"
import Spinner from "src/partials/Spinner.svelte"
import Tabs from "src/partials/Tabs.svelte"
@ -30,7 +35,7 @@
// Sort by rounded timestamp so we can group reactions to the same parent
return reverse(
sortBy(
e => Math.round(e.created_at / timedelta(1, "hour")).toString() + findReplyId(e),
e => formatTimestampAsLocalISODate(e.created_at) + findReplyId(e),
user.applyMutes(t.all())
)
)

View File

@ -8,6 +8,10 @@
export let url
if (!url.startsWith("ws")) {
url = "wss://" + url
}
const relay = relays.get(url) || {url}
document.title = displayRelay(relay)

View File

@ -109,6 +109,14 @@ export const formatTimestampRelative = ts => {
return formatter.format(-delta, unit as Intl.RelativeTimeFormatUnit)
}
export const formatTimestampAsLocalISODate = ts => {
const date = new Date(ts * 1000)
const offset = date.getTimezoneOffset() * 60000
const datetime = new Date(date.getTime() - offset).toISOString()
return datetime.slice(0, 10)
}
export const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
export const poll = (t, cb) => {