wip: migrate to zustand

This commit is contained in:
Ren Amamiya
2023-05-26 14:45:12 +07:00
parent 5c7b18bf29
commit 671b857077
34 changed files with 494 additions and 530 deletions

View File

@@ -272,7 +272,7 @@ export async function updateChannelMetadata(event_id: string, value: string) {
);
}
// get all chats
// get all chats by pubkey
export async function getChatsByPubkey(pubkey: string) {
const db = await connect();
return await db.select(
@@ -280,6 +280,17 @@ export async function getChatsByPubkey(pubkey: string) {
);
}
// get chat messages
export async function getChatMessages(
receiver_pubkey: string,
sender_pubkey: string,
) {
const db = await connect();
return await db.select(
`SELECT * FROM chats WHERE receiver_pubkey = "${receiver_pubkey}" AND sender_pubkey = "${sender_pubkey}" ORDER BY created_at ASC;`,
);
}
// create chat
export async function createChat(
event_id: string,