wip: migrate to zustand
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
import { getActiveAccount } from "@utils/storage";
|
||||
import useSWR from "swr";
|
||||
|
||||
const fetcher = () => getActiveAccount();
|
||||
|
||||
export function useActiveAccount() {
|
||||
const { data, error, isLoading } = useSWR("activeAcount", fetcher);
|
||||
|
||||
return {
|
||||
account: data,
|
||||
isLoading,
|
||||
isError: error,
|
||||
};
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user