completed migrate to tauri-sql
This commit is contained in:
@@ -16,19 +16,9 @@ export const BrowseChannelItem = ({ data }: { data: any }) => {
|
||||
[router]
|
||||
);
|
||||
|
||||
const joinChannel = useCallback(
|
||||
async (id: string) => {
|
||||
const { updateChannel } = await import('@utils/bindings');
|
||||
updateChannel({ event_id: id, active: true })
|
||||
.then(() => openChannel(id))
|
||||
.catch(console.error);
|
||||
},
|
||||
[openChannel]
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
onClick={() => openChannel(data.eventId)}
|
||||
onClick={() => openChannel(data.event_id)}
|
||||
className="group relative flex items-center gap-2 border-b border-zinc-800 px-3 py-2.5 hover:bg-black/20"
|
||||
>
|
||||
<div className="relative h-11 w-11 shrink overflow-hidden rounded-md border border-white/10">
|
||||
@@ -44,10 +34,7 @@ export const BrowseChannelItem = ({ data }: { data: any }) => {
|
||||
<span className="text-sm leading-tight text-zinc-400">{channel.about}</span>
|
||||
</div>
|
||||
<div className="absolute right-2 top-1/2 hidden -translate-y-1/2 transform group-hover:inline-flex">
|
||||
<button
|
||||
onClick={() => joinChannel(data.eventId)}
|
||||
className="inline-flex h-8 w-16 items-center justify-center rounded-md bg-fuchsia-500 px-4 text-sm font-medium shadow-button hover:bg-fuchsia-600 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50"
|
||||
>
|
||||
<button className="inline-flex h-8 w-16 items-center justify-center rounded-md bg-fuchsia-500 px-4 text-sm font-medium shadow-button hover:bg-fuchsia-600 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50">
|
||||
Join
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -3,21 +3,10 @@ import { CreateChannelModal } from '@components/channels/createChannelModal';
|
||||
|
||||
import { Globe } from 'iconoir-react';
|
||||
import Link from 'next/link';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useState } from 'react';
|
||||
|
||||
export default function ChannelList() {
|
||||
const [list, setList] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchChannels = async () => {
|
||||
const { getActiveChannels } = await import('@utils/bindings');
|
||||
return await getActiveChannels({ active: true });
|
||||
};
|
||||
|
||||
fetchChannels()
|
||||
.then((res) => setList(res))
|
||||
.catch(console.error);
|
||||
}, []);
|
||||
const [list] = useState([]);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-px">
|
||||
|
||||
@@ -8,14 +8,14 @@ export const ChannelListItem = ({ data }: { data: any }) => {
|
||||
|
||||
return (
|
||||
<ActiveLink
|
||||
href={`/nostr/channels/${data.eventId}`}
|
||||
href={`/nostr/channels/${data.event_id}`}
|
||||
activeClassName="dark:bg-zinc-900 dark:text-zinc-100 hover:dark:bg-zinc-800"
|
||||
className="inline-flex items-center gap-2 rounded-md px-2.5 py-1.5 hover:bg-zinc-900"
|
||||
>
|
||||
<div className="relative h-5 w-5 shrink-0 overflow-hidden rounded">
|
||||
<ImageWithFallback
|
||||
src={channel?.picture || DEFAULT_AVATAR}
|
||||
alt={data.eventId}
|
||||
alt={data.event_id}
|
||||
fill={true}
|
||||
className="rounded object-cover"
|
||||
/>
|
||||
|
||||
@@ -6,14 +6,13 @@ import * as Dialog from '@radix-ui/react-dialog';
|
||||
import useLocalStorage from '@rehooks/local-storage';
|
||||
import { Cancel, Plus } from 'iconoir-react';
|
||||
import { getEventHash, signEvent } from 'nostr-tools';
|
||||
import { useCallback, useContext, useState } from 'react';
|
||||
import { useContext, useState } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
|
||||
export const CreateChannelModal = () => {
|
||||
const [pool, relays]: any = useContext(RelayContext);
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
const [activeAccount]: any = useLocalStorage('activeAccount', {});
|
||||
const [activeAccount]: any = useLocalStorage('account', {});
|
||||
|
||||
const {
|
||||
register,
|
||||
@@ -22,11 +21,6 @@ export const CreateChannelModal = () => {
|
||||
formState: { isDirty, isValid },
|
||||
} = useForm();
|
||||
|
||||
const insertChannelToDB = useCallback(async (id, data, account) => {
|
||||
const { createChannel } = await import('@utils/bindings');
|
||||
return await createChannel({ event_id: id, content: data, account_id: account });
|
||||
}, []);
|
||||
|
||||
const onSubmit = (data) => {
|
||||
const event: any = {
|
||||
content: JSON.stringify(data),
|
||||
@@ -40,8 +34,6 @@ export const CreateChannelModal = () => {
|
||||
|
||||
// publish channel
|
||||
pool.publish(event, relays);
|
||||
// save to database
|
||||
insertChannelToDB(event.id, data, activeAccount.id);
|
||||
// close modal
|
||||
setOpen(false);
|
||||
// reset form
|
||||
|
||||
@@ -11,7 +11,7 @@ import { useCallback, useContext } from 'react';
|
||||
|
||||
export const HideMessageButton = ({ id }: { id: string }) => {
|
||||
const [pool, relays]: any = useContext(RelayContext);
|
||||
const [activeAccount]: any = useLocalStorage('activeAccount', {});
|
||||
const [activeAccount]: any = useLocalStorage('account', {});
|
||||
|
||||
const hideMessage = useCallback(() => {
|
||||
const event: any = {
|
||||
|
||||
@@ -11,7 +11,7 @@ import { useCallback, useContext } from 'react';
|
||||
|
||||
export const MuteButton = ({ pubkey }: { pubkey: string }) => {
|
||||
const [pool, relays]: any = useContext(RelayContext);
|
||||
const [activeAccount]: any = useLocalStorage('activeAccount', {});
|
||||
const [activeAccount]: any = useLocalStorage('account', {});
|
||||
|
||||
const muteUser = useCallback(() => {
|
||||
const event: any = {
|
||||
|
||||
Reference in New Issue
Block a user