mirror of
https://github.com/dergigi/boris.git
synced 2025-12-27 19:44:40 +01:00
refactor: use AppDataBlueprint via namespace import
- Import blueprints as namespace: 'import * as Blueprints from applesauce-factory/blueprints' - Use Blueprints.AppDataBlueprint with proper factory API - Cleaner than manual event construction - Should work with Vercel as namespace imports don't require direct named exports
This commit is contained in:
@@ -3,6 +3,7 @@ import { EventFactory } from 'applesauce-factory'
|
||||
import { RelayPool, onlyEvents } from 'applesauce-relay'
|
||||
import { NostrEvent } from 'nostr-tools'
|
||||
import { firstValueFrom } from 'rxjs'
|
||||
import * as Blueprints from 'applesauce-factory/blueprints'
|
||||
|
||||
const SETTINGS_IDENTIFIER = 'com.dergigi.boris.user-settings'
|
||||
const APP_DATA_KIND = 30078 // NIP-78 Application Data
|
||||
@@ -136,13 +137,13 @@ export async function saveSettings(
|
||||
): Promise<void> {
|
||||
console.log('💾 Saving settings to nostr:', settings)
|
||||
|
||||
// Create NIP-78 application data event manually
|
||||
const draft = await factory.create(async () => ({
|
||||
kind: APP_DATA_KIND,
|
||||
content: JSON.stringify(settings),
|
||||
tags: [['d', SETTINGS_IDENTIFIER]],
|
||||
created_at: Math.floor(Date.now() / 1000)
|
||||
}))
|
||||
// Create NIP-78 application data event using the AppDataBlueprint
|
||||
const draft = await factory.create(
|
||||
Blueprints.AppDataBlueprint,
|
||||
SETTINGS_IDENTIFIER,
|
||||
settings,
|
||||
false // no encryption
|
||||
)
|
||||
|
||||
const signed = await factory.sign(draft)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user