diff --git a/ROADMAP.md b/ROADMAP.md index 9c06ecff..f5235e02 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,7 +1,6 @@ # Current - [ ] Fix pagination -- [ ] Relays get marked as slow too easily now # Next @@ -23,6 +22,7 @@ # More +- [ ] Add new DM button to dms list - [ ] Add suggested relays based on follows or topics - [ ] Combine alerts/messages and any other top-level subscriptions to avoid sub limit - [ ] Clean up person detail actions, maybe click one circle and show the rest diff --git a/src/agent/pool.ts b/src/agent/pool.ts index 721adb29..19efe9b3 100644 --- a/src/agent/pool.ts +++ b/src/agent/pool.ts @@ -31,7 +31,7 @@ class Connection { this.status = 'new' this.stats = { timeouts: 0, - subCount: 0, + subsCount: 0, eoseCount: 0, eoseTimer: 0, eventsCount: 0, @@ -87,8 +87,8 @@ class Connection { return [0, "Failed to connect"] } - const {timeouts, subCount, eoseTimer, eoseCount} = this.stats - const timeoutRate = timeouts > 0 ? timeouts / subCount : null + const {timeouts, subsCount, eoseTimer, eoseCount} = this.stats + const timeoutRate = timeouts > 0 ? timeouts / subsCount : null const eoseQuality = eoseCount > 0 ? Math.max(1, 500 / (eoseTimer / eoseCount)) : null if (timeoutRate && timeoutRate > 0.5) { diff --git a/src/agent/user.ts b/src/agent/user.ts index 0d76d8b3..945382b7 100644 --- a/src/agent/user.ts +++ b/src/agent/user.ts @@ -1,7 +1,8 @@ import type {Person} from 'src/util/types' import type {Readable} from 'svelte/store' -import {prop, find, pipe, assoc, whereEq, when, concat, reject, nth, map} from 'ramda' +import {last, prop, find, pipe, assoc, whereEq, when, concat, reject, nth, map} from 'ramda' import {synced} from 'src/util/misc' +import {Tags} from 'src/util/nostr' import {derived} from 'svelte/store' import database from 'src/agent/database' import keys from 'src/agent/keys' @@ -90,6 +91,34 @@ const user = { canPublish, getProfile: () => profileCopy, getPubkey: () => profileCopy?.pubkey, + muffle: events => { + const muffle = user.getMuffle() + + return events.filter(e => !muffle.has(e.pubkey)) + }, + getMuffle: () => { + return new Set( + Tags + .wrap((profileCopy?.muffle || [])) + .filter(t => Math.random() > parseFloat(last(t))) + .values() + .all() + ) + }, + mute: events => { + const mutes = user.getMutes() + + return events.filter(e => !mutes.has(e.pubkey)) + }, + getMutes: () => { + return new Set( + Tags + .wrap((profileCopy?.muffle || [])) + .filter(t => parseFloat(last(t)) === 0) + .values() + .all() + ) + }, // Petnames diff --git a/src/app/index.ts b/src/app/index.ts index 9b792852..8ceb8be8 100644 --- a/src/app/index.ts +++ b/src/app/index.ts @@ -99,6 +99,10 @@ export const publishWithToast = (relays, thunk) => extra.push(`${timeouts.size} timed out`) } + if (pending.size > 0) { + extra.push(`${pending.size} pending`) + } + if (extra.length > 0) { message += ` (${extra.join(', ')})` } diff --git a/src/util/nostr.ts b/src/util/nostr.ts index 63978a0b..f460659c 100644 --- a/src/util/nostr.ts +++ b/src/util/nostr.ts @@ -34,6 +34,9 @@ export class Tags { values() { return new Tags(this.tags.map(t => t[1])) } + filter(f) { + return new Tags(this.tags.filter(f)) + } type(type) { return new Tags(this.tags.filter(t => t[0] === type)) } diff --git a/src/views/alerts/Alerts.svelte b/src/views/alerts/Alerts.svelte index 4d8fd057..b040a8de 100644 --- a/src/views/alerts/Alerts.svelte +++ b/src/views/alerts/Alerts.svelte @@ -11,6 +11,7 @@ import ImageCircle from "src/partials/ImageCircle.svelte" import Alert from 'src/views/alerts/Alert.svelte' import database from 'src/agent/database' + import user from 'src/agent/user' import {lastChecked} from 'src/app/alerts' import {modal, routes} from 'src/app/ui' @@ -25,7 +26,7 @@ // Filter out alerts for which we failed to find the required context. The bug // is really upstream of this, but it's an easy fix - const events = database.alerts.all() + const events = user.mute(database.alerts.all()) .filter(e => e.replies.length > 0 || e.likedBy.length > 0 || e.isMention) notes = sortBy(e => -e.created_at, events).slice(0, limit) diff --git a/src/views/notes/Feed.svelte b/src/views/notes/Feed.svelte index 766dd948..15cb9927 100644 --- a/src/views/notes/Feed.svelte +++ b/src/views/notes/Feed.svelte @@ -1,10 +1,10 @@