Implement mute feed filtering across recent, topic, search, and notifications feeds

By coder.
This commit is contained in:
Chris Troutner
2026-09-04 12:23:00 -07:00
parent c8ef2ddd95
commit 448bddc31f
25 changed files with 510 additions and 61 deletions
@@ -57,13 +57,35 @@ test('load forwards limit and offset to the memo db client', async () => {
assert.deepEqual(calls, [{ limit: 10, offset: 20 }])
})
test('load throws when no memo db client is provided', async () => {
const page = new RecentFeedPage({})
test('load forwards the viewer address to the memo db client when a wallet is provided', async () => {
const calls = []
const memoDb = {
async getRecentPosts (params) {
calls.push(params)
return { posts: [], pagination: {} }
}
}
const wallet = { walletInfo: { cashAddress: 'bitcoincash:qqlrzp23w08434twmvr4fxw672whkjy0py26r63g3d' } }
const page = new RecentFeedPage({ memoDb, wallet })
await assert.rejects(
() => page.load(),
/requires a memo db client/
)
await page.load({ limit: 10, offset: 20 })
assert.deepEqual(calls, [{ limit: 10, offset: 20, viewer: 'bitcoincash:qqlrzp23w08434twmvr4fxw672whkjy0py26r63g3d' }])
})
test('load omits viewer address when no wallet is provided', async () => {
const calls = []
const memoDb = {
async getRecentPosts (params) {
calls.push(params)
return { posts: [], pagination: {} }
}
}
const page = new RecentFeedPage({ memoDb })
await page.load({ limit: 10, offset: 20 })
assert.deepEqual(calls, [{ limit: 10, offset: 20 }])
})
test('load defaults limit to 50 and offset to 0', async () => {
@@ -80,3 +102,12 @@ test('load defaults limit to 50 and offset to 0', async () => {
assert.deepEqual(calls, [{ limit: 50, offset: 0 }])
})
test('load throws when no memo db client is provided', async () => {
const page = new RecentFeedPage({})
await assert.rejects(
() => page.load(),
/requires a memo db client/
)
})
@@ -49,6 +49,30 @@ test('submit forwards query, limit and offset to the memo db client', async () =
assert.deepEqual(calls, [{ q: 'alice', params: { limit: 10, offset: 20 } }])
})
test('submit forwards the viewer address when a wallet is provided', async () => {
const calls = []
const memoDb = {
async search (q, params) {
calls.push({ q, params })
return { posts: [], profiles: [], pagination: {} }
}
}
const wallet = { walletInfo: { cashAddress: 'bitcoincash:qqlrzp23w08434twmvr4fxw672whkjy0py26r63g3d' } }
const page = new SearchPage({ memoDb, wallet })
page.setQuery('alice')
await page.submit({ limit: 10, offset: 20 })
assert.deepEqual(calls, [{
q: 'alice',
params: {
limit: 10,
offset: 20,
viewer: 'bitcoincash:qqlrzp23w08434twmvr4fxw672whkjy0py26r63g3d'
}
}])
})
test('submit defaults limit to 50 and offset to 0', async () => {
const calls = []
const memoDb = {
@@ -71,6 +71,34 @@ test('load forwards limit and offset to the memo db client', async () => {
assert.deepEqual(calls, [{ room: 'bitcoin', params: { limit: 10, offset: 20 } }])
})
test('load forwards the viewer address when myAddr is provided', async () => {
const calls = []
const memoDb = {
async getTopicPosts (room, params) {
calls.push({ room, params })
return { posts: [], pagination: {} }
},
async getTopicFollowState () {
return false
},
async getTopicFollowers () {
return []
}
}
const page = new TopicFeedPage({ memoDb, room: 'bitcoin', myAddr: MY_ADDRESS })
await page.load({ limit: 10, offset: 20 })
assert.deepEqual(calls, [{
room: 'bitcoin',
params: {
limit: 10,
offset: 20,
viewer: MY_ADDRESS
}
}])
})
test('load defaults limit and offset to 50 and 0', async () => {
const calls = []
const memoDb = {