wip: convert tauri sql to prisma
This commit is contained in:
@@ -3,7 +3,7 @@ import BaseLayout from '@layouts/base';
|
||||
import { RelayContext } from '@components/relaysProvider';
|
||||
import { UserBase } from '@components/user/base';
|
||||
|
||||
import { createFollows } from '@utils/storage';
|
||||
import { followsTag } from '@utils/transform';
|
||||
|
||||
import { CheckCircledIcon } from '@radix-ui/react-icons';
|
||||
import { createClient } from '@supabase/supabase-js';
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
ReactElement,
|
||||
ReactFragment,
|
||||
ReactPortal,
|
||||
useCallback,
|
||||
useContext,
|
||||
useEffect,
|
||||
useState,
|
||||
@@ -76,18 +77,9 @@ export default function Page() {
|
||||
setFollows(arr);
|
||||
};
|
||||
|
||||
// build event tags
|
||||
const tags = () => {
|
||||
const arr = [];
|
||||
// push item to tags
|
||||
follows.forEach((item) => {
|
||||
arr.push(['p', item]);
|
||||
});
|
||||
return arr;
|
||||
};
|
||||
|
||||
// save follows to database then broadcast
|
||||
const submit = () => {
|
||||
const submit = useCallback(async () => {
|
||||
const { createFollow } = await import('@utils/bindings');
|
||||
setLoading(true);
|
||||
|
||||
// build event
|
||||
@@ -96,21 +88,18 @@ export default function Page() {
|
||||
created_at: Math.floor(Date.now() / 1000),
|
||||
kind: 3,
|
||||
pubkey: id,
|
||||
tags: tags(),
|
||||
tags: followsTag(follows),
|
||||
};
|
||||
event.id = getEventHash(event);
|
||||
event.sig = signEvent(event, privkey);
|
||||
|
||||
createFollows(follows, id, 0)
|
||||
.then((res) => {
|
||||
if (res === 'ok') {
|
||||
// publish to relays
|
||||
pool.publish(event, relays);
|
||||
router.replace('/');
|
||||
}
|
||||
})
|
||||
.catch(console.error);
|
||||
};
|
||||
follows.forEach((item) => {
|
||||
createFollow({ pubkey: item, kind: 0, metadata: JSON.stringify({}), account_id: id });
|
||||
});
|
||||
|
||||
pool.publish(event, relays);
|
||||
router.replace('/');
|
||||
}, [follows, id, pool, privkey, relays, router]);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
|
||||
Reference in New Issue
Block a user