fix duplicated event when sending.

This commit is contained in:
fiatjaf 2020-11-14 22:05:49 -03:00
parent a175d8d977
commit 415126c50f
2 changed files with 5 additions and 6 deletions

View File

@ -9,6 +9,5 @@ db.version(1).stores({
relays: 'host',
following: 'pubkey',
mynotes: 'id, kind, created_at',
cachedmetadata: 'pubkey',
cachednotes: 'id, pubkey, created_at'
cachedmetadata: 'pubkey'
})

View File

@ -31,7 +31,7 @@ export default createStore({
relays,
key: ec.genKeyPair().getPrivate('hex'),
following: [],
home: new SortedMap([], (a, b) => b[1] - a[1]),
home: new SortedMap(),
metadata: new LRU({maxSize: 100}),
browsing: new LRU({maxSize: 300})
}
@ -119,7 +119,7 @@ export default createStore({
state.browsing.set('rel:' + evt.ref, evt)
}
} else {
state.home.set([evt.id, evt.created_at], evt)
state.home.set(evt.id + ':' + evt.created_at, evt)
}
break
case 2: // recommendServer
@ -232,8 +232,8 @@ async function init(store) {
.toArray()
.then(notes => {
return new SortedMap(
notes.map(n => [[n.id, n.created_at], n]),
(a, b) => b[1] - a[1]
notes.map(n => [n.id + ':' + n.created_at, n]),
(a, b) => b.split(':')[1] - a.split(':')[1]
)
}),
db.cachedmetadata.toArray().then(metas => {