Skip to content

Commit

Permalink
Group notifications better
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Staab committed May 27, 2023
1 parent 6ac4df7 commit 6e686c6
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions ROADMAP.md
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/app/state.ts
Expand Up @@ -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")}}),
Expand Down
9 changes: 7 additions & 2 deletions src/app/views/Notifications.svelte
Expand Up @@ -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"
Expand All @@ -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())
)
)
Expand Down
4 changes: 4 additions & 0 deletions src/app/views/RelayDetail.svelte
Expand Up @@ -8,6 +8,10 @@
export let url
if (!url.startsWith("ws")) {
url = "wss://" + url
}
const relay = relays.get(url) || {url}
document.title = displayRelay(relay)
Expand Down
8 changes: 8 additions & 0 deletions src/util/misc.ts
Expand Up @@ -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) => {
Expand Down

0 comments on commit 6e686c6

Please sign in to comment.