diff --git a/Shared (Extension)/Resources/db.js b/Shared (Extension)/Resources/db.js index 86401cb..c02d8cc 100644 --- a/Shared (Extension)/Resources/db.js +++ b/Shared (Extension)/Resources/db.js @@ -46,3 +46,24 @@ export async function getHosts() { } return [...hosts]; } + +export async function downloadAllContents() { + let db = await openEventsDb(); + let events = []; + let cursor = await db.transaction('events').store.openCursor(); + while (cursor) { + events.push(cursor.value.event); + cursor = await cursor.continue(); + } + events = events.map(e => JSON.stringify(e)); + events = events.join('\n'); + console.log(events); + + const file = new File([events], 'events.jsonl', { + type: 'application/octet-stream', + }); + + const blob = new Blob([events], { type: 'plain/text' }); + + return blob; +} diff --git a/Shared (Extension)/Resources/event_log.html b/Shared (Extension)/Resources/event_log.html index f22333f..14c27f4 100644 --- a/Shared (Extension)/Resources/event_log.html +++ b/Shared (Extension)/Resources/event_log.html @@ -107,6 +107,10 @@ + +
+ +
diff --git a/Shared (Extension)/Resources/event_log.js b/Shared (Extension)/Resources/event_log.js index c3df835..19b12e6 100644 --- a/Shared (Extension)/Resources/event_log.js +++ b/Shared (Extension)/Resources/event_log.js @@ -1,7 +1,7 @@ import Alpine from 'alpinejs'; import jsonFormatHighlight from 'json-format-highlight'; import { getPublicKey } from 'nostr-tools'; -import { getHosts, sortByIndex } from './db'; +import { downloadAllContents, getHosts, sortByIndex } from './db'; import { getProfiles, KINDS } from './utils'; const TOMORROW = new Date(); @@ -50,6 +50,14 @@ Alpine.data('eventLog', () => ({ })); }, + async saveAll() { + const file = await downloadAllContents(); + browser.tabs.create({ + url: URL.createObjectURL(file), + active: true, + }); + }, + quickKindSelect() { if (this.quickKind === '') return; const i = parseInt(this.quickKind);