mirror of
https://github.com/irislib/iris-messenger.git
synced 2024-09-19 17:46:33 +00:00
.
This commit is contained in:
parent
180d1723ca
commit
f5c3fe8fe9
@ -5,6 +5,8 @@ import { Event, Filter } from 'nostr-tools';
|
|||||||
import Events from './Events';
|
import Events from './Events';
|
||||||
import Key from './Key';
|
import Key from './Key';
|
||||||
|
|
||||||
|
// IDB ops can be heavy, would be useful to do this in worker in order to not block the main thread
|
||||||
|
// TODO can we somehow map event and user ids to shorter internal ids like we do in EventDB (in-memory)? would save a lot of space
|
||||||
type Tag = {
|
type Tag = {
|
||||||
id: string;
|
id: string;
|
||||||
eventId: string;
|
eventId: string;
|
||||||
@ -73,7 +75,16 @@ const IndexedDB = {
|
|||||||
saveEvent(event: Event & { id: string }) {
|
saveEvent(event: Event & { id: string }) {
|
||||||
const eventTags =
|
const eventTags =
|
||||||
event.tags
|
event.tags
|
||||||
?.filter((tag) => ['e', 'p'].includes(tag[0]))
|
?.filter((tag) => {
|
||||||
|
if (tag[0] === 'e') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// we're only interested in p tags where we are mentioned
|
||||||
|
if (tag[0] === 'p' && tag[1] === Key.getPubKey()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
})
|
||||||
.map((tag) => ({
|
.map((tag) => ({
|
||||||
id: event.id.slice(0, 16) + '-' + tag[0].slice(0, 16) + '-' + tag[1].slice(0, 16),
|
id: event.id.slice(0, 16) + '-' + tag[0].slice(0, 16) + '-' + tag[1].slice(0, 16),
|
||||||
eventId: event.id,
|
eventId: event.id,
|
||||||
|
Loading…
Reference in New Issue
Block a user