minor updates

This commit is contained in:
Ren Amamiya
2023-06-07 14:45:20 +07:00
parent 2f3ea13613
commit 75a33d205a
8 changed files with 80 additions and 106 deletions

View File

@@ -35,7 +35,6 @@ export function useEvent(id: string) {
event.tags,
event.content,
event.created_at,
parentID,
);
// update state
next(null, event);

View File

@@ -1,3 +1,4 @@
import { getParentID } from "@utils/transform";
import { nip19 } from "nostr-tools";
import Database from "tauri-plugin-sql-api";
@@ -221,12 +222,41 @@ export async function createNote(
tags: string[],
content: string,
created_at: number,
parent_id: string,
) {
const db = await connect();
const parentID = getParentID(tags, event_id);
return await db.execute(
"INSERT INTO notes (event_id, account_id, pubkey, kind, tags, content, created_at, parent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?);",
[event_id, account_id, pubkey, kind, tags, content, created_at, parent_id],
[event_id, account_id, pubkey, kind, tags, content, created_at, parentID],
);
}
// create reply note
export async function createReplyNote(
event_id: string,
account_id: number,
pubkey: string,
kind: number,
tags: string[],
content: string,
created_at: number,
parent_comment_id: string,
) {
const db = await connect();
const parentID = getParentID(tags, event_id);
return await db.execute(
"INSERT INTO notes (event_id, account_id, pubkey, kind, tags, content, created_at, parent_id, parent_comment_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);",
[
event_id,
account_id,
pubkey,
kind,
tags,
content,
created_at,
parentID,
parent_comment_id,
],
);
}