Fix posts missing from following feed

This commit is contained in:
styppo 2023-01-24 14:54:49 +00:00
parent c18c4ed988
commit 0d9673ad3f
No known key found for this signature in database
GPG Key ID: 3AAA685C50724C28
2 changed files with 23 additions and 4 deletions

View File

@ -78,7 +78,11 @@ export default {
{subId: `feed:${this.feed.name}`} {subId: `feed:${this.feed.name}`}
) )
this.stream.on('init', notes => { this.stream.on('init', notes => {
const data = typeof this.feed.data === 'function'
? this.feed.data()
: this.feed.data || []
const items = notes const items = notes
.concat(data)
.filter(note => this.filterNote(note, this.feed.hideBots)) .filter(note => this.filterNote(note, this.feed.hideBots))
.map(note => [note]) // TODO Single element thread .map(note => [note]) // TODO Single element thread
items.sort(feedOrder) items.sort(feedOrder)

View File

@ -37,9 +37,17 @@ import Feed from 'components/Feed/Feed.vue'
import {useAppStore} from 'stores/App' import {useAppStore} from 'stores/App'
import {useNostrStore} from 'src/nostr/NostrStore' import {useNostrStore} from 'src/nostr/NostrStore'
import {EventKind} from 'src/nostr/model/Event' import {EventKind} from 'src/nostr/model/Event'
import {NoteOrder, useNoteStore} from 'src/nostr/store/NoteStore'
const ZERO_PUBKEY = '0000000000000000000000000000000000000000000000000000000000000000' const ZERO_PUBKEY = '0000000000000000000000000000000000000000000000000000000000000000'
const myContacts = () => {
const app = useAppStore()
const nostr = useNostrStore()
const contacts = nostr.getContacts(app.myPubkey)
return contacts?.map(contact => contact.pubkey)
}
const Feeds = { const Feeds = {
global: { global: {
name: 'global', name: 'global',
@ -52,10 +60,7 @@ const Feeds = {
following: { following: {
name: 'following', name: 'following',
filters: () => { filters: () => {
const app = useAppStore() let authors = myContacts()
const nostr = useNostrStore()
const contacts = nostr.getContacts(app.myPubkey)
let authors = contacts?.map(contact => contact.pubkey)
if (!authors || !authors.length) authors = [ZERO_PUBKEY] if (!authors || !authors.length) authors = [ZERO_PUBKEY]
return { return {
kinds: [EventKind.NOTE], kinds: [EventKind.NOTE],
@ -63,6 +68,16 @@ const Feeds = {
limit: 50, limit: 50,
} }
}, },
data: () => {
let authors = myContacts()
if (!authors || !authors.length) return []
let notes = []
const store = useNoteStore()
for (const author of authors) {
notes = notes.concat(store.postsByAuthor(author, NoteOrder.CREATION_DATE_DESC))
}
return notes
},
hideBots: false, hideBots: false,
}, },
} }